Files
OpenCL-CTS/test_conformance/vulkan/shaders/image2D.comp.in
Ahmed Hesham 4486241540 Generate the Vulkan shaders at build time (#2199)
Use `add_custom_command` and `add_custom_target` instead of
`execute_process` so the generation of the Vulkan shader is done at
build time and not configuration time.

Use `configure_file` instead of string replacement.

Fixes #2179

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-01-07 09:30:27 -08:00

38 lines
1.4 KiB
Plaintext

#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable
#define MAX_2D_IMAGES 5
#define MAX_2D_IMAGE_MIP_LEVELS 11
#define MAX_2D_IMAGE_DESCRIPTORS MAX_2D_IMAGES * MAX_2D_IMAGE_MIP_LEVELS
layout(binding = 0) buffer Params
{
uint32_t numImage2DDescriptors;
};
layout(binding = 1, ${GLSL_FORMAT}) uniform ${GLSL_TYPE_PREFIX}image2D image2DList[MAX_2D_IMAGE_DESCRIPTORS];
layout(local_size_x = 32, local_size_y = 32) in;
void main()
{
uvec3 numThreads = gl_NumWorkGroups * gl_WorkGroupSize;
for (uint32_t image2DIdx = 0; image2DIdx < numImage2DDescriptors; image2DIdx++)
{
ivec2 imageDim = imageSize(image2DList[image2DIdx]);
uint32_t heightBy2 = imageDim.y / 2;
for (uint32_t row = gl_GlobalInvocationID.y; row < heightBy2; row += numThreads.y)
{
for (uint32_t col = gl_GlobalInvocationID.x; col < imageDim.x; col += numThreads.x)
{
ivec2 coordsA = ivec2(col, row);
ivec2 coordsB = ivec2(col, imageDim.y - row - 1);
${GLSL_TYPE_PREFIX}vec4 dataA = imageLoad(image2DList[image2DIdx], coordsA);
${GLSL_TYPE_PREFIX}vec4 dataB = imageLoad(image2DList[image2DIdx], coordsB);
imageStore(image2DList[image2DIdx], coordsA, dataB);
imageStore(image2DList[image2DIdx], coordsB, dataA);
}
}
}
}