• Advertisement
Sign in to follow this  

Can't Sample Texture After imageStore

This topic is 565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.

 

I am writing to a 3D texture in a compute shader using the imageStore function. In another compute shader I then need to read from this texture. I would like to be able to set it as a sampler uniform and read it using the texture function but this returns a clear value. However, when I attempt to read with imageLoad after binding the texture as an image, I successfully read the pixels. I am aware this problem fits the description of using gl_MemoryBarrier(GL_SHADER_IMAGE_ACCESS_BIT) in place of gl_MemoryBarrier(GL_TEXTURE_FETCH_BIT) but this doesn't seem to affect the output. Strangely, I only encounter this problem with layered textures.

 

Here is the code that dispatches the compute shaders and sets up memory barriers:

 

	glUseProgram(inscatter_compute.program_id);
	glActiveTexture(GL_TEXTURE0 + TRANSMITTANCE_UNIT);
	glBindTexture(GL_TEXTURE_2D, transmittanceTexture);
	glUniform1i(glGetUniformLocation(inscatter_compute.program_id, "transmittance_tex"), TRANSMITTANCE_UNIT);
	glBindImageTexture(0, deltaSRTexture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA16F);
	glBindImageTexture(1, deltaSMTexture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA16F);
	glDispatchCompute(16, 8, 8);
	glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);

	glUseProgram(copy_inscatter_compute.program_id);
	glActiveTexture(GL_TEXTURE0 + DELTA_R_UNIT);
	glBindTexture(GL_TEXTURE_3D, deltaSRTexture);
	glUniform1i(glGetUniformLocation(copy_inscatter_compute.program_id, "delta_sr_tex"), DELTA_R_UNIT);
	glActiveTexture(GL_TEXTURE0 + DELTA_M_UNIT);
	glBindTexture(GL_TEXTURE_3D, deltaSMTexture);
	glUniform1i(glGetUniformLocation(copy_inscatter_compute.program_id, "delta_sm_tex"), DELTA_M_UNIT);
	glBindImageTexture(0, inscatterTexture, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA16F);
	glDispatchCompute(16, 8, 8);
	glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);

I create all of these textures using glTexStorage3D. 

 

Any input would be appreciated. Thank you.

 

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement