Merge pull request #1839 from KhronosGroup/spv1.6

Add sanity test for SPIR-V 1.6 modules.
This commit is contained in:
Hans-Kristian Arntzen 2022-01-06 15:51:11 +01:00 committed by GitHub
commit fe5a0aa72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,13 @@
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
float values[];
} _3;
void main()
{
_3.values[gl_GlobalInvocationID.x] += 2.0;
}

View File

@ -0,0 +1,48 @@
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %_ %gl_GlobalInvocationID
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 450
OpName %main "main"
OpName %SSBO "SSBO"
OpMemberName %SSBO 0 "values"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpDecorate %_runtimearr_float ArrayStride 4
OpMemberDecorate %SSBO 0 Offset 0
OpDecorate %SSBO Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_runtimearr_float = OpTypeRuntimeArray %float
%SSBO = OpTypeStruct %_runtimearr_float
%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO
%_ = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%float_2 = OpConstant %float 2
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%uint_1 = OpConstant %uint 1
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
%main = OpFunction %void None %3
%5 = OpLabel
%19 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%20 = OpLoad %uint %19
%23 = OpAccessChain %_ptr_StorageBuffer_float %_ %int_0 %20
%24 = OpLoad %float %23
%25 = OpFAdd %float %24 %float_2
%26 = OpAccessChain %_ptr_StorageBuffer_float %_ %int_0 %20
OpStore %26 %25
OpReturn
OpFunctionEnd

View File

@ -68,6 +68,7 @@ static bool is_valid_spirv_version(uint32_t version)
case 0x10300: // SPIR-V 1.3
case 0x10400: // SPIR-V 1.4
case 0x10500: // SPIR-V 1.5
case 0x10600: // SPIR-V 1.6
return true;
default:

View File

@ -516,8 +516,14 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl
spirv_path = create_temporary()
glsl_path = create_temporary(os.path.basename(shader))
spirv_16 = '.spv16.' in shader
spirv_14 = '.spv14.' in shader
spirv_env = 'vulkan1.1spv1.4' if spirv_14 else 'vulkan1.1'
if spirv_16:
spirv_env = 'spv1.6'
elif spirv_14:
spirv_env = 'vulkan1.1spv1.4'
else:
spirv_env = 'vulkan1.1'
if vulkan or spirv:
vulkan_glsl_path = create_temporary('vk' + os.path.basename(shader))