[ganesh][dawn] Disable derivative uniformity warnings

This disables derivative uniformity analysis in the Ganesh Dawn backend.

Change-Id: I8292943e8adf989a5ff5031c8ef562d03821855a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/658116
Commit-Queue: Arman Uguray <armansito@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/ganesh/dawn/GrDawnGpu.cpp b/src/gpu/ganesh/dawn/GrDawnGpu.cpp
index c2f6565..37bc72b 100644
--- a/src/gpu/ganesh/dawn/GrDawnGpu.cpp
+++ b/src/gpu/ganesh/dawn/GrDawnGpu.cpp
@@ -1027,12 +1027,19 @@
 }
 
 wgpu::ShaderModule GrDawnGpu::createShaderModule(const std::string& spirvSource) {
-    wgpu::ShaderModuleSPIRVDescriptor desc;
-    desc.codeSize = spirvSource.size() / 4;
-    desc.code = reinterpret_cast<const uint32_t*>(spirvSource.c_str());
+    wgpu::ShaderModuleSPIRVDescriptor spirvDesc;
+    spirvDesc.codeSize = spirvSource.size() / 4;
+    spirvDesc.code = reinterpret_cast<const uint32_t*>(spirvSource.c_str());
 
-    wgpu::ShaderModuleDescriptor smDesc;
-    smDesc.nextInChain = &desc;
+    // Skia often generates shaders that select a texture/sampler conditionally based on an
+    // attribute (specifically in the case of texture atlas indexing). We disable derivative
+    // uniformity warnings as we expect Skia's behavior to result in well-defined values.
+    wgpu::DawnShaderModuleSPIRVOptionsDescriptor dawnSpirvOptions;
+    dawnSpirvOptions.allowNonUniformDerivatives = true;
 
-    return fDevice.CreateShaderModule(&smDesc);
+    wgpu::ShaderModuleDescriptor desc;
+    desc.nextInChain = &spirvDesc;
+    spirvDesc.nextInChain = &dawnSpirvOptions;
+
+    return fDevice.CreateShaderModule(&desc);
 }