mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 03:30:06 +00:00
spirv-val: Add WorkgroupMemoryExplicitLayoutKHR check for Block (#5461)
This commit is contained in:
parent
4f014aff9c
commit
c87755bb9f
@ -922,9 +922,9 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) {
|
||||
}
|
||||
}
|
||||
|
||||
if (vstate.HasCapability(
|
||||
spv::Capability::WorkgroupMemoryExplicitLayoutKHR) &&
|
||||
num_workgroup_variables > 0 &&
|
||||
const bool workgroup_blocks_allowed = vstate.HasCapability(
|
||||
spv::Capability::WorkgroupMemoryExplicitLayoutKHR);
|
||||
if (workgroup_blocks_allowed && num_workgroup_variables > 0 &&
|
||||
num_workgroup_variables_with_block > 0) {
|
||||
if (num_workgroup_variables != num_workgroup_variables_with_block) {
|
||||
return vstate.diag(SPV_ERROR_INVALID_BINARY, vstate.FindDef(entry_point))
|
||||
@ -945,6 +945,13 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) {
|
||||
"Entry point id "
|
||||
<< entry_point << " does not meet this requirement.";
|
||||
}
|
||||
} else if (!workgroup_blocks_allowed &&
|
||||
num_workgroup_variables_with_block > 0) {
|
||||
return vstate.diag(SPV_ERROR_INVALID_BINARY,
|
||||
vstate.FindDef(entry_point))
|
||||
<< "Workgroup Storage Class variables can't be decorated with "
|
||||
"Block unless declaring the WorkgroupMemoryExplicitLayoutKHR "
|
||||
"capability.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8003,6 +8003,7 @@ TEST_F(ValidateDecorations, WorkgroupBlockVariableWith16BitType) {
|
||||
OpCapability Shader
|
||||
OpCapability Float16
|
||||
OpCapability Int16
|
||||
OpCapability WorkgroupMemoryExplicitLayoutKHR
|
||||
OpCapability WorkgroupMemoryExplicitLayout16BitAccessKHR
|
||||
OpExtension "SPV_KHR_workgroup_memory_explicit_layout"
|
||||
OpMemoryModel Logical GLSL450
|
||||
@ -8265,6 +8266,37 @@ TEST_F(ValidateDecorations, WorkgroupSingleBlockVariableBadLayout) {
|
||||
"member 0 at offset 1 is not aligned to 4"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, WorkgroupBlockNoCapability) {
|
||||
std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main" %_
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
OpMemberDecorate %struct 1 Offset 4
|
||||
OpDecorate %struct Block
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%struct = OpTypeStruct %int %int
|
||||
%ptr_workgroup = OpTypePointer Workgroup %struct
|
||||
%_ = OpVariable %ptr_workgroup Workgroup
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_BINARY,
|
||||
ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1_SPIRV_1_4));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"Workgroup Storage Class variables can't be decorated with Block "
|
||||
"unless declaring the WorkgroupMemoryExplicitLayoutKHR capability"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, BadMatrixStrideUniform) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
|
Loading…
Reference in New Issue
Block a user