【问题标题】:imageLoad and imageStore Seemingly not DefinedimageLoad 和 imageStore 貌似没有定义
【发布时间】:2012-07-02 07:57:04
【问题描述】:

我正在通过在 OpenGL 4.2 中使用原子纹理来实现单通道深度剥离算法。我写了以下片段程序:

#version 420 core
layout(r32i) coherent uniform iimage2D img2D_0;
uniform iimage2D img2D_1;
in vec3 pos;
vec4 insert(vec4 data, float new_data) {
    if      (new_data<data.x) return vec4(      new_data,data.xyz);
    else if (new_data<data.y) return vec4(data.x,new_data,data.yz);
    else if (new_data<data.z) return vec4(data.xy,new_data,data.z);
    else if (new_data<data.w) return vec4(data.xyz,new_data      );
    else                      return data;
}
void main() {
    ivec2 coord = ivec2(gl_FragCoord.xy);
    while (imageAtomicCompSwap(img2D_0,coord,0,1)==1);
    vec4 depths = imageLoad(img2D_1,coord);
    depths = insert(depths,gl_FragCoord.z);
    imageStore(img2D_1,coord,depths);
    memoryBarrier();
    imageAtomicExchange(img2D_0,coord,0);
}

但是,我收到以下错误:

Fragment info
-------------
0(15) : error C1115: unable to find compatible overloaded function "imageLoad(struct iimage2D, ivec2)"
0(17) : error C1115: unable to find compatible overloaded function "imageStore(struct iimage2D, ivec2, vec4)

我注意到我在着色器中使用了#version 420,并且我检查了文档中的函数声明(imageLoadimageStore),它们似乎匹配。奇怪的是,似乎定义了 imageAtomicCompSwap、memoryBarrier 和 imageAtomicExchange。为什么会出现这些错误?

【问题讨论】:

    标签: glsl


    【解决方案1】:
    uniform iimage2D img2D_1;
    

    这不是一个有效的图像定义。您必须使用layout() 来定义其图像格式,除非您已将其声明为writeonly。它应该在这一行出错,但它把它解释为某种结构定义。所以后来你尝试使用它时出错了。

    【讨论】:

    • 谢谢;我将其更改为“layout(RGBA32F) uniform image2D”并编译。
    • @IanMallett:顺便说一句,您可能希望将错误作为驱动程序错误提交给 NVIDIA 或 AMD。他们应该清理错误消息以使其更加明显。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-04
    • 1970-01-01
    相关资源
    最近更新 更多