diff options
author | alan-baker <alanbaker@google.com> | 2021-10-25 17:40:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 17:40:11 -0400 |
commit | 17a5bacfa7ab0470f45097ce1d3769fe7ea9211c (patch) | |
tree | 4ca0802879920229010145a899654bf5890fc537 | |
parent | 7326b494d079cfd24d08e46e291754151e2b9462 (diff) | |
download | spirv-tools-17a5bacfa7ab0470f45097ce1d3769fe7ea9211c.tar.gz |
Handle missing execution modes for limitation check (#4594)
Fixes https://crbug.com/40216
* Handle entry points with no execution modes when checking implicit
derivative execution model checks
-rw-r--r-- | source/val/validate_image.cpp | 12 | ||||
-rw-r--r-- | test/val/val_image_test.cpp | 36 |
2 files changed, 43 insertions, 5 deletions
diff --git a/source/val/validate_image.cpp b/source/val/validate_image.cpp index 3baff820..64f6ba7b 100644 --- a/source/val/validate_image.cpp +++ b/source/val/validate_image.cpp @@ -2068,11 +2068,13 @@ spv_result_t ImagePass(ValidationState_t& _, const Instruction* inst) { std::string* message) { const auto* models = state.GetExecutionModels(entry_point->id()); const auto* modes = state.GetExecutionModes(entry_point->id()); - if (models->find(SpvExecutionModelGLCompute) != models->end() && - modes->find(SpvExecutionModeDerivativeGroupLinearNV) == - modes->end() && - modes->find(SpvExecutionModeDerivativeGroupQuadsNV) == - modes->end()) { + if (models && + models->find(SpvExecutionModelGLCompute) != models->end() && + (!modes || + (modes->find(SpvExecutionModeDerivativeGroupLinearNV) == + modes->end() && + modes->find(SpvExecutionModeDerivativeGroupQuadsNV) == + modes->end()))) { if (message) { *message = std::string( diff --git a/test/val/val_image_test.cpp b/test/val/val_image_test.cpp index f49c81a5..11b14fb0 100644 --- a/test/val/val_image_test.cpp +++ b/test/val/val_image_test.cpp @@ -6063,6 +6063,42 @@ TEST_F(ValidateImage, ImageTexelPointerRgba16fVulkan) { "R32f, R32i, or R32ui for Vulkan environment")); } +TEST_F(ValidateImage, ImageExecutionModeLimitationNoMode) { + const std::string text = R"( +OpCapability Shader +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %2 " " %4 +%void = OpTypeVoid +%8 = OpTypeFunction %void +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%12 = OpTypeImage %float 2D 0 0 0 1 Rgba8ui +%13 = OpTypeSampledImage %12 +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 +%5 = OpVariable %_ptr_UniformConstant_13 UniformConstant +%_ptr_Input_v4float = OpTypePointer Input %v4float +%4 = OpVariable %_ptr_Input_v4float Input +%v2float = OpTypeVector %float 2 +%float_1_35631564en19 = OpConstant %float 1.35631564e-19 +%2 = OpFunction %void None %8 +%8224 = OpLabel +%6 = OpLoad %13 %5 +%19 = OpLoad %v4float %4 +%20 = OpVectorShuffle %v2float %19 %19 0 1 +%21 = OpVectorTimesScalar %v2float %20 %float_1_35631564en19 +%65312 = OpImageSampleImplicitLod %v4float %6 %21 +OpUnreachable +OpFunctionEnd +)"; + + CompileSuccessfully(text); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("ImplicitLod instructions require " + "DerivativeGroupQuadsNV or DerivativeGroupLinearNV " + "execution mode for GLCompute execution model")); +} + } // namespace } // namespace val } // namespace spvtools |