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 <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/CopyTextureForBrowserHelper.cpp b/src/dawn/native/CopyTextureForBrowserHelper.cpp
index b236815..528f740 100644
--- a/src/dawn/native/CopyTextureForBrowserHelper.cpp
+++ b/src/dawn/native/CopyTextureForBrowserHelper.cpp
@@ -130,14 +130,15 @@
// Clamp the texcoord and discard the out-of-bound pixels.
var clampedTexcoord =
clamp(texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(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;