RFR: 8336624: Improve Decora Shader loading for modern APIs

Lukasz Kostyra lkostyra at openjdk.org
Mon Aug 5 16:05:47 UTC 2024


In modern graphics APIs having the knowledge of Shader's name can be necessary - whether it is because of a different Shader storage/loading behavior, or to fetch some additional metadata generated upon Shader precompilation. A good example is shown on development branch for Metal backend, where [a temporary workaround was added](https://github.com/openjdk/jfx-sandbox/blob/metal/modules/javafx.graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSRenderer.java#L270) to provide Metal with loaded Shader's name. Metal API uses shaders stored in a Metal-specific shader library, which makes our "usual ways" of loading shader code and providing it via an InputStream not possible.

This change resolves above problem by adding a `pixelShaderName` argument to `ShaderFactory` interface. Additionally, Glue template for Prism Shaders was updated to also provide both Shader's name and Shader code to the backend. Thanks to this change, Prism backends can determine the best course of action - old backends can ignore newly added `pixelShaderName` parameter and proceed "as usual", while new backends like Metal can adjust shader loading for their needs.

Both D3D and ES2 Prism backends were updated to properly handle these changes.

NOTE: Because Glue template was changed for Prism stock shaders, it might be necessary to run a full clean-rebuild sequence to regenerate JSL Shaders and properly test this change.

I tested this change on Windows, macOS and Linux, both full test run and by randomly picking Ensemble8 examples.

-------------

Commit messages:
 - Provide Shader name in ShaderFactory.createShader

Changes: https://git.openjdk.org/jfx/pull/1530/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1530&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8336624
  Stats: 15 lines in 6 files changed: 5 ins; 0 del; 10 mod
  Patch: https://git.openjdk.org/jfx/pull/1530.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1530/head:pull/1530

PR: https://git.openjdk.org/jfx/pull/1530


More information about the openjfx-dev mailing list