Sim*_*sch 5 opengl intel compute-shader
我正在编写一个框架,需要提供一些在 image2D 类型上定义的函数。
但要做到这一点似乎有点困难,而且我找不到任何有关将 an 传递image2D给函数的文档。
这是我的问题的一个最小示例:
#version 440
layout (local_size_x = 16, local_size_y = 16) in;
struct Test
{
bool empty;
};
// Version 1:
// fails with 0:11: '' : imageLoad function cannot access the image defined
// without layout format qualifier or with writeonly memory qualifier
float kernel1(image2D x, Test arg1){
return imageLoad(x, ivec2(1, 1)).x;
}
// Version 2:
// fails with ERROR: 0:16: 'Test' : syntax error syntax error
// doesn't fail without the Test struct at second argument
float kernel2(layout (r32f) image2D x, Test arg2){
return imageLoad(x, ivec2(1, 1)).x;
}
layout (binding=0, r32f) readonly uniform image2D globalvar_A;
const Test globalvar_f = Test(false);
void main(){
// works when other function are commented out
imageLoad(globalvar_A, ivec2(1, 1)).x;
//kernel1(globalvar_A, globalvar_f);
//kernel2(globalvar_A, globalvar_f);
}
Run Code Online (Sandbox Code Playgroud)
这在我的 intel onboard (hd4400) windows 10 上失败。
更复杂的版本no overloaded function found在调用该函数时会生成错误。
在 nvidia 硬件上,我通过输入 来解决这个问题img,image2D1x32_bindless但这似乎是未记录的 nvidia 特定名称争论。
谁能通过这个看似简单的任务为我指明正确的方向?
更新:
我直接从GLSL 4.3 规范4.10 节中举了一个例子:
#version 430
layout (local_size_x = 16, local_size_y = 16) in;
// this works fine without the imageLoad
vec4 funcA(restrict image2D a){ return imageLoad(a, ivec2(1, 1));}
layout(rgba32f) coherent uniform image2D img2;
void main(){
funcA(img1); // OK, adding "restrict" is allowed
}
Run Code Online (Sandbox Code Playgroud)
并且 get imageLoad 函数无法访问没有布局格式限定符定义的图像。我可以通过添加来摆脱它:layout(rgba32f)。但随后我无法将其他结构传递给该函数,因为它会导致语法错误。所以我可以得出结论:
因为imageLoad您必须有一个带有布局限定符的图像,但是为函数参数声明它是错误的/定义不正确的。解析器错误很可能发生,因为内置类型可以工作,这表明解析器对这些类型的支持更强大。
| 归档时间: |
|
| 查看次数: |
1426 次 |
| 最近记录: |