From 32f55426f26c1acbfa74279efa134b1bb4e90ade Mon Sep 17 00:00:00 2001 From: James Price Date: Mon, 2 May 2022 14:53:36 +0000 Subject: [PATCH] Fix uniformity issue in CopyTextureForBrowserHelper Calls to textureSample() must only happen in uniform control flow, so move them to before the conditional discard. Bug: tint:880 Change-Id: Idd6ca35a7acaa6917753da8deb6e9266284afe86 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88463 Reviewed-by: Ben Clayton Kokoro: Kokoro --- src/dawn/native/CopyTextureForBrowserHelper.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dawn/native/CopyTextureForBrowserHelper.cpp b/src/dawn/native/CopyTextureForBrowserHelper.cpp index b2368158f8..528f740ef6 100644 --- a/src/dawn/native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn/native/CopyTextureForBrowserHelper.cpp @@ -130,14 +130,15 @@ static const char sCopyTextureForBrowserShader[] = R"( // Clamp the texcoord and discard the out-of-bound pixels. var clampedTexcoord = clamp(texcoord, vec2(0.0, 0.0), vec2(1.0, 1.0)); - if (!all(clampedTexcoord == texcoord)) { - discard; - } // Swizzling of texture formats when sampling / rendering is handled by the // hardware so we don't need special logic in this shader. This is covered by tests. var color = textureSample(myTexture, mySampler, texcoord); + if (!all(clampedTexcoord == texcoord)) { + discard; + } + let kUnpremultiplyStep = 0x01u; let kDecodeToLinearStep = 0x02u; let kConvertToDstGamutStep = 0x04u;