Skip to content

Conversation

@hzqst
Copy link
Contributor

@hzqst hzqst commented Dec 30, 2025

  • Extends PipelineStateVkImpl::ShaderStageInfo with ShaderResources so shader reflection data can be reconstructed/updated after SPIR-V patching (e.g., UBO → push constants).

  • Introduces PushConstantInfoVk and stores push-constant metadata in PipelineLayoutVk; PipelineLayoutVk::Create(...) now configures VkPipelineLayoutCreateInfo.pPushConstantRanges (and validates size vs maxPushConstantsSize).

  • Adds logic in Vulkan PSO creation to derive push-constant info from signatures and to patch shaders via ConvertUBOToPushConstants, updating both SPIR-V and the associated shader resources.

  • Tweaks validation so push constants are validated but skip descriptor-set resource cache checks; fixes descriptor counting to use ResDesc.GetArraySize().

  • Adds ShaderVkImpl::CreateSPIRVShaderResources(const std::vector<uint32_t>&) to rebuild SPIRVShaderResources from SPIR-V after ShaderVkImpl::Initialize.

  • Persists CI-derived state (EntryPoint, LoadConstantBufferReflection) so reconstructed resources match the original reflection configuration.

  • Changes GetShaderResources() to return a null shared_ptr while compiling asynchronously instead of asserting.

  • Updates SerializedPipelineStateImpl::PatchShadersVk to also transfer ShaderResources into PipelineStateVkImpl::ShaderStageInfo, ensuring archived/serialized Vulkan PSOs keep the per-stage reflection/resources alongside shaders and SPIR-V.

}

void PipelineLayoutVk::Create(RenderDeviceVkImpl* pDeviceVk, RefCntAutoPtr<PipelineResourceSignatureVkImpl> ppSignatures[], Uint32 SignatureCount) noexcept(false)
void PipelineLayoutVk::Create(RenderDeviceVkImpl* pDeviceVk,

Check notice

Code scanning / CodeQL

No raw arrays in interfaces Note

Raw arrays should not be used in interfaces. A container class should be used instead.
Uint32 ArraySize = Attribs.ArraySize;
if (Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS)
{
VERIFY(Flags == PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS, "INLINE_CONSTANTS flag cannot be combined with other flags.");

Check warning

Code scanning / PREfast

Use 'bitwise and' to check if a flag is set. Warning

Use 'bitwise and' to check if a flag is set.
@hzqst hzqst marked this pull request as ready for review December 30, 2025 08:22
@hzqst hzqst changed the title ShaderVk, PipelineLayoutVk, PipelineStateVkImpl update. ShaderVk, PipelineLayoutVk, PipelineStateVkImpl update, based on #729 Dec 31, 2025
@TheMostDiligent
Copy link
Contributor

It is in fact hard to look at these changes separated from the context.
Can you submit the whole remaining changes as one PR - this will be easier to see why they are needed?

Comment on lines +95 to +98
static const std::shared_ptr<const SPIRVShaderResources> NullShaderResource;
// NOTE: while shader is compiled asynchronously, is not available
if (IsCompiling())
return NullShaderResource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right.
If the shader is compiling, no method should be called except for GetStatus()

@hzqst hzqst changed the title ShaderVk, PipelineLayoutVk, PipelineStateVkImpl update, based on #729 Full vulkan inlineconstants support, based on #729 Jan 1, 2026
#include "ManagedVulkanObject.hpp"

// Push constants data storage (max size is typically 128-256 bytes, use 256 for safety)
#define DILIGENT_MAX_PUSH_CONSTANTS_SIZE 256
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this constant to Constants.h, and call it DILIGENT_MAX_INLINE_CONSTANTS_SIZE / MAX_INLINE_CONSTANTS_SIZE similar to other constants.
It is already used in D3D11 and D3D12, so let's make it unified.
Can you submit this as separate PR?

Comment on lines 507 to 517
__forceinline void PushConstants(VkPipelineLayout layout,
VkShaderStageFlags stageFlags,
uint32_t offset,
uint32_t size,
const void* pValues)
{
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
VERIFY_EXPR(pValues != nullptr);
VERIFY_EXPR(size > 0);
vkCmdPushConstants(m_VkCmdBuffer, layout, stageFlags, offset, size, pValues);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also submit this small change as separate PR?
It will reduce the number of changed files

hzqst added a commit to hzqst/DiligentCore that referenced this pull request Jan 2, 2026
hzqst added a commit to hzqst/DiligentCore that referenced this pull request Jan 2, 2026
hzqst added a commit to hzqst/DiligentCore that referenced this pull request Jan 2, 2026
…eLayoutVk should be completely responsible for initializing the layout. (DiligentGraphics#747)
hzqst added a commit to hzqst/DiligentCore that referenced this pull request Jan 2, 2026
hzqst added a commit to hzqst/DiligentCore that referenced this pull request Jan 2, 2026
TheMostDiligent pushed a commit to hzqst/DiligentCore that referenced this pull request Jan 3, 2026
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.

2 participants