Skip to main content
Notice removed Draw attention by Makogan
Bounty Ended with russ's answer chosen by Makogan
Notice added Draw attention by Makogan
Bounty Started worth 50 reputation by Makogan
added 856 characters in body
Source Link
Makogan
  • 1.8k
  • 14
  • 31

Assume we have created a program that renders toThe typical scenario for using a texture. Say the declaration is would simply be:

//Create texture
glGenTextures(1, &textureID);
glBindTexture(target, textureID);
glTexImage2D(target, 0, color_format, width, height, 0,
    color_format, GL_UNSIGNED_BYTE, data);

glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

//load to program
glActiveTexture(texture_unit);
glBindTexture(target, textureID);
//Get the uniform location in the program and attach the texture unit
GLuint shadingProgram;location = /*get_uniform_location*/;
glUniform1i(location,texture_unit - GL_TEXTURE0);

//Draw
render();

Assume the shader has compiled successfully and it makes use of the imageStore() funtion.

Just like textures we need to bind the target texture we wish to write to to a binding pointHowever image load store are somewhat different. But we do notFirst, they don't use texture units, we use but image binding units. We also have an additional requirementSecond you need to explicetly callmanually set memory barriers yourself to ensure completion of the writing processstage before reading. Amgon other things.

SoI have read the documentation and attempted to implement things myself but It seems I am doing things wrong. I'd rather just forget about what wouldI have tried and understand properly how this needs to be done step by step.

I want to know what a typical, minimum example use of image load stores qould be.

So creation of the image, writing andto the image, reading from a texture using load/store operations?the image.

Assume we have created a program that renders to a texture. Say the declaration is:

GLuint shadingProgram;

Assume the shader has compiled successfully and it makes use of the imageStore() funtion.

Just like textures we need to bind the target texture we wish to write to to a binding point. But we do not use texture units, we use image binding units. We also have an additional requirement to explicetly call memory barriers to ensure completion of the writing process.

So what would be a typical minimum example of writing and reading from a texture using load/store operations?

The typical scenario for using a texture would simply be:

//Create texture
glGenTextures(1, &textureID);
glBindTexture(target, textureID);
glTexImage2D(target, 0, color_format, width, height, 0,
    color_format, GL_UNSIGNED_BYTE, data);

glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

//load to program
glActiveTexture(texture_unit);
glBindTexture(target, textureID);
//Get the uniform location in the program and attach the texture unit
GLuint location = /*get_uniform_location*/;
glUniform1i(location,texture_unit - GL_TEXTURE0);

//Draw
render();

However image load store are somewhat different. First, they don't use texture units but image units. Second you need to manually set memory barriers yourself to ensure completion of writing stage before reading. Amgon other things.

I have read the documentation and attempted to implement things myself but It seems I am doing things wrong. I'd rather just forget about what I have tried and understand properly how this needs to be done step by step.

I want to know what a typical, minimum example use of image load stores qould be.

So creation of the image, writing to the image, reading from the image.

Source Link
Makogan
  • 1.8k
  • 14
  • 31

What is the typical use case for rendering to an image through imageStore?

Assume we have created a program that renders to a texture. Say the declaration is:

GLuint shadingProgram;

Assume the shader has compiled successfully and it makes use of the imageStore() funtion.

Just like textures we need to bind the target texture we wish to write to to a binding point. But we do not use texture units, we use image binding units. We also have an additional requirement to explicetly call memory barriers to ensure completion of the writing process.

So what would be a typical minimum example of writing and reading from a texture using load/store operations?