-
Notifications
You must be signed in to change notification settings - Fork 170
Full vulkan inlineconstants support, based on #729 #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
|
|
||
| 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
| 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
|
It is in fact hard to look at these changes separated from the context. |
| static const std::shared_ptr<const SPIRVShaderResources> NullShaderResource; | ||
| // NOTE: while shader is compiled asynchronously, is not available | ||
| if (IsCompiling()) | ||
| return NullShaderResource; |
There was a problem hiding this comment.
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()
| #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 |
There was a problem hiding this comment.
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?
| __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); | ||
| } |
There was a problem hiding this comment.
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
… it can be reconstructed in "PatchShaderConvertUniformBufferToPushConstant" later. 2. Add push constants info to "PipelineLayoutVk" and setup "PipelineLayoutCI.pPushConstantRanges" properly.
…ShaderResources from SPIRV even after ShaderVkImpl::Initialize.
6252996 to
3c23107
Compare
…sh constants data in DeviceContextVkImpl. () DiligentGraphics#747
…eLayoutVk should be completely responsible for initializing the layout. (DiligentGraphics#747)
…ta, follow D3D12 pattern. (DiligentGraphics#747)
Extends
PipelineStateVkImpl::ShaderStageInfowithShaderResourcesso shader reflection data can be reconstructed/updated after SPIR-V patching (e.g., UBO → push constants).Introduces
PushConstantInfoVkand stores push-constant metadata inPipelineLayoutVk;PipelineLayoutVk::Create(...)now configuresVkPipelineLayoutCreateInfo.pPushConstantRanges(and validates size vsmaxPushConstantsSize).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 rebuildSPIRVShaderResourcesfrom SPIR-V afterShaderVkImpl::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::PatchShadersVkto also transferShaderResourcesintoPipelineStateVkImpl::ShaderStageInfo, ensuring archived/serialized Vulkan PSOs keep the per-stage reflection/resources alongside shaders and SPIR-V.