57 lines
1.0 KiB
GLSL
57 lines
1.0 KiB
GLSL
#version 460
|
|
|
|
#extension GL_EXT_shader_8bit_storage : require
|
|
|
|
layout (constant_id = 0) const int CHANNELS = 3;
|
|
|
|
layout (local_size_x = 32, local_size_y = 32) in;
|
|
|
|
layout (push_constant) uniform Constants {
|
|
uint x;
|
|
uint y;
|
|
} PC;
|
|
|
|
layout (set = 1, binding = 0, rgba32f) uniform image2D dst;
|
|
|
|
layout (set = 1, binding = 1) buffer input_array
|
|
{
|
|
uint8_t src[];
|
|
};
|
|
|
|
|
|
void main()
|
|
{
|
|
uint x = gl_GlobalInvocationID.x;
|
|
uint y = gl_GlobalInvocationID.y;
|
|
|
|
if(x > PC.x || y > PC.y)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(CHANNELS == 1)
|
|
{
|
|
uint index = x + y * PC.x;
|
|
|
|
vec4 col = vec4(vec3(uint(src[index]) / 255.0), 1.0);
|
|
imageStore(dst, ivec2(x, y), col);
|
|
}
|
|
else if(CHANNELS == 2)
|
|
{
|
|
uint index = (x + y * PC.x) * 2;
|
|
|
|
float f = uint(src[index]) / 255.0;
|
|
float a = uint(src[index+1]) / 255.0;
|
|
vec4 col = vec4(f, f, f, a);
|
|
imageStore(dst, ivec2(x, y), col);
|
|
}
|
|
else if(CHANNELS == 3)
|
|
{
|
|
uint index = (x + y * PC.x) * 3;
|
|
|
|
vec4 col = vec4(uint(src[index]) / 255.0, uint(src[index+1]) / 255.0, uint(src[index+2]) / 255.0, 1.0);
|
|
imageStore(dst, ivec2(x, y), col);
|
|
}
|
|
}
|
|
|