#version 450

layout(set = 0, binding = 0) buffer Pos {
   float values[ ];
};

layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

void main() 
{
	// PRACTICE (how to get 6144 to the shader without hard coding?)
	const uint row_stride = 6144 * 4;

	uint pixel_x = gl_GlobalInvocationID.x;
	uint pixel_y = gl_GlobalInvocationID.y;

	// const int iXCoord = int(gl_WorkGroupID.x * 8 + gl_LocalInvocationID.x);

	// original colors
	float fOriginalRed   = values[ pixel_x * 4 + pixel_y * row_stride];
	float fOriginalGreen = values[ pixel_x * 4 + pixel_y * row_stride + 1];
	float fOriginalBlue  = values[ pixel_x * 4 + pixel_y * row_stride + 2];
	float fOriginalAlpha = values[ pixel_x * 4 + pixel_y * row_stride + 3];
	
	// swap red & green channels (and unnormalize)
	values[pixel_x * 4 + pixel_y * row_stride]     = clamp(fOriginalRed * 255, 0, 255);
	values[pixel_x * 4 + pixel_y * row_stride + 1] = clamp(fOriginalGreen * 255, 0, 255);
	values[pixel_x * 4 + pixel_y * row_stride + 2] = clamp(fOriginalBlue   * 255, 0, 255);
	values[pixel_x * 4 + pixel_y * row_stride + 3] = clamp(255, 0, 255);
}