GLSL 中 'pixel_interlock_ordered' 的语法是什么?

What is the syntax for 'pixel_interlock_ordered' in GLSL?

我正在尝试 OpenGL 4.5 中的 ARB_fragment_shader_interlock 扩展,但在尝试使用 pixel_interlock_ordered.

时无法编译着色器
#version 430
#extension GL_ARB_shading_language_420pack : require
#extension GL_ARB_shader_image_load_store : require
#extension GL_ARB_fragment_shader_interlock : require

layout(location = 0, rg8, pixel_interlock_ordered) uniform image2D image1;

void main()
{
    beginInvocationInterlockARB();

    ivec2 coords = ivec2(gl_FragCoord.xy);
    vec4 pixel = imageLoad(image1, coords);

    pixel.g = pixel.g + 0.01;
    if (pixel.g > 0.5)
        pixel.r = pixel.r + 0.01;
    else
        pixel.r = pixel.r + 0.02;

    imageStore(image1, coords, pixel);

    endInvocationInterlockARB();
}

以下着色器编译失败:

0(6) : error C7600: no value specified for layout qualifier 'pixel_interlock_ordered'

这与使用任何随机名称而不是 pixel_interlock_ordered 时得到的错误相同。我猜语法在某种程度上有所不同,但规范 (https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_fragment_shader_interlock.txt) 将其称为 "layout qualifier".

谷歌搜索 "pixel_interlock_ordered" 只找到官方规范的链接,所以我找不到示例。正确的语法是什么?

Layout qualifiers in GLSL are a bit weird. They usually apply to declarations, but some of them effectively apply to the shader as a whole. Such qualifiers are basically shader-specific options 您在着色器中设置。

互锁限定词就是那些类型的限定词。你并不是说这个变量将通过互锁访问,因为这不是互锁的意思。这意味着相对于在同一着色器的其他调用上执行互锁绑定代码,互锁绑定代码的执行将具有一定的 属性。限定符指定执行限制的详细信息。

适用于整个着色器的限定符在语法上指定为 inout 上的限定符(大多数此类限定符使用 in,但少数使用 out):

layout(pixel_interlock_ordered) in;