If one declares some bindless textures with a ubo while also binding a image traditionally and then calls imageSize on the traditionally bound image the driver will crash. Have not tested textureSize aswell.
gpu rx5700xt : windows 10
driver 23.5.2: broken
driver 22.1.2: working
Added cpu side gl calls with more testing. In the large codebase I wasn't setting a program uniform for that shader and it was still crashing but in a small example was not. just happened to get a different conflicting index location?. However adding a glProgramUniform2i to index location 0 would cause a driver timeout again, maybe separate issues?.
layout (binding = 0) uniform writeonly image2D output_image;
// if declared can also stop timeouts if cpu programUniform set to same location
// driver shifts uniform index of imageSize?
// layout (location = 0) uniform ivec2 uniform_resolution;
// removing this will always stop timeouts. makes no differance if a ubo has actually
// been created and bound to the location with a bindless texture or not
layout (std140, binding = 0) uniform BINDLESS_TEXTURE_BUFFER {
sampler2D reflectance_texture;
};
void main() {
ivec2 resolution = imageSize(output_image); // crash
ivec2 invCoord = ivec2(gl_GlobalInvocationID.xy);
imageStore(output_image, invCoord, vec4(0, 0, 0, 1));
}
// init
int textureID, pipelineID;
int shaderID = glCreateShaderProgramv(GL_COMPUTE_SHADER, 1, shader_string);
glCreateTextures(GL_TEXTURE_2D, 1, &textureID);
glTextureStorage2D(textureID, 1, GL_RGBA16F, 1024, 1024);
glTextureParameteri(textureID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTextureParameteri(textureID, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glCreateProgramPipelines(1, &pipelineID);
glUseProgramStages(pipelineID, GL_COMPUTE_SHADER_BIT, shaderID);
// loop
glBindProgramPipeline(pipelineID);
glProgramUniform2i(programID, 0, 1024, 1024); // 'wasn't calling before' if location set to 1 no crash. imageSize takes slot 0 by default?
glBindImageTexture(0, textureID, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA16F);
glDispatchCompute(1024 / 8, 1024 / 8, 1); // driver timeout on dispatch
Hi @RichPressence ,
Thanks for reporting it. I have whitelisted you and moved the post to the OpenGL forum.
I will forward the issue to the OpenGL team.
Thanks.
An internal bug ticket has been created to track this issue. Will keep you posted on its progress.
Thanks.
Hi @RichPressence ,
As the OpenGL team has asked, could you please clarify on the following shader and API calls?
1. reflectance_texture is declared but not used, is it expected?
sampler2D reflectance_texture;
2. There is no default uniform defined in the shader, then why the following API is called? Is something missing in the shader?
glProgramUniform2i(programID, 0, 1024, 1024);
Thanks.
Ok I haven't been able to find anything app side specific to cause the crash and was able to reproduce with a minimal example, dropbox link: minimal_example
example crashes for me on windows 10, rx5700xt, driver 23.7.1
With regards to sampler2D reflectance_texture; it didn't matter if it was used in the shader or not so I left it unused, but needed to be declared to cause the crash. I have a possible theory why this does not crash on the older driver but would like to make a separate report for that as I think its related but more a side effect.
However in short I believe its due to unused code being striped on previous drivers and seems like this is no longer the case on newer ones (i must do more testing), and I believe this rears its head when you include a math or common shader header into a shader but of course only pull certain things from the included shader file. I wouldn't say that its uncommon to build shaders from reusable shader header files.
About the glProgramUniform2i call again needed to cause the crash, yes it shouldn't be there but didn't crash with the previous 22.5.1 driver. I assume its conflicting with the imageSize call which is also a uniform behind the scenes? and the old driver silently discards the call?
Any who it maybe worth still looking into by the opengl team as I would imagine this could show up in opengl apps now running on the new drivers not realising there's a conflict happening.
Thanks for the clarification and providing the minimal reproducible example. I have shared the above information with the OpenGL team.
Thanks.
Update:
The OpenGL team has implemented a fix for this issue.
Thanks.
Hi @dipak Do you know if the bug fix has already been released? Because I am having the same issue with the currently newest driver available, 5 months later. (see https://community.amd.com/t5/opengl-vulkan/opengl-bug-imagesize-causes-crash-when-using-gl-arb-bindl...)