Skip to content

Commit 9e21cd4

Browse files
authored
wgpu: Enable Metal-like legalization for byte addressible buffers (shader-slang#5681)
* Enable hlsl-intrinsic/byte-address-buffer/byte-address-struct * Set byte address buffer legalization options for WGSL
1 parent cf0e3a6 commit 9e21cd4

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

source/slang/slang-emit.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,15 @@ Result linkAndOptimizeIR(
12001200
byteAddressBufferOptions.translateToStructuredBufferOps = false;
12011201
byteAddressBufferOptions.lowerBasicTypeOps = true;
12021202
break;
1203+
case CodeGenTarget::WGSL:
1204+
case CodeGenTarget::WGSLSPIRV:
1205+
case CodeGenTarget::WGSLSPIRVAssembly:
1206+
byteAddressBufferOptions.scalarizeVectorLoadStore = true;
1207+
byteAddressBufferOptions.treatGetEquivalentStructuredBufferAsGetThis = true;
1208+
byteAddressBufferOptions.translateToStructuredBufferOps = false;
1209+
byteAddressBufferOptions.lowerBasicTypeOps = true;
1210+
byteAddressBufferOptions.useBitCastFromUInt = true;
1211+
break;
12031212
}
12041213

12051214
// We also need to decide whether to translate

tests/expected-failure-github.txt

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ tests/autodiff/custom-intrinsic.slang.2 syn (wgpu)
1212
tests/bugs/buffer-swizzle-store.slang.3 syn (wgpu)
1313
tests/compute/interface-shader-param-in-struct.slang.4 syn (wgpu)
1414
tests/compute/interface-shader-param.slang.5 syn (wgpu)
15-
tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang.5 syn (wgpu)
1615
tests/language-feature/constants/static-const-in-generic-interface.slang.1 syn (wgpu)
1716
tests/language-feature/enums/strongly-typed-id.slang.1 syn (wgpu)
1817
tests/language-feature/generics/tuple.slang.1 syn (wgpu)

tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -shaderobj
1010
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-slang -vk -compute -shaderobj
1111
//TEST(compute):COMPARE_COMPUTE_EX:-slang -cuda -compute -shaderobj
12-
// WGSL: Signed int initialized using unsigned int #5283
13-
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu
1412

1513
// Note: This input should really be just a `ByteAddressBuffer`,
1614
// so that we can confirm that the functionality works in the

0 commit comments

Comments
 (0)