dia*_*pir 5 opengl glsl spir-v
我正在尝试使用 SPIR-V专门化常量来定义统一块中数组的大小。
#version 460 core
layout(constant_id = 0) const uint count = 0;
layout(binding = 0) uniform Uniform
{
vec4 foo[count];
uint bar[count];
};
void main() {}
Run Code Online (Sandbox Code Playgroud)
count = 0在着色器中声明 时,编译失败并显示:
array size must be a positive integer
Run Code Online (Sandbox Code Playgroud)
当count = 1特化为 5 时,代码可以编译,但在运行时链接失败,并抱怨别名:
error: different uniforms (named Uniform.foo[4] and Uniform.bar[3]) sharing the same offset within a uniform block (named Uniform) between shaders
error: different uniforms (named Uniform.foo[3] and Uniform.bar[2]) sharing the same offset within a uniform block (named Uniform) between shaders
error: different uniforms (named Uniform.foo[2] and Uniform.bar[1]) sharing the same offset within a uniform block (named Uniform) between shaders
error: different uniforms (named Uniform.foo[1] and Uniform.bar[0]) sharing the same offset within a uniform block (named Uniform) between shaders
Run Code Online (Sandbox Code Playgroud)
似乎统一块的布局(每个成员的偏移)在专业化期间不受影响,因此foo和bar重叠。
显式偏移也不起作用并导致相同的链接错误:
layout(binding = 0, std140) uniform Uniform
{
layout(offset = 0) vec4 foo[count];
layout(offset = count) uint bar[count];
};
Run Code Online (Sandbox Code Playgroud)
这是有意的行为吗?俯瞰?可以使用专门化常量来定义数组的大小吗?
| 归档时间: |
|
| 查看次数: |
1458 次 |
| 最近记录: |