From 4d098a7b751c5f2c4eb3a14e743b927a18c85bdd Mon Sep 17 00:00:00 2001 From: David Neto Date: Mon, 1 Feb 2021 21:47:04 +0000 Subject: [PATCH] spirv-reader: WGSL does not support OpImageQueryLod Bug: tint:109 Change-Id: Ife61dca63c605a456407140d5c4fdb6b4bfa97a0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39681 Commit-Queue: David Neto Reviewed-by: Ben Clayton Auto-Submit: David Neto --- src/reader/spirv/function.cc | 15 +++++++++------ src/reader/spirv/parser_impl_handle_test.cc | 9 +++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) 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