diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index e2e5e4120d..15e9988300 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -539,6 +539,7 @@ bool IsImageQuery(SpvOp opcode) { case SpvOpImageQuerySizeLod: case SpvOpImageQueryLevels: case SpvOpImageQuerySamples: + case SpvOpImageQueryLod: return true; default: break; @@ -2945,14 +2946,14 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { return false; } - if (IsSampledImageAccess(inst.opcode()) || IsRawImageAccess(inst.opcode())) { - return EmitImageAccess(inst); - } - if (IsImageQuery(inst.opcode())) { return EmitImageQuery(inst); } + if (IsSampledImageAccess(inst.opcode()) || IsRawImageAccess(inst.opcode())) { + return EmitImageAccess(inst); + } + switch (inst.opcode()) { case SpvOpNop: return true; @@ -4174,8 +4175,6 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { case SpvOpImageGather: case SpvOpImageDrefGather: return Fail() << " image gather is not yet supported"; - case SpvOpImageQueryLod: - return Fail() << " image query Lod is not yet supported"; case SpvOpImageFetch: // Read a single texel from a sampled image. builtin_name = "textureLoad"; @@ -4398,6 +4397,10 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) { create(Source{}, result_type, exprs)}; return EmitConstDefOrWriteToHoistedVar(inst, expr); } + case SpvOpImageQueryLod: + return Fail() << "WGSL does not support querying the level of detail of " + "an image: " + << inst.PrettyPrint(); case SpvOpImageQuerySizeLod: // TODO(dneto) case SpvOpImageQueryLevels: // TODO(dneto) case SpvOpImageQuerySamples: // TODO(dneto) diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc index 0a7143e929..de34c44bdc 100644 --- a/src/reader/spirv/parser_impl_handle_test.cc +++ b/src/reader/spirv/parser_impl_handle_test.cc @@ -4832,6 +4832,15 @@ TEST_F(SpvParserTest, CombinedImageSampler_IsError) { HasSubstr("WGSL does not support combined image-samplers: ")); } +INSTANTIATE_TEST_SUITE_P( + ImageQueryLod_IsError, + SpvParserTest_ImageCoordsTest, + ::testing::ValuesIn(std::vector{ + {"%float 2D 0 0 0 1 Unknown", + "%result = OpImageQueryLod %v2int %sampled_image %vf12", + "WGSL does not support querying the level of detail of an image: ", + {}}})); + } // namespace } // namespace spirv } // namespace reader