shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
MIT License
2.18k stars 187 forks source link

Trailing OpTypeRuntimeArray in Uniform Struct #4296

Closed spencer-lunarg closed 5 months ago

spencer-lunarg commented 5 months ago

Taking the hlsl

struct T2 {
    float4 _m0;
};

[[vk::binding(0)]]
    cbuffer ubo : register(b0) {
    int in_val;
    T2 _z0[];
}

float4 main() : SV_TARGET {
    uint x = in_val;
    float4 data = _z0[x]._m0;
    return data;
}

slangc in.hlsl -o out.spv -emit-spirv-directly -target spirv -enable-effect-annotations -entry main -stage fragment it will produce invalid spirv because Vulkan requires Uniform can't have a runtime array if inside a Block

image


if ran with dxc it will give an error

in.hlsl:8:5: error: definition of variable with array type needs an explicit size or an initializer
        T2 _z0[];