Sign in to follow this  
JorenJoestar

Binding location for an image2D in compute shader

Recommended Posts

Hello everyone,

   I am trying to search the binding index of a uniform image2D into a compute shader.

If I have this kind of syntax:

 

layout(rgba16f, binding=0) readonly uniform image2D tex0;

and I use

 

glBindImageTexture(0, ...)

it works of course.
But I can't find any proper way of finding the binding point. glGetUniformLocation does not work of course, but I can't find a method to get the binding.
I would like not to have to explicitly write the binding point in the shader and in the cpu code, but just reflect it!
Any ideas?

Thank you a lot!

Share this post


Link to post
Share on other sites

glGetUniformLocation and glUniform1i/glProgramUniform1i should work just fine like with textures. Is your shader actually using the image in a way that it changes the output? Otherwise the glsl compilers are free to optimize it away. And then any kind of query won't find it in the gl shader object and glGetUniformLocation will return -1!

Edited by Osbios

Share this post


Link to post
Share on other sites

glGetUniformLocation gives you the location. And then you can use the location to set/get the binding via glUniform1i / glGetUniformiv.

Edited by Osbios

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this