DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Component swizzling / vector indexing not considered a constant expression

Open Dolkar opened this issue 3 years ago • 4 comments

This issue manifests when trying to define arrays where the length is a component of a constant variable or expression, which fails to compile with the error "variable length arrays are not supported in HLSL". For a minimal example int array[10] works but int array[(10).x] doesn't. This makes it impossible to use components of constant vectors as array lengths. See http://shader-playground.timjones.io/442b05c88862a2aff43e01ce4c15a811

This works in FXC and is causing us issues when porting shaders to DXC. Thanks in advance for resolving this.

Dolkar avatar Apr 24 '21 13:04 Dolkar