PHANTOM
🇮🇳 IN
Skip to content

Enable full vulkan support of specialization constants#770

Open
hzqst wants to merge 3 commits intoDiligentGraphics:specialization_constantsfrom
hzqst:specialization_constants
Open

Enable full vulkan support of specialization constants#770
hzqst wants to merge 3 commits intoDiligentGraphics:specialization_constantsfrom
hzqst:specialization_constants

Conversation

@hzqst
Copy link
Contributor

@hzqst hzqst commented Feb 26, 2026

Following workitem from SpecializationConstants.md has been implemented:

  1. Name -> SpecId matching policy

    • Match SpecializationConstant::Name to reflected specialization constant names from SPIR-V.
    • Scope matching by shader module and stage mask (ShaderStages).
    • Validate uniqueness and type/size compatibility.
    • Define clear error messages for:
      • name not found in target shader module
      • duplicate bindings
      • size/type mismatch
  2. Populate Vulkan structs during PSO creation

    • In Vulkan pipeline state creation flow, build per-shader-module specialization data:
      • std::vector<VkSpecializationMapEntry>
      • contiguous data blob (std::vector<Uint8>)
      • Populate VkSpecializationInfo
    • Attach StageCI.pSpecializationInfo for each VkPipelineShaderStageCreateInfo.
    • Ensure memory lifetime is valid until Vulkan vkCreate*Pipelines call returns.
    • Primary integration file:
      • Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
  3. Pipeline coverage

    • Cover all Vulkan PSO paths that use shader stage create infos (graphics/compute/ray tracing as applicable).
  4. Tests for stage 2

    • Add Vulkan API tests with known specialization constants:
      • graphics path and compute path minimum
      • positive test: output changes when constants change
      • negative test: unknown name / wrong size
    • Reuse existing test infrastructure patterns from inline-constants and Vulkan-specific test suites.

@hzqst
Copy link
Contributor Author

hzqst commented Feb 26, 2026

@TheMostDiligent why we have unrelated error with D3D12 tests even when I did nothing to D3D12 codepath?

[ RUN      ] SparseResourceTest.SparseResidentAliasedBuffer
D:\a\DiligentCore\DiligentCore\Tests\GPUTestFramework\src\TestingSwapChainBase.cpp(125): error: Failed
Image rendered by the test is not identical to the reference image

[  FAILED  ] SparseResourceTest.SparseResidentAliasedBuffer (345 ms)

}

// Validate size compatibility.
if (UserConst.Size != pReflected->Size)

Check warning

Code scanning / PREfast

Dereferencing NULL pointer 'pReflected'. Warning

Dereferencing NULL pointer 'pReflected'.
@hzqst hzqst marked this pull request as ready for review February 26, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant