spirv: Add a postprocessing pass to fix up uses of OpSampledImage

SPIR-V requires that any instruction using the result of an
OpSampledImage instruction be in the same block as the OpSampledImage.
This is hard to guarantee in code generation but easy to fix after the
fact, by simply inserting a new OpSampledImage before the user of its
result if needed, with the new instruction having the same operands as
the original OpSampledImage.
This change adds a new pass to spv::Builder::postProcess that does this.
This might leave the original OpSampledImage instructions "orphaned"
with no users of their result ID, but dead code elimination would take
care of those further down the line.
This commit is contained in:
arcady-lunarg 2024-05-20 10:25:55 -07:00 committed by GitHub
parent 2712d643b1
commit 7c3c50ea94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 180 additions and 1 deletions

View file

@ -551,6 +551,7 @@ INSTANTIATE_TEST_SUITE_P(
"spv.ext.textureShadowLod.error.frag",
"spv.floatFetch.frag",
"spv.atomicRvalue.error.vert",
"spv.sampledImageBlock.frag",
})),
FileNameAsCustomTestSuffix
);