- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
OpenGL 中的 2-pass 渲染系统使用绑定(bind)到 2 个帧缓冲区纹理 tex1 和 tex2 的 MRT 着色器。 mrt pass 的目标是计算场景中的过度绘制并在gather pass 中渲染出来。我使用帧缓冲区纹理来传递结果。
它还有一个非常大的工作 ssbo 缓冲区(并且使用固定的屏幕分辨率)并且需要很长时间才能链接,但我可以使用它来执行 atomicAdds。我想要完成的是用 uiimage2D 上的 imageAtomicAdd 操作替换它,就像使用 mrt 通行证一样。
问题是 imageAtomicAdd 的结果总是为零,我希望它会像 atomicAdd 那样上升。
#version 440 core
layout(early_fragment_tests) in;
// this works fine
layout (location = 0) out vec4 tex1;
layout (location = 1) out vec4 tex2;
// this works fine
layout(std430, binding = 3) buffer ssbo_data
{
uint v[1024*768];
};
// this does not work at all.
uniform volatile layout(r32ui) uimage2D imgCounter;
out vec4 frag_colour;
void main ()
{
ivec2 coords = ivec2(gl_FragCoord.xy);
uint addValue = 1u;
uint countOverdraw1 = atomicAdd(v[coords.x + coords.y * 1024], 1u);
uint countOverdraw2 = imageAtomicAdd(imgCounter, ivec2(0,0), 1u);
memoryBarrier();
// supports 256 levels of overdraw..
float overdrawDepth = 256.0;
vec3 c1 = vec3(float(countOverdraw1+1)/overdrawDepth ,0,1);
vec3 c2 = vec3(float(countOverdraw2+1)/overdrawDepth ,0,1);
tex1 = vec4(c1,1);
tex2 = vec4(c2,1);
frag_colour = vec4(1,1,1,1);
}
Atomic operations to any texel that is outside of the boundaries of the bound image will return 0 and do nothing.
char data[1024*768*4];
glGenTextures(1, &m_Handle);
m_Target = GL_TEXTURE_2D;
glActiveTexture(GL_TEXTURE0+6);
glBindTexture(m_Target,m_Handle);
// updated : a sampler object was bound to the texture, but is now removed
glTexParameteri(m_Target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // updated
glTexParameteri(m_Target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // updated
glTexParameteri(m_Target, GL_TEXTURE_WRAP_R, GL_REPEAT); // updated
glTexParameteri(m_Target, GL_TEXTURE_WRAP_S, GL_REPEAT); // updated
glTexParameteri(m_Target, GL_TEXTURE_WRAP_T, GL_REPEAT); // updated
glTexImage2D(m_Target, 0, R32UI, 1024, 768, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, data);
GL_INVALID_OPERATION error generated. The required buffer is missing.
GL_INVALID_ENUM error generated. <pname> requires feature(s) disabled in the current profile.
GL_INVALID_OPERATION error generated. <index> exceeds the maximum number of supported texture units.
GL_INVALID_ENUM error generated. or require feature(s) disabled in the current profile.
GL_INVALID_OPERATION error generated. Can't mix integer and non-integer data
...
最佳答案
那个纹理是不完整的。
请注意,当您绑定(bind)纹理以用于图像加载/存储操作时,您不会将采样器与它一起绑定(bind)。所以所有这些glSamplerParameter
调用对纹理的完整性状态没有意义。
纹理不完整,因为过滤参数为GL_LINEAR
,但纹理是无符号整数格式。创建整数格式纹理时,应始终将纹理的参数设置为有效值。
关于opengl - GLSL:我可以在同一个着色器(pass)中组合 MRT、ssbo 和 imageAtomic 操作吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46788286/
是否可以将 3D RGBA32F 纹理作为与 imageAtomic 操作(即 R32F)兼容的类型传递给着色器,然后以某种方式修改 ivec3 索引,以便确定性地访问 RGBA32F 纹理的适当组件
OpenGL 中的 2-pass 渲染系统使用绑定(bind)到 2 个帧缓冲区纹理 tex1 和 tex2 的 MRT 着色器。 mrt pass 的目标是计算场景中的过度绘制并在gather pa
我是一名优秀的程序员,十分优秀!