mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
* Shader -> SPIR-V at CTS build time (#1849) Instead of relying on prebuilt checked-in SPIR-V files, compile available shaders at CTS build time. * Add dependency on glslc (available as part of VULKAN_SDK). * Add optional build flag BUILD_GLSL_SHADERS, OFF by default. * Remove pre-built SPIR-V files * Compile Shader -> SPIR-V at CTS build time * Use glslangValidator for shader -> spirv * Add glslangValidator tool for shader -> spirv * Refactor glslangValidator tool retrieval * Address review comments * Use add_subdirectory() instead of include() * Use glslang instead of glslangValidator * Update Github actions CI to install Vulkan SDK
This commit is contained in:
@@ -43,4 +43,6 @@ set_source_files_properties(
|
||||
PROPERTIES LANGUAGE CXX)
|
||||
include_directories("../common/vulkan_wrapper")
|
||||
|
||||
add_subdirectory(shaders)
|
||||
|
||||
include(../CMakeCommon.txt)
|
||||
|
||||
45
test_conformance/vulkan/shaders/CMakeLists.txt
Normal file
45
test_conformance/vulkan/shaders/CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
# CMP0007:NEW - Don't ignore empty elements in a list
|
||||
cmake_policy(SET CMP0007 NEW)
|
||||
find_program(
|
||||
Vulkan_glslang_binary
|
||||
NAMES glslang
|
||||
HINTS $ENV{VULKAN_SDK})
|
||||
|
||||
if(${Vulkan_glslang_binary} STREQUAL "Vulkan_glslang_binary-NOTFOUND")
|
||||
message(FATAL_ERROR "glslang tool (part of Vulkan SDK) is a prerequisite to compile shaders to spir-v")
|
||||
else()
|
||||
message(STATUS "Found glslang: ${Vulkan_glslang_binary}")
|
||||
|
||||
set(IMAGE2D_SHADER_IN_FILE "image2D.comp")
|
||||
set(IMAGE2D_SHADER_TMP_OUT_FILE "tmp_image2D.comp")
|
||||
set(BUFFER_SHADER_IN_FILE "buffer")
|
||||
set(IMAGE2D_FORMATS_LIST_IN_FILE "image2D_test_formats.txt")
|
||||
|
||||
file(READ ${IMAGE2D_SHADER_IN_FILE} IMAGE2D_SHADER_UNFORMAT_CONTENT)
|
||||
file(STRINGS ${IMAGE2D_FORMATS_LIST_IN_FILE} IMAGE2D_FORMATS_LIST)
|
||||
|
||||
foreach(IMAGE2D_FORMAT ${IMAGE2D_FORMATS_LIST})
|
||||
list(GET IMAGE2D_FORMAT 1 GLSL_FORMAT)
|
||||
list(GET IMAGE2D_FORMAT 2 GLSL_TYPE_PREFIX)
|
||||
string(REPLACE "GLSL_FORMAT" "${GLSL_FORMAT}" IMAGE2D_SHADER_CONTENT "${IMAGE2D_SHADER_UNFORMAT_CONTENT}")
|
||||
string(REPLACE "GLSL_TYPE_PREFIX" "${GLSL_TYPE_PREFIX}" IMAGE2D_SHADER_CONTENT "${IMAGE2D_SHADER_CONTENT}")
|
||||
file(WRITE ${IMAGE2D_SHADER_TMP_OUT_FILE} "${IMAGE2D_SHADER_CONTENT}")
|
||||
execute_process(
|
||||
COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o image2D_${GLSL_FORMAT}.spv ${IMAGE2D_SHADER_TMP_OUT_FILE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE commandStatus
|
||||
OUTPUT_QUIET)
|
||||
if(commandStatus AND NOT commandStatus EQUAL 0)
|
||||
message(FATAL_ERROR "shader -> spir-v compilation failed")
|
||||
endif()
|
||||
endforeach(IMAGE2D_FORMAT)
|
||||
execute_process(
|
||||
COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${BUFFER_SHADER_IN_FILE}.spv ${BUFFER_SHADER_IN_FILE}.comp
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE commandStatus
|
||||
OUTPUT_QUIET)
|
||||
if(commandStatus AND NOT commandStatus EQUAL 0)
|
||||
message(FATAL_ERROR "shader -> spir-v compilation failed")
|
||||
endif()
|
||||
file(REMOVE ${IMAGE2D_SHADER_TMP_OUT_FILE})
|
||||
endif()
|
||||
Binary file not shown.
@@ -10,7 +10,7 @@ layout(binding = 0) buffer Params
|
||||
{
|
||||
uint32_t numImage2DDescriptors;
|
||||
};
|
||||
layout(binding = 1, rgba32f ) uniform image2D image2DList[ MAX_2D_IMAGE_DESCRIPTORS ];
|
||||
layout(binding = 1, GLSL_FORMAT ) uniform GLSL_TYPE_PREFIXimage2D image2DList[ MAX_2D_IMAGE_DESCRIPTORS ];
|
||||
layout(local_size_x = 32, local_size_y = 32) in;
|
||||
void main() {
|
||||
uvec3 numThreads = gl_NumWorkGroups * gl_WorkGroupSize;
|
||||
@@ -21,8 +21,8 @@ void main() {
|
||||
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);
|
||||
vec4 dataA = imageLoad(image2DList[image2DIdx], coordsA);
|
||||
vec4 dataB = imageLoad(image2DList[image2DIdx], coordsB);
|
||||
GLSL_TYPE_PREFIXvec4 dataA = imageLoad(image2DList[image2DIdx], coordsA);
|
||||
GLSL_TYPE_PREFIXvec4 dataB = imageLoad(image2DList[image2DIdx], coordsB);
|
||||
imageStore(image2DList[image2DIdx], coordsA, dataB);
|
||||
imageStore(image2DList[image2DIdx], coordsB, dataA);
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21
test_conformance/vulkan/shaders/image2D_test_formats.txt
Normal file
21
test_conformance/vulkan/shaders/image2D_test_formats.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
VULKAN_FORMAT_R8_UINT;r8ui;u
|
||||
VULKAN_FORMAT_R8_SINT;r8i;i
|
||||
VULKAN_FORMAT_R8G8_UINT;rg8ui;u
|
||||
VULKAN_FORMAT_R8G8_SINT;rg8i;i
|
||||
VULKAN_FORMAT_R8G8B8A8_UINT;rgba8ui;u
|
||||
VULKAN_FORMAT_R8G8B8A8_SINT;rgba8i;i
|
||||
VULKAN_FORMAT_R16_UINT;r16ui;u
|
||||
VULKAN_FORMAT_R16_SINT;r16i;i
|
||||
VULKAN_FORMAT_R16G16_UINT;rg16ui;u
|
||||
VULKAN_FORMAT_R16G16_SINT;rg16i;i
|
||||
VULKAN_FORMAT_R16G16B16A16_UINT;rgba16ui;u
|
||||
VULKAN_FORMAT_R16G16B16A16_SINT;rgba16i;i
|
||||
VULKAN_FORMAT_R32_UINT;r32ui;u
|
||||
VULKAN_FORMAT_R32_SINT;r32i;i
|
||||
VULKAN_FORMAT_R32_SFLOAT;r32f;
|
||||
VULKAN_FORMAT_R32G32_UINT;rg32ui;u
|
||||
VULKAN_FORMAT_R32G32_SINT;rg32i;i
|
||||
VULKAN_FORMAT_R32G32_SFLOAT;rg32f;
|
||||
VULKAN_FORMAT_R32G32B32A32_UINT;rgba32ui;u
|
||||
VULKAN_FORMAT_R32G32B32A32_SINT;rgba32i;i
|
||||
VULKAN_FORMAT_R32G32B32A32_SFLOAT;rgba32f;
|
||||
Reference in New Issue
Block a user