glsl writes to the other texture?

Started by
-1 comments, last by Yours3!f 10 years, 1 month ago

hi there,

I'm trying to read from one uimage1D and read/write the other uimage1D.

they're declared like this:


layout(location=0, r32ui) readonly uniform uimage1D first;
layout(location=1, r32ui) uniform uimage1D second;

and I'm writing into the second one like this:


void main()
{
  imageStore(second, 0, uvec4(floatBitsToUint(1)) );
}

However what happens is that when I read them back on the cpu side, it turns out that the imageStore actually modifies the READONLY first texture (so it's first element will be 1). I'm puzzled about what happens, I check if I'm binding the correct texture to the correct binding point.


glBindImageTexture( 0, first_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R32UI );
glBindImageTexture( 1, second_tex, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32UI );

also the compiler does give me an error when I'm trying to write the first texture directly.

texture creation:


GLuint first_tex = 0;
glGenTextures( 1, &first_tex );
glBindTexture( GL_TEXTURE_1D, first_tex );
//need unsigned int format for atomics
glTexImage1D( GL_TEXTURE_1D, 0, GL_R32UI, 4 * 8, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, 0 );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

GLuint second_tex = 0;
glGenTextures( 1, &second_tex );
glBindTexture( GL_TEXTURE_1D, second_tex );
//need unsigned int format for atomics
glTexImage1D( GL_TEXTURE_1D, 0, GL_R32UI, 4 * 6, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, 0 );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

cpu side readback:


float firstdata[4*8] = {0};
glBindTexture( GL_TEXTURE_1D, first_tex );
glGetTexImage( GL_TEXTURE_1D, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, firstdata );

float seconddata[4*6] = {0};
glBindTexture( GL_TEXTURE_1D, second_tex );
glGetTexImage( GL_TEXTURE_1D, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, seconddata );

any idea what am I doing wrong?

Best regards,

Yours3!f

This topic is closed to new replies.

Advertisement