From e1d0ef2002d7b0f459cf689ec1f8e37c4ff2afba Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 26 Jun 2024 09:37:18 -0400 Subject: Expand upon existing `ImageSubscript` support (Metal, GLSL, SPIRV) (#4408) * Add additional `ImageSubscript` features: 1. Added ImageSubscript support for Metal & a test case * Merge GLSL/SPIRV/Metal `ImageSubscript` legalization pass 2. Added multisample support to glsl/spirv/metal for when using ImageSubscript * Added in this PR since the overhaul of the code merges together GLSL/SPIRV/Metal implementation 3. Fixed minor metal texture `Load`/`Read` bugs * [HLSL methods of access do not support subscript accessor for texture cube array](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/texturecubearray) * removed swizzling of uint/int/float * other odd bugs which were causing compile errors note: Compute tests do not work due to what seems to be the GFX backend (causes crash without error report). The tests are disabled. * disable LOD with texture 1d seems that LOD for 1d textures need to be a compile time constant as per an error metal throws * syntax error in hlsl.meta * static_assert alone with intrinsic_asm error provides cleaner errors Note: `static_assert` seems to be unstable and not be fully respected (still require `intrinsic_asm` to avoid a stdlib compile error) * change comment to `// lod is not supported for 1D texture * add `static_assert` in related code gen paths * address review * address review * add asserts as per review comment, NOTE: unclear if these should be release 'asserts' as well --- source/slang/slang-emit-spirv.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 3ee0d9241..51a71d65c 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -2989,12 +2989,26 @@ struct SPIRVEmitContext SpvInst* emitImageLoad(SpvInstParent* parent, IRImageLoad* load) { - return emitInst(parent, load, SpvOpImageRead, load->getDataType(), kResultID, load->getImage(), load->getCoord()); + if (load->hasAuxCoord1()) + { + return emitInst(parent, load, SpvOpImageRead, load->getDataType(), kResultID, load->getImage(), load->getCoord(), SpvImageOperandsSampleMask, load->getAuxCoord1()); + } + else + { + return emitInst(parent, load, SpvOpImageRead, load->getDataType(), kResultID, load->getImage(), load->getCoord()); + } } SpvInst* emitImageStore(SpvInstParent* parent, IRImageStore* store) { - return emitInst(parent, store, SpvOpImageWrite, store->getImage(), store->getCoord(), store->getValue()); + if (store->hasAuxCoord1()) + { + return emitInst(parent, store, SpvOpImageWrite, store->getImage(), store->getCoord(), store->getValue(), SpvImageOperandsSampleMask, store->getAuxCoord1()); + } + else + { + return emitInst(parent, store, SpvOpImageWrite, store->getImage(), store->getCoord(), store->getValue()); + } } SpvInst* emitImageSubscript(SpvInstParent* parent, IRImageSubscript* subscript) -- cgit v1.2.3