Skip to content

Conditional resource declaration based on link-time specialization constant fails to compile #10387

@karel-tomanec

Description

@karel-tomanec

Issue Description

When using link-time specialization constants to conditionally declare resources, Slang fails to compile. The use case is transitioning from #ifdef-guarded shader code to link-time specialization constants for conditionally including/excluding resource declarations whose types may be unsupported on certain targets (e.g. RWTexture2DMSArray<uint> on GPUs without multisampled storage image support).

Confirmed as a bug by @csyonghe on Discord.

Reproducer Code

extern static const bool kVariantMSSupported;

Conditional<RWTexture2DMSArray<uint>, kVariantMSSupported> headIndexImageMs;

Expected Behavior

When the specialization constant is false, the resource declaration (and its descriptor binding) should be completely omitted from the final SPIR-V output, since the underlying type may be unsupported on the target. The code should compile successfully regardless of the constant's value.

Actual Behavior

Compilation fails.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions