cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

armageddon
Journeyman III

OpenGL bindless textures driver crash

Hello All,

I've stumbled upon another, rather bizzare bug with extension GL_ARB_bindless_texture.
If both vertex shader and fragment shader has functions which accepts as parameter a sampler2D, they must 'decide' if either use bindless one or 'bind' one. Otherwise crash happen, even if fragment shader has just a function definition, without use.

As code is worth more than 1000 words, vertex shader:

#version 460 core 
#extension GL_ARB_bindless_texture : require 
#extension GL_ARB_gpu_shader5 : require

layout (location = 0) in vec2 vertexPosition;

layout (location = 5) out vec3 SomeValue;

uniform sampler2D someTexture;

//vec3 GetByHandle(uvec2 textureHandle, vec2 uv)
//{
//    sampler2D texture = sampler2D(textureHandle);
//	
//    float normal1 = texture2D(texture, uv).r;
//    return normal1.xxx;  	
//}

vec3 GetBySampler(sampler2D texture, vec2 uv)
{	
    float normal1 = texture2D(texture, uv).r;
    return normal1.xxx;  	
}

void main()
{
	//SomeValue = GetByHandle(uvec2(someTexture), vertexPosition);
	SomeValue = GetBySampler(someTexture, vertexPosition);
	
	vec4 vertexPositionWithHeight = vec4(vertexPosition.x, 0.0, vertexPosition.y, 1.0f);

	gl_Position = vertexPositionWithHeight;
}

Fragment shader:

#version 460 core 
#extension GL_ARB_bindless_texture : require 
#extension GL_ARB_gpu_shader5 : require

out vec4 fragColor;

layout (location = 5) in vec3 SomeValue;

vec4 SampleTextureByHandle(uvec2 textureHandle, vec2 coords)
{
	return texture2D(sampler2D(textureHandle), coords);
}

//vec4 SampleTextureBySampler(sampler2D texture, vec2 coords)
//{
//	return texture2D(texture, coords);
//}

void main()
{
	vec3 normalizedValue = normalize(SomeValue);
	fragColor.rgb = normalizedValue;
	fragColor.a = 1.0f;
}

Now, the funny part:
If both vertex and fragment use(has uncommented) GetByHandle and SampleTextureByHandle - everything works. Same situation if GetBySampler and SampleTextureBySampler is used (uncommented).
Removing SampleTextureByHandle and SampleTextureBySampler also works 🙂

It's REALLY bizzare behaviour and I'd love if it be fixed, or at least, if it could return an error or warning.

Driver version: 22.88.2
Graphics Card: RX 480 8GB

Best Regards

0 Likes
4 Replies
dipak
Staff

Hi @armageddon ,

Thank you for posting it. I have reported the issue to the OpenGL team.

Thanks.

dipak
Staff

Hi @armageddon ,

As I've been informed, the OpenGL team was unable to reproduce the issue using the vertex shader and fragment shader mentioned above. Can you please modify these shaders and provide only the relevant code that will reproduce the driver crash?

Thanks.

0 Likes
armageddon
Journeyman III

Hello @dipak ,

I've quickly hacked a sample application based on learnopengl.com texturing tutorial that shows crash in a driver.
Here is a link: https://www.dropbox.com/s/qqbi60jedr95tf3/BindlessBug.7z?dl=0

Following archive contains:
- Compiled debug/release executables
- Problematic shaders
- Source code and Visual Studio 2022 solution

Most important files are in folder shaders. I tried also with newest drivers (22.9.1) on Windows 11 - still crashes :(.
Hope program with source code will help with reproducing issue.
Best Regards,
Michał

0 Likes

Thanks for providing the reproducible test-case. The OpenGL team was able to reproduce the issue. They have created a bug ticket to investigate this issue. 

Thanks.