Skip to content

Commit

Permalink
Fix bug in WGSL emitter layout code.
Browse files Browse the repository at this point in the history
There was a "kinds" vs. "kind flags" mismatch, and also getBindingOffsetForKinds was not
being used.

This patch enables a bunch of tests for WGPU.
This helps to address issue shader-slang#4943.
  • Loading branch information
aleino-nv committed Nov 13, 2024
1 parent 0f20fd5 commit 2f9cde7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
8 changes: 6 additions & 2 deletions source/slang/slang-emit-wgsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ void WGSLSourceEmitter::emitParameterGroupImpl(
case LayoutResourceKind::SamplerState:
case LayoutResourceKind::DescriptorTableSlot:
{
auto kinds = LayoutResourceKindFlag::make(LayoutResourceKind::DescriptorTableSlot);
m_writer->emit("@binding(");
m_writer->emit(attr->getOffset());
auto index = getBindingOffsetForKinds(
&containerChain,
kinds);
m_writer->emit(index);
m_writer->emit(") ");
m_writer->emit("@group(");
auto space = getBindingSpaceForKinds(
&containerChain,
LayoutResourceKind::DescriptorTableSlot);
kinds);
m_writer->emit(space);
m_writer->emit(") ");
}
Expand Down
1 change: 0 additions & 1 deletion tests/compute/compile-time-loop.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj
//TEST(compute):COMPARE_RENDER_COMPUTE: -mtl -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE:-wgpu

//TEST_INPUT: Texture2D(size=4, content = one):name t
//TEST_INPUT: Sampler:name s
Expand Down
1 change: 0 additions & 1 deletion tests/compute/discard-stmt.slang
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//TEST_INPUT: Texture2D(size=4, content = one):name tex
//TEST_INPUT: Sampler:name samp
//TEST_INPUT: ubuffer(data=[0 0], stride=4):out,name outputBuffer
//DISABLE_TEST(compute):COMPARE_COMPUTE:-wgpu


Texture2D tex;
Expand Down
1 change: 0 additions & 1 deletion tests/compute/texture-sampling.slang
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//TEST_INPUT: TextureCube(size=4, content = one, arrayLength=2):name=tCubeArray
//TEST_INPUT: Sampler:name=samplerState
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu

Texture1D t1D;
Texture2D t2D;
Expand Down
3 changes: 0 additions & 3 deletions tests/expected-failure-github.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ tests/compute/atomics (wgpu)
tests/compute/atomics-buffer (wgpu)
tests/compute/atomics-groupshared (wgpu)
tests/compute/buffer-type-splitting (wgpu)
tests/compute/compile-time-loop.slang.2 syn (wgpu)
tests/compute/constant-buffer-memory-packing.slang.6 syn (wgpu)
tests/compute/constexpr.slang.2 syn (wgpu)
tests/compute/discard-stmt.slang.2 syn (wgpu)
tests/compute/func-cbuffer-param.slang.4 syn (wgpu)
tests/compute/interface-shader-param-in-struct.slang.4 syn (wgpu)
tests/compute/interface-shader-param.slang.5 syn (wgpu)
tests/compute/loop-unroll.slang.7 syn (wgpu)
tests/compute/matrix-layout.hlsl.3 syn (wgpu)
tests/compute/texture-get-dimensions (wgpu)
tests/compute/texture-sampling (wgpu)
tests/compute/texture-simple (wgpu)
tests/compute/transcendental-double (wgpu)
tests/hlsl-intrinsic/byte-address-buffer/byte-address-struct.slang.5 syn (wgpu)
Expand Down

0 comments on commit 2f9cde7

Please sign in to comment.