Skip to content

Commit

Permalink
Various fixes to enable some WGSL graphics tests (#5548)
Browse files Browse the repository at this point in the history
* Update Slang-RHI to get WGPU backend fixes

* render-test: Use device local memory type for vertex buffers

This helps to avoid shader-slang/slang-rhi#104

* Fix bug in WGSL emitter layout code.

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 #4943.

* format code

---------

Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
  • Loading branch information
aleino-nv and slangbot authored Nov 13, 2024
1 parent 2be4fa4 commit 91f19be
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions source/slang/slang-emit-wgsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ 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);
auto space = getBindingSpaceForKinds(&containerChain, 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: 1 addition & 0 deletions tests/compute/texture-sampling.slang
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//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
// There is no texture_1d_array type in WGSL https://github.com/shader-slang/slang/issues/5223
//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu

Texture1D t1D;
Expand Down
2 changes: 0 additions & 2 deletions tests/expected-failure-github.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ 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)
Expand Down
2 changes: 1 addition & 1 deletion tools/render-test/render-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ SlangResult RenderTestApp::initialize(

BufferDesc vertexBufferDesc;
vertexBufferDesc.size = kVertexCount * sizeof(Vertex);
vertexBufferDesc.memoryType = MemoryType::Upload;
vertexBufferDesc.memoryType = MemoryType::DeviceLocal;
vertexBufferDesc.usage = BufferUsage::VertexBuffer;
vertexBufferDesc.defaultState = ResourceState::VertexBuffer;

Expand Down

0 comments on commit 91f19be

Please sign in to comment.