Sign in to follow this  
Yours3!f

compute shader image store frustration

Recommended Posts

Yours3!f    1532

hi,

 

I'm trying to store some values into a texture using image store, however when I grab the data back with glGetTexImage() I get weird values (3131961357 ???).

I'm on AMD A8-4500m win7 64 bit Catalyst 13.12, no errors etc.

 

cpu side:

//set up texture
GLuint tex = 0;
glGenTextures( 1, &tex );
glBindTexture( GL_TEXTURE_1D, tex );
glTexImage1D( GL_TEXTURE_1D, 0, GL_R32UI, 32, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, 0 );

//...

//render using compute shader
glUseProgram( shader );

glBindImageTexture( 0, tex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R32UI );

glDispatchCompute( 32, 1, 1 );

glMemoryBarrier( GL_SHADER_IMAGE_ACCESS_BARRIER_BIT );
glFinish(); //not really needed just to make sure

//get back results
unsigned data[32] = {0};
glBindTexture( GL_TEXTURE_1D, tex );
glGetTexImage( GL_TEXTURE_1D, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, data );

compute shader:

#version 430
layout(local_size_x = 1) in; //local workgroup size

layout(location=0, r32ui) uniform uimage1D result;

void main()
{
  ivec2 global_id = ivec2( gl_GlobalInvocationID.xy ); //this should go [0...31] right?

  imageStore(result, int(global_id.x), uvec4(1)); //write to each pixel of the texture 1
}

what am I doing wrong?

 

edit: seems like these are the same values as if the compute shader didn't run at all. Sooo the stores aren't happening or what...

 

SOLVED:

you need to put
 

glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

after glTexImage1D on AMD. aaaaaaaaaaaaaaargh :D

 

best regards,

Yours3!f

Edited by Yours3!f

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