0
$\begingroup$

I've been updating an old project that does Marching Cubes using compute shaders, and it fails on my laptop with an old AMD GPU (7670M).

After investigating a bit, I found the problem is with writing to 3D textures using imageStore. I made a simple test case to see what was happening.

Compute shader:

#version 440 core
layout(local_size_x = 4, local_size_y = 4, local_size_z = 4) in;
layout(binding = 0, r32f) uniform image3D img;

void main() {
    imageStore(img, ivec3(gl_GlobalInvocationID), vec4(1, 1, 1, 1));
}

Client code:

glCreateTextures(GL_TEXTURE_3D, 1, &tex);
glTextureStorage3D(tex, 1, GL_R32F, 4, 4, 4);
glBindImageTexture(0, tex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R32F);
glUseProgram(prog);
glDispatchCompute(1, 1, 1);
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
GLfloat pixels[64];
glGetTextureImage(tex, 0, GL_RED, GL_FLOAT, 64, pixels);
for (auto p : pixels) 
    std::cout << p << std::endl;

When inspecting the values written to the texture, it seems only the first layer is written - i get sixteen 1s and the rest are 0s.

The program works fine on every NVidia card I've tested it on, including pretty old laptop cards. I don't have access to any more modern AMD cards right now though. So my question is: is there something different about the way AMD handles 3D textures that i should be aware of? Or does my old card just have crappy drivers?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.