On Thu, 19 Nov 2026 17:45:44 GMT, Lukasz Kostyra <[email protected]> wrote:
>> ## Description >> >> This PR is for review and integration of Direct3D 12 Rendering Pipeline into >> JavaFX mainline. We released three Early Access (EA) versions of this >> implementation while keeping the development ongoing on [JavaFX >> Sandbox](https://github.com/openjdk/jfx-sandbox/tree/direct3d12) and reached >> a stage where it is ready to be integrated into mainline. Any further work >> and potential fixes will be done on mainline. >> >> At the time of writing, this PR is identical to the [JavaFX Sandbox D3D12 >> branch](https://github.com/openjdk/jfx-sandbox/tree/direct3d12) with only >> one difference - the Sandbox defaults to D3D12 backend. This PR, however, >> does *NOT* change the default rendering pipeline on Windows. D3D9 remains >> the default rendering pipeline and D3D12 is optional - it can be selected by >> providing `-Dprism.order=d3d12`. To verify which pipeline is actually in use >> `-Dprism.verbose=true` is recommended. >> >> ## Details >> >> Below are general changes introduced by the backend: >> >> ### JSL changes >> >> - Introduced `HLSL6Backend` class which translates JSL shader code into >> HLSL6 code. D3D12 introduced HLSL Shader Level 6 support and won't support >> existing HLSL shaders used with D3D9, as those are compiled for unsupported >> Shader Level 3. >> - D3D12-specific shaders are kept in >> `modules/javafx.graphics/src/main/native-prism-d3d12/hlsl6` >> - Shader compilation is done with DXC instead of FXC (FXC does not support >> SL6). DXC is bundled in Windows SDK which JavaFX already integrates with. >> - Backend also generates C++ headers with Shader resource binding >> information, used by the native-side >> >> ### Build changes >> >> - Added new build tasks for generation and compilation of HLSL6 shaders for >> D3D12 >> - Added tasks to compile D3D12 native backend code >> >> ### Prism changes >> >> - Added D3D12-specific Java classes (package `com.sun.prism.d3d12`) and a >> Java-to-JNI layer (package `com.sun.prism.d3d12.ni`) >> - Java implementation is mostly similar to D3D9 implementation, with only >> some minor changes needed to accommodate slightly different presentation >> behavior of the new runtime >> - JNI interface is relatively high level to reduce the amount of JNI calls >> for performance >> - Added a native Prism backend implementation using D3D12 runtime (stored in >> `modules/javafx.graphics/src/main/native-prism-d3d12`) >> - Written in C++ 20 >> - Uses only interfaces available via Windows API with no third-party >> libraries - WinAPI, Windows COM interface system and "bare... > > Lukasz Kostyra has updated the pull request incrementally with six additional > commits since the last revision: > > - Config: Disable clear opts by default > > Current implementation is not the most precise and can cause rendering > errors. It will be restored when further improved as a follow-up. > - Static analysis fixes from @kevinrushforth > > Omitted GetArrayLength() fix because it is more complex and needs more > time. > - Cleanup unused functions/methods/classes > > Some methods (ex. from Matrix, BBox or Config) were left for future > convenience. > - RenderingContext: Cleanup Mesh rebuild changes > > - Changed CopyResource action to now use ITrackedResource objects and to > perform D3D12 State transitions > - Removed CopyBufferRegion Action > - Review comments from @jayathirthrao, update Buffer initialization > > - Fixed MSAA support polling > - Adjusted code initializing Internal::Buffer: > - Now Buffer::Init will only initialize data when we create an > UPLOAD-heap Buffer for convenienice > - DEFAULT-heap Buffers now require manual update via RenderingContext > - RenderingContext, similar to Textures, employs a fast path for small > Buffers utilizing preallocated memory > - NativeMesh will now reuse existing VB/IB if BuildGeometryBuffers uses > the same buffer size with new data > - RTContext: Fix potential quad VB data overwrite > > Main Ring Buffer data should be declared before use, together with > ResourceManager's data. Seems like your GHA did not run (anymore). Checks shows 1 / 1. You might need to reenable the GHA actions in your fork. Otherwise, looks good. - Building this branch locally worked fine - Did a first pass with some internal applications, all work and 'feel' the same Did not do a thorough code review yet. Also I plan to do a GraalVM build as well soon. buildSrc/win.gradle line 403: > 401: WIN.prismD3D12.ccFlags = [ccFlags, "/std:c++20", > "/I${project("graphics").projectDir}/build/gensrc/d3d12-headers"].flatten() > 402: WIN.prismD3D12.linker = linker > 403: WIN.prismD3D12.linkFlags = [linkFlags, D3D12Libs].flatten(); Question: do we ne need any special handling here for the `IS_STATIC_BUILD` case as we do in `prismD3D` ? modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeShader.cpp line 258: > 256: { > 257: #endif > 258: In the same spirit as D3D, can we have a `JNI_OnLoad` function here, so that this will work with GraalVM? https://github.com/openjdk/jfx/blob/94168cc51fb449561248fe84184c088a324e7e0d/modules/javafx.graphics/src/main/native-prism-d3d/D3DShader.cc#L203-L207 We can also use another file, e.g. `D3D12NativeLibrary` (did not checked this yet) modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeShader.cpp line 262: > 260: (JNIEnv* env, jobject obj, jlong ptr) > 261: { > 262: if (!ptr) return; Here and some other locations: Not sure what the openjdk / openjfx code convention for C++ is, but should we use `{ .. }` here? ------------- PR Review: https://git.openjdk.org/jfx/pull/2346#pullrequestreview-6054330935 PR Review Comment: https://git.openjdk.org/jfx/pull/2346#discussion_r4692366169 PR Review Comment: https://git.openjdk.org/jfx/pull/2346#discussion_r4692433614 PR Review Comment: https://git.openjdk.org/jfx/pull/2346#discussion_r4692494493
