diff --git a/filament/backend/src/webgpu/WebGPUDriver.cpp b/filament/backend/src/webgpu/WebGPUDriver.cpp index af0483ca8e..c4d302317b 100644 --- a/filament/backend/src/webgpu/WebGPUDriver.cpp +++ b/filament/backend/src/webgpu/WebGPUDriver.cpp @@ -1970,9 +1970,19 @@ void WebGPUDriver::dispatchCompute(Handle program, math::uint3 workGr //todo } -void WebGPUDriver::scissor( - Viewport scissor) { - //todo +void WebGPUDriver::scissor(Viewport scissor) { + assert_invariant(mRenderPassEncoder); + assert_invariant(mCurrentRenderTarget); + + // The WebGPU scissor starts from the top-left corner + assert_invariant(scissor.left >= 0 && + mCurrentRenderTarget->height >= scissor.bottom + scissor.height /*top >= 0*/ && + scissor.width <= mCurrentRenderTarget->width && + scissor.height <= mCurrentRenderTarget->height); + + mRenderPassEncoder.SetScissorRect(scissor.left, + mCurrentRenderTarget->height - scissor.bottom - scissor.height /*top*/, scissor.width, + scissor.height); } void WebGPUDriver::beginTimerQuery(Handle tqh) { diff --git a/filament/backend/test/test_Scissor.cpp b/filament/backend/test/test_Scissor.cpp index 8b7d5bf788..c5b11bdc40 100644 --- a/filament/backend/test/test_Scissor.cpp +++ b/filament/backend/test/test_Scissor.cpp @@ -32,7 +32,6 @@ using namespace filament; using namespace filament::backend; TEST_F(BackendTest, ScissorViewportRegion) { - SKIP_IF(Backend::WEBGPU, "test cases fail in WebGPU, see b/424157731"); auto& api = getDriverApi(); constexpr int kSrcTexWidth = 1024;