git: openjdk/jfx-sandbox: direct3d12: Implement Mipmap generation and other minor improvements

duke duke at openjdk.org
Tue Jan 28 14:00:12 UTC 2025


Changeset: d3dde2d6
Branch: direct3d12
Author:    Lukasz Kostyra <lukasz.kostyra at oracle.com>
Date:      2025-01-28 13:18:40 +0000
URL:       https://git.openjdk.org/jfx-sandbox/commit/d3dde2d63dfda12dfc2d289754092d0a205c1f53

Implement Mipmap generation and other minor improvements

This change adds code responsible for generating mipmaps for Textures
using a Compute Shader. Many other smaller changes were incorporated
into this commit, partially because of finding some minor issues and
fixing them as I went instead of leaving them for later and ultimately
forgetting about them.

Main changes:
- Added a Compute path to native-side of the backend. For now it is
  utilized only by MipmapGenComputeShader.
- Added Compute PSO cache and creation to PSOManager.
- Added MipmapGenCS shader.
- Added MimpamGenComputeShader class, handles resources and constants
  for MipmapGenCS.
- Added NativeDevice::GenerateMipmaps() method which is called during
  NativeDevice::UpdateTexture().
- Added calculation of NativeTexture's mip levels if mipmaps are
  requested by Prism.
- Added NativeTexture::WriteUAVToDescriptor() used by shaders to update
  descriptors on resource prep stage
- Switched from B8G8R8X8 to B8G8R8A8 format for 3-byte textures. BGRX
  cannot be used as an UAV according to D3D12 spec and we need UAV
  access for MipmapGenCS. Other than the format this doesn't affect much,
  as TextureUploader already set the alpha channel to max when uploading
  3-byte textures.

Other changes:
- Moved D3D12NativeBuffer into Internal part of the backend and renamed
  it to D3D12Buffer. It has not been used by Java-side and there is no
  need to expose it.
- Simplified some parts of the backend to only use the base
  Internal::Shader class. This allows abstraction between all different
  types of shaders used in the backend.
- Added RootSignatureManager to store Root Signatures used in the
  backend. For now it only stores the Graphics RS used by Phong
  shaders and Compute RS used exclusively by MipmapGenCS - goal is to
  make NativeShader-s also use a shared Graphics RS.
- Delegated SRV creation to Shader instances. This simplifies
  ResourceManager code and allows specialized internal shaders like
  MipmapGenCS to manage Texture (sub)resources better. This also goes in
  pair with first use of UAVs in the backend.
- Updated NativeTexture::EnsureState() with Subresource parameter. Used
  to access Texture's mip levels.
- Added ShaderCommon.hlsl which stores both Graphics and Compute RS
  definitions for all internal shaders.

! build.gradle
! modules/javafx.graphics/src/main/java/com/sun/prism/d3d12/D3D12Mesh.java
! modules/javafx.graphics/src/main/java/com/sun/prism/d3d12/D3D12Pipeline.java
- modules/javafx.graphics/src/main/java/com/sun/prism/d3d12/ni/D3D12NativeBuffer.java
! modules/javafx.graphics/src/main/java/com/sun/prism/d3d12/ni/D3D12NativeShader.java
! modules/javafx.graphics/src/main/java/com/sun/prism/d3d12/ni/DXGIFormat.java
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12Common.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12Constants.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeDevice.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeDevice.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeMesh.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeShader.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeShader.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeTexture.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/D3D12NativeTexture.hpp
= modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12Buffer.cpp
= modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12Buffer.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12InternalShader.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12InternalShader.hpp
+ modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12MipmapGenComputeShader.cpp
+ modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12MipmapGenComputeShader.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12PSOManager.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12PSOManager.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12RenderingContext.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12RenderingContext.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12RenderingParameter.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12ResourceManager.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12ResourceManager.hpp
+ modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12RootSignatureManager.cpp
+ modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12RootSignatureManager.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12Shader.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12ShaderLibrary.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12ShaderLibrary.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12TextureUploader.cpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12TextureUploader.hpp
! modules/javafx.graphics/src/main/native-prism-d3d12/Internal/D3D12Utils.hpp
+ modules/javafx.graphics/src/main/native-prism-d3d12/hlsl6/MipmapGenCS.hlsl
! modules/javafx.graphics/src/main/native-prism-d3d12/hlsl6/Mtl1PS.hlsl
+ modules/javafx.graphics/src/main/native-prism-d3d12/hlsl6/ShaderCommon.hlsl



More information about the openjfx-changes mailing list