Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 17 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


compute shader image store frustration


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Yours3!f   Members   -  Reputation: 1455

Like
0Likes
Like

Posted 29 December 2013 - 12:52 PM

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, 29 December 2013 - 05:38 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS