Add empty constructors to structs with resource fields #117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem
RTX Remix shaders fail to compile with recent versions of the Slang shader compiler (v2025.23.2+) due to error 41024:
This error occurs when attempting to instantiate structs that contain resource types (e.g.,
Texture2D,RWTexture2D) without providing explicit initialization for those fields.Root Cause
Slang recently introduced stricter validation to prevent default-initialization of resource types using empty braces
{}. This is because downstream compilers like DXC do not support default-initializing resources, making this pattern unsafe and non-portable.The error triggers when code like this is encountered:
Solution
Add empty constructors
__init() {}to structs containing resource fields that are explicitly instantiated in shader code:File:
src/dxvk/shaders/rtx/algorithm/path_state.slanghThe empty constructor allows the struct to be instantiated without attempting to default-initialize the resource fields. The existing code pattern of field-by-field assignment continues to work correctly:
Why Only These Structs?
Fixed (2 structs):
DirectPathTextures- explicitly instantiated inintegrate_direct.slanghIndirectPathTextures- explicitly instantiated inintegrate_indirect.slangh,integrate_indirect_closesthit.rchit.slang, andintegrate_indirect_miss.rmiss.slangNot Fixed (6+ structs):
AliasedData0,AliasedData1,AliasedData2(in various*_bindings.slanghfiles)These are declared as
uniform structbindings:The
uniform structpattern declares a shader input binding (similar to a uniform buffer), not a struct instance. These are never instantiated or constructed in shader code - they're bound by the host application. Therefore, they don't trigger error 41024 and don't need the fix.Related
cannotDefaultInitializeResource)