From 256a494cd04e11834bbc036a65ef2bf15de3da5a Mon Sep 17 00:00:00 2001 From: Run Yu Date: Fri, 13 Mar 2026 17:37:54 -0400 Subject: [PATCH] webgpu: implement the scissor backend function (#9783) also enable ScissorViewportRegion backend test. It was previously skipped, now it is passing. BUGS=474393992 --- filament/backend/src/webgpu/WebGPUDriver.cpp | 16 +++++++++++++--- filament/backend/test/test_Scissor.cpp | 1 - 2 files changed, 13 insertions(+), 4 deletions(-) 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;