spirv-reader: ImageQuerySize can be on readonly image

Fix how handle usage is collected.  OpImageQuerySize
is usable for *any* image that is either MS=1 or Sampled=0 or 2.
(Sampled=0 is not allowed by Vulkan).
So it's usable by storage images or multisampled image.

OpImageQuerySizeLod is usable by Sampled=1 MS=0 images, ie. sampled
images.

Fixed: tint:422
Change-Id: Ibfbcab2daa8b38f17758a0428a08cb9660496bac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36061
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
David Neto 2021-01-05 16:10:40 +00:00 committed by Commit Bot service account
parent 1637cbb868
commit 938ff5f482
2 changed files with 8 additions and 6 deletions

View File

@ -2087,9 +2087,12 @@ bool ParserImpl::RegisterHandleUsage() {
// Image queries
case SpvOpImageQuerySizeLod:
// Vulkan requires Sampled=1 for this. SPIR-V already requires MS=0.
handle_usage_[get_image(inst)].AddSampledTexture();
break;
case SpvOpImageQuerySize:
// Applies to NonReadable, and hence a write-only storage image
handle_usage_[get_image(inst)].AddStorageWriteTexture();
// Applies to either MS=1 or Sampled=0 or 2.
// So we can't force it to be multisampled, or storage image.
break;
case SpvOpImageQueryLod:
handle_usage_[get_image(inst)].AddSampledTexture();

View File

@ -1070,18 +1070,17 @@ INSTANTIATE_TEST_SUITE_P(
// Image queries
// OpImageQuerySizeLod
// Applies to NonReadable, hence write-only storage
UsageRawImageCase{"f_storage_2d",
"%result = OpImageQuerySizeLod "
"%v2uint %im %uint_1",
"Usage(Texture( write ))"},
"Usage(Texture( is_sampled ))"},
// OpImageQuerySize
// Applies to NonReadable, hence write-only storage
// Could be MS=1 or storage image. So it's non-committal.
UsageRawImageCase{"f_storage_2d",
"%result = OpImageQuerySize "
"%v2uint %im",
"Usage(Texture( write ))"},
"Usage()"},
// OpImageQueryLevels
UsageRawImageCase{"f_texture_2d",