【问题标题】:What is the syntax for 'pixel_interlock_ordered' in GLSL?GLSL 中“pixel_interlock_ordered”的语法是什么?
【发布时间】:2019-02-15 11:07:12
【问题描述】:

我正在尝试 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) 将其称为“布局限定符”。

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

【问题讨论】:

    标签: opengl glsl opengl-extensions


    【解决方案1】:

    GLSL 中的Layout qualifiers 有点奇怪。它们通常应用于声明,但其中一些有效地应用于整个着色器。此类限定符基本上是您在着色器中设置的shader-specific options

    联锁限定符就是这类限定符。您并不是说将通过互锁访问此变量,因为这不是互锁的含义。这意味着,与在同一着色器的其他调用上执行互锁绑定代码相比,互锁绑定代码的执行将具有一定的属性。限定符指定执行限制的详细信息。

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

    layout(pixel_interlock_ordered) in;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-21
      • 1970-01-01
      • 1970-01-01
      • 2020-06-01
      • 1970-01-01
      • 2013-10-17
      • 2020-04-18
      • 2016-06-19
      相关资源
      最近更新 更多