On Thu, 12 Nov 2026 13:56:43 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 with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase. The pull request contains eight additional > commits since the last revision: > > - MeshView: Use weak_ptr for Mesh and Material references > > Changed in-line with NativePhongMaterial change in previous commit > - Review fixes from general comments from @kevinrushforth > > - D3D12Context.java correctly handles NULL destination RTT now > - D3D12SwapChain.java prevents potential NPE when disposing > - D3D12RenderingContext.cpp: > - Shader assignments are now checked based on stored Shader parameter > instead of PSO's bound Shader (fixes incorrect shader resource > assignments after restoring the Context after Blit) > - Clear now handles dirty bboxes better (fixes unnecessary and/or > incorrect bbox estimation) > - D3D12Graphics.java now provides premultiplied clear parameters > - D3D12NativeSwapChain.cpp now checks for tearing support when VSync is > requested disabled, will fall-back to enabled VSync if device does not > support it or we cannot poll DXGI for support > - D3D12NativeRenderTarget.cpp sets underlying Texture's sampling to > linear to match D3D's settings > - D3D12NativePhongMaterial.cpp now uses weak pointers to refer to > texture maps - prevents keeping strong references and keeping the > resources alive despite NativeTexture being released > > Additionally: > - Added logic to unbind Textures from RenderingContext when they are > disposed > - Added a missing Clear call to createRTTexture (found it in D3D backend) > - RenderPerfTest will respect java.animation.fullspeed pre-set when > it is set via a JVM argument > - DXGIFormat: Remove extra newline > - Review comments from @crschnick > > Doesn't contain SwapChain flag adjustment, as this will be solved > separately with SwapChain changes requested by @kevinrushforth > - Update CompileHLSL6Task to latest build fixes > - Merge remote-tracking branch 'upstream/master' into feature/direct3d12 > - Review fixes from @kevinrushforth > - Implement Direct3D12 Rendering Pipeline modules/javafx.graphics/src/main/java/com/sun/prism/d3d12/D3D12Context.java line 76: > 74: int getMSAASampleSize(PixelFormat format) { > 75: int maxSamples = mDevice.getMaximumMSAASampleSize(format); > 76: return maxSamples < 2 ? 1 : (maxSamples < 4 ? 2 : 4); If we are limiting the max samples to 4, what is the use of probing until 16? modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeDevice.cpp line 375: > 373: int NativeDevice::GetMaximumMSAASampleSize(DXGI_FORMAT format) const > 374: { > 375: int maxSamples = 2; We will return maxSamples 2, even if probing with sample count 2 fails. So we will end up selecting unsupported 2x sampling. modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeMesh.cpp line 67: > 65: bool NativeMesh::BuildGeometryBuffers(const void* vbData, size_t vbSize, > const void* ibData, size_t ibSize, DXGI_FORMAT ibFormat) > 66: { > 67: if (mVertexBuffer) Can we avoid disposing of vertex/index buffer when the count is not changed? I see we do that in D3D9 and other pipelines. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2346#discussion_r4583278542 PR Review Comment: https://git.openjdk.org/jfx/pull/2346#discussion_r4583253195 PR Review Comment: https://git.openjdk.org/jfx/pull/2346#discussion_r4596695080
