Single sources for shader constants, bindings and layouts #25
No assignees
Labels
No labels
area/build
area/content
area/editor
area/engine
area/graphics
area/platform
area/repo-wide
area/tests
area/tools
bug
optional
roadmap
size/L
size/M
size/S
No project
No milestone
Blocks
Depends on
#26 Shader packs for material shaders and variants
UnflavoredMeson/Primal_Plus_Plus
#30 Shared renderer modules, D3D12 refit onto them
UnflavoredMeson/Primal_Plus_Plus
#24 ShaderCompilerTool at build time
UnflavoredMeson/Primal_Plus_Plus
Reference
No Branch/Tag specified
Notifications
1 participant
Due date
No due date set.
Reference
UnflavoredMeson/Primal_Plus_Plus#25
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
A constant defined once in C++ and once in HLSL drifts; a struct whose layout differs between C++ and the shader shows up as garbage on screen with no error. One source per constant and a build-time check make those impossible.
Decided
CommonConstants.hlsliasPRIMAL_SHARED_CONSTANT uint Name = ...;; C++ readshlsl::NamethroughSharedTypes.h. No-Ddefines for them.Engine/Graphics/Shaders/EngineShaders.h: a new engine shader is an id and a row.-fvk-*-shiftvalues) inEngine/Graphics/Shaders/ShaderBindings.h, documented for HLSL at the top ofCommon.hlsli. The bindless heap is at set 1 binding 2; heap casts carry the type (Texture2D<float4>(ResourceDescriptorHeap[i])).CommonTypes.hlslito SPIR-V, reads the offsets and strides, and compares them withoffsetof/sizeof; a difference fails the build.Read first
UnflavoredMeson/Primal#17(items 1-4).Engine/Graphics/Direct3D12/Shaders/CommonTypes.hlsliandSharedTypes.honmaster.Steps
CommonConstants.hlsliand delete the C++ copies.ShaderBindings.hand make the compiler pass its shifts.Done when
Claude can help with
Learn
float3followed byfloatis the classic trap.