I have 3D textures of colors, normals and other data of my voxelized scene and because some of this data can't be just averaged i need to calculate mip levels by my own. The 3D texture sizes are (128+64) x 128 x 128, the additional 64 x 128 x 128 are for mip levels.
So when i take the first mip level, which is at (0, 0, 0) with a size of 128 x 128 x 128 and just copy voxels to the second level, which is at (128, 0, 0) the data appears there, but as soon as i copy the second level at (128, 0, 0) to the third at (128, 0, 64) the data doesn't appear at the 3rd level.
shader code:
#version 450 core
layout (local_size_x = 1,
local_size_y = 1,
local_size_z = 1) in;
layout (location = 0) uniform unsigned int resolution;
layout (binding = 0, rgba32f) uniform image3D voxel_texture;
void main()
{
ivec3 index = ivec3(gl_WorkGroupID);
ivec3 spread_index = index * 2;
vec4 voxel = imageLoad(voxel_texture, spread_index);
imageStore(voxel_texture, index + ivec3(resolution, 0, 0), voxel);
// This isn't working
voxel = imageLoad(voxel_texture, spread_index +
ivec3(resolution, 0, 0));
imageStore(voxel_texture, index + ivec3(resolution, 0, 64), voxel);
}
The shader program is dispatched with
glUniform1ui(0, OCTREE_RES);
glBindImageTexture(0, voxel_textures[0], 0, GL_TRUE, 0, GL_READ_WRITE,
GL_RGBA32F);
glDispatchCompute(64, 64, 64);
I don't know if i missed some basic thing, this is my first compute shader. I also tried to use memory barriers but it didn't change a thing.
Increased performance – Mipmapping increases cache efficiency as full-size textures will not be needed as often, and the lower resolution mipmaps will fit more easily in the texture cache. This means texture data doesn't have to be fetched as often, reducing bandwidth usage and increasing application performance.
Compute Shader Stage. To make GPU computing easier accessible especially for graphics applications while sharing common memory mappings, the OpenGL standard introduced the compute shader in OpenGL version 4.3 as a shader stage for computing arbitrary information.
A high-resolution mipmap image is used for objects that are close to the user. Lower-resolution images are used as the object appears farther away. Mipmapping improves the quality of rendered textures at the expense of using more memory.
Platform-specific differences. Metal (for iOS and tvOS platforms) does not support atomic operations on Textures. Metal also does not support GetDimensions queries on buffers. Pass the buffer size info as constant to the shader if needed.
Well you can't expect your second imageLoad to read texels that you just wrote in your first store like that.
And there is no way to synchronize access outside of the 'local' workgroup.
You'll need either :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With