Skip to content

Commit

Permalink
[WebGPU] It is legal to submit zero work to a render bundle but this …
Browse files Browse the repository at this point in the history
…results in a metal error

https://bugs.webkit.org/show_bug.cgi?id=263591
<radar://117417815>

Reviewed by Tadeu Zagallo.

Fix a few other places where zero work was being submitted from the
CTS tests resulting in Metal validation errors.

* Source/WebGPU/WebGPU/RenderBundleEncoder.mm:
(WebGPU::RenderBundleEncoder::drawIndexedIndirect):
(WebGPU::RenderBundleEncoder::drawIndirect):
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
(WebGPU::RenderPassEncoder::drawIndexedIndirect):

Canonical link: https://commits.webkit.org/269724@main
  • Loading branch information
mwyrzykowski committed Oct 24, 2023
1 parent eb5d0db commit a36b56b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/WebGPU/WebGPU/RenderBundleEncoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static void addResource(RenderBundle::ResourcesContainer* resources, id<MTLResou
UNUSED_PARAM(indirectOffset);

auto contents = (MTLDrawIndexedPrimitivesIndirectArguments*)indirectBuffer.buffer().contents;
if (!contents)
if (!contents || !contents->indexCount)
return;

executePreDrawCommands();
Expand All @@ -209,7 +209,7 @@ static void addResource(RenderBundle::ResourcesContainer* resources, id<MTLResou
UNUSED_PARAM(indirectOffset);

auto contents = (MTLDrawPrimitivesIndirectArguments*)indirectBuffer.buffer().contents;
if (!contents)
if (!contents || !contents->instanceCount || !m_indexBuffer.length)
return;

executePreDrawCommands();
Expand Down
3 changes: 3 additions & 0 deletions Source/WebGPU/WebGPU/RenderPassEncoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@

void RenderPassEncoder::drawIndexedIndirect(const Buffer& indirectBuffer, uint64_t indirectOffset)
{
if (!m_indexBuffer.length || !indirectBuffer.buffer().length)
return;

executePreDrawCommands();
[m_renderCommandEncoder drawIndexedPrimitives:m_primitiveType indexType:m_indexType indexBuffer:m_indexBuffer indexBufferOffset:m_indexBufferOffset indirectBuffer:indirectBuffer.buffer() indirectBufferOffset:indirectOffset];
}
Expand Down

0 comments on commit a36b56b

Please sign in to comment.