From 9e21cd4a7552390aff9a1421f2c7f6666876d0bc Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Tue, 26 Nov 2024 13:53:23 +0200 Subject: [PATCH] wgpu: Enable Metal-like legalization for byte addressible buffers (#5681) * Enable hlsl-intrinsic/byte-address-buffer/byte-address-struct * Set byte address buffer legalization options for WGSL --- source/slang/slang-emit.cpp | 9 +++++++++ tests/expected-failure-github.txt | 1 - .../byte-address-buffer/byte-address-struct.slang | 2 -- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 326fc702da..a9d5c5e508 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -1200,6 +1200,15 @@ Result linkAndOptimizeIR( byteAddressBufferOptions.translateToStructuredBufferOps = false; byteAddressBufferOptions.lowerBasicTypeOps = true; break; + case CodeGenTarget::WGSL: + case CodeGenTarget::WGSLSPIRV: + case CodeGenTarget::WGSLSPIRVAssembly: + byteAddressBufferOptions.scalarizeVectorLoadStore = true; + byteAddressBufferOptions.treatGetEquivalentStructuredBufferAsGetThis = true; + byteAddressBufferOptions.translateToStructuredBufferOps = false; + byteAddressBufferOptions.lowerBasicTypeOps = true; + byteAddressBufferOptions.useBitCastFromUInt = true; + break; } // We also need to decide whether to translate diff --git a/tests/expected-failure-github.txt b/tests/expected-failure-github.txt index ee96de7f5d..862f3528e2 100644 --- a/tests/expected-failure-github.txt +++ b/tests/expected-failure-github.txt @@ -12,7 +12,6 @@ tests/autodiff/custom-intrinsic.slang.2 syn (wgpu) tests/bugs/buffer-swizzle-store.slang.3 syn (wgpu) tests/compute/interface-shader-param-in-struct.slang.4 syn (wgpu) tests/compute/interface-shader-param.slang.5 syn (wgpu) -tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang.5 syn (wgpu) tests/language-feature/constants/static-const-in-generic-interface.slang.1 syn (wgpu) tests/language-feature/enums/strongly-typed-id.slang.1 syn (wgpu) tests/language-feature/generics/tuple.slang.1 syn (wgpu) diff --git a/tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang b/tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang index 7d0259e49f..7564a8a0ca 100644 --- a/tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang +++ b/tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang @@ -9,8 +9,6 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -shaderobj //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-slang -vk -compute -shaderobj //TEST(compute):COMPARE_COMPUTE_EX:-slang -cuda -compute -shaderobj -// WGSL: Signed int initialized using unsigned int #5283 -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu // Note: This input should really be just a `ByteAddressBuffer`, // so that we can confirm that the functionality works in the