Fix more CMake compiler warnings about implicit data conversion

Bug: 436300898
Change-Id: Iec1680574898f60f1eea97a9f1e346d1afa5010d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/262734
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp b/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
index 06f043f..73ebc7a 100644
--- a/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
+++ b/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
@@ -407,10 +407,10 @@
         return false;
     }
 
-    key->colorAttachmentCount = renderPassDescriptor->colorAttachmentCount;
+    key->colorAttachmentCount = static_cast<uint8_t>(renderPassDescriptor->colorAttachmentCount);
 
     auto colorAttachments = ityp::SpanFromUntyped<ColorAttachmentIndex>(
-        renderPassDescriptor->colorAttachments, renderPassDescriptor->colorAttachmentCount);
+        renderPassDescriptor->colorAttachments, key->colorAttachmentCount);
 
     key->colorTargetFormats.fill(wgpu::TextureFormat::Undefined);
     for (auto [i, attachment] : Enumerate(colorAttachments)) {
diff --git a/src/dawn/native/BindGroup.cpp b/src/dawn/native/BindGroup.cpp
index 38a3d47..0178f9b 100644
--- a/src/dawn/native/BindGroup.cpp
+++ b/src/dawn/native/BindGroup.cpp
@@ -125,7 +125,7 @@
             DAWN_UNREACHABLE();
     }
 
-    DAWN_INVALID_IF(!IsAligned(entry.offset, requiredBindingAlignment),
+    DAWN_INVALID_IF(!IsAligned(static_cast<uint32_t>(entry.offset), requiredBindingAlignment),
                     "Offset (%u) of %s does not satisfy the minimum %s alignment (%u).",
                     entry.offset, entry.buffer, layout.type, requiredBindingAlignment);
 
diff --git a/src/dawn/native/BlitBufferToTexture.cpp b/src/dawn/native/BlitBufferToTexture.cpp
index f5a926c..168714e 100644
--- a/src/dawn/native/BlitBufferToTexture.cpp
+++ b/src/dawn/native/BlitBufferToTexture.cpp
@@ -491,8 +491,9 @@
         Ref<RenderPassEncoder> pass = commandEncoder->BeginRenderPass(&rpDesc);
         // Bind the resources.
         pass->APISetBindGroup(0, bindGroup.Get());
-        pass->APISetViewport(dst.origin.x, dst.origin.y, copyExtent.width, copyExtent.height, 0.f,
-                             1.f);
+        pass->APISetViewport(static_cast<float>(dst.origin.x), static_cast<float>(dst.origin.y),
+                             static_cast<float>(copyExtent.width),
+                             static_cast<float>(copyExtent.height), 0.f, 1.f);
 
         // Draw to perform the blit.
         pass->APISetPipeline(pipeline.Get());
diff --git a/src/dawn/native/BlitColorToColorWithDraw.cpp b/src/dawn/native/BlitColorToColorWithDraw.cpp
index d363923..3381dfd 100644
--- a/src/dawn/native/BlitColorToColorWithDraw.cpp
+++ b/src/dawn/native/BlitColorToColorWithDraw.cpp
@@ -365,8 +365,10 @@
     }
 
     Ref<RenderPipelineBase> pipeline;
-    DAWN_TRY_ASSIGN(pipeline, GetOrCreateExpandMultisamplePipeline(
-                                  device, pipelineKey, renderPassDescriptor->colorAttachmentCount));
+    DAWN_TRY_ASSIGN(
+        pipeline,
+        GetOrCreateExpandMultisamplePipeline(
+            device, pipelineKey, static_cast<uint8_t>(renderPassDescriptor->colorAttachmentCount)));
 
     Ref<BindGroupLayoutBase> bgl;
     DAWN_TRY_ASSIGN(bgl, pipeline->GetBindGroupLayout(0));
diff --git a/src/dawn/native/BlitTextureToBuffer.cpp b/src/dawn/native/BlitTextureToBuffer.cpp
index 5343b9f..a06da24 100644
--- a/src/dawn/native/BlitTextureToBuffer.cpp
+++ b/src/dawn/native/BlitTextureToBuffer.cpp
@@ -1249,10 +1249,10 @@
 
         params[8] = bytesPerRow;
         params[9] = rowsPerImage;
-        params[10] = shaderStartOffset;
+        params[10] = static_cast<uint32_t>(shaderStartOffset);
 
         // These params are only used for formats smaller than 4 bytes
-        params[11] = (shaderStartOffset % 4) / bytesPerTexel;  // shift
+        params[11] = (static_cast<uint32_t>(shaderStartOffset) % 4) / bytesPerTexel;  // shift
 
         params[16] = bytesPerTexel;
         params[17] = numU32PerRowNeedsWriting;
diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp
index 2feae74..4704f03 100644
--- a/src/dawn/native/Buffer.cpp
+++ b/src/dawn/native/Buffer.cpp
@@ -327,7 +327,7 @@
 
         DAWN_INVALID_IF(!device->HasFeature(Feature::HostMappedPointer), "%s requires %s.",
                         hostMappedDesc->sType, ToAPI(Feature::HostMappedPointer));
-        DAWN_INVALID_IF(!IsAligned(descriptor->size, requiredAlignment),
+        DAWN_INVALID_IF(!IsAligned(static_cast<uint32_t>(descriptor->size), requiredAlignment),
                         "Buffer size (%u) wrapping host-mapped memory was not aligned to %u.",
                         descriptor->size, requiredAlignment);
         DAWN_INVALID_IF(!IsPtrAligned(hostMappedDesc->pointer, requiredAlignment),
diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp
index da7ecb1..8a51f47 100644
--- a/src/dawn/native/CommandEncoder.cpp
+++ b/src/dawn/native/CommandEncoder.cpp
@@ -1916,9 +1916,9 @@
                 // Calculate needed buffer size to hold copied texel data.
                 const TexelBlockInfo& blockInfo =
                     source.texture->GetFormat().GetAspectInfo(aspect).block;
-                const uint64_t bytesPerRow =
+                const uint32_t bytesPerRow =
                     Align(4 * copySize->width, kTextureBytesPerRowAlignment);
-                const uint64_t rowsPerImage = copySize->height;
+                const uint32_t rowsPerImage = copySize->height;
                 uint64_t requiredBytes;
                 DAWN_TRY_ASSIGN(
                     requiredBytes,
diff --git a/src/dawn/native/Commands.cpp b/src/dawn/native/Commands.cpp
index c7c6ff4..d622b35 100644
--- a/src/dawn/native/Commands.cpp
+++ b/src/dawn/native/Commands.cpp
@@ -422,7 +422,7 @@
 
 const char* AddNullTerminatedString(CommandAllocator* allocator, StringView s, uint32_t* length) {
     std::string_view view = s;
-    *length = view.length();
+    *length = static_cast<uint32_t>(view.length());
 
     // Include extra null-terminator character. The string_view may not be null-terminated. It also
     // may already have a null-terminator inside of it, in which case adding the null-terminator is
diff --git a/src/dawn/native/ComputePassEncoder.cpp b/src/dawn/native/ComputePassEncoder.cpp
index d90c1a2..c2c902a 100644
--- a/src/dawn/native/ComputePassEncoder.cpp
+++ b/src/dawn/native/ComputePassEncoder.cpp
@@ -519,7 +519,8 @@
             if (offsets.empty()) {
                 APISetBindGroup(static_cast<uint32_t>(i), bg);
             } else {
-                APISetBindGroup(static_cast<uint32_t>(i), bg, offsets.size(), offsets.data());
+                APISetBindGroup(static_cast<uint32_t>(i), bg, static_cast<uint32_t>(offsets.size()),
+                                offsets.data());
             }
         }
     }
diff --git a/src/dawn/native/ComputePipeline.cpp b/src/dawn/native/ComputePipeline.cpp
index c693829..d787d96 100644
--- a/src/dawn/native/ComputePipeline.cpp
+++ b/src/dawn/native/ComputePipeline.cpp
@@ -41,13 +41,14 @@
     }
 
     ShaderModuleEntryPoint entryPoint;
-    DAWN_TRY_ASSIGN_CONTEXT(entryPoint,
-                            ValidateProgrammableStage(
-                                device, descriptor->compute.module, descriptor->compute.entryPoint,
-                                descriptor->compute.constantCount, descriptor->compute.constants,
-                                descriptor->layout, SingleShaderStage::Compute),
-                            "validating compute stage (%s, entryPoint: %s).",
-                            descriptor->compute.module, descriptor->compute.entryPoint);
+    DAWN_TRY_ASSIGN_CONTEXT(
+        entryPoint,
+        ValidateProgrammableStage(
+            device, descriptor->compute.module, descriptor->compute.entryPoint,
+            static_cast<uint32_t>(descriptor->compute.constantCount), descriptor->compute.constants,
+            descriptor->layout, SingleShaderStage::Compute),
+        "validating compute stage (%s, entryPoint: %s).", descriptor->compute.module,
+        descriptor->compute.entryPoint);
     return {};
 }