39 lines
796 B
GLSL
39 lines
796 B
GLSL
#version 460
|
|
|
|
#define u32 uint
|
|
#define f32 float
|
|
|
|
layout(local_size_x = 32, local_size_y = 32) in;
|
|
|
|
layout(set = 1, binding = 0, rgba32f) uniform image2D DrawImage;
|
|
|
|
layout(set = 1, binding = 1) buffer display_buffer
|
|
{
|
|
u32 pixels[];
|
|
};
|
|
|
|
layout(push_constant) uniform PushConst
|
|
{
|
|
uvec2 src_resolution;
|
|
} PC;
|
|
|
|
void main()
|
|
{
|
|
uvec2 src_resolution = PC.src_resolution;
|
|
uvec2 dst_resolution = uvec2(imageSize(DrawImage).xy);
|
|
|
|
uvec2 scale = dst_resolution/src_resolution;
|
|
uvec2 pos = uvec2(gl_GlobalInvocationID.xy);
|
|
|
|
if(pos.x < dst_resolution.x && pos.y < dst_resolution.y)
|
|
{
|
|
uvec2 scaled_pos = pos/scale;
|
|
|
|
u32 index = scaled_pos.y*src_resolution.x + scaled_pos.x;
|
|
|
|
vec4 color = bool(pixels[index]) ? vec4(1.0) : vec4(0.0);
|
|
imageStore(DrawImage, ivec2(pos.xy), color);
|
|
}
|
|
}
|
|
|