Capture: Translate ComputePassDescriptor

Bug: 440123094
Change-Id: I6a6a6964b5e3a7aa1b8672cbbae852fa43df0c95
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/258735
Auto-Submit: Gregg Tavares <gman@chromium.org>
Commit-Queue: Gregg Tavares <gman@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/webgpu/CommandBufferWGPU.cpp b/src/dawn/native/webgpu/CommandBufferWGPU.cpp
index 0dc7a6c..2dc7ea8 100644
--- a/src/dawn/native/webgpu/CommandBufferWGPU.cpp
+++ b/src/dawn/native/webgpu/CommandBufferWGPU.cpp
@@ -27,6 +27,7 @@
 
 #include "dawn/native/webgpu/CommandBufferWGPU.h"
 
+#include "dawn/common/StringViewUtils.h"
 #include "dawn/native/webgpu/BufferWGPU.h"
 #include "dawn/native/webgpu/DeviceWGPU.h"
 #include "dawn/native/webgpu/TextureWGPU.h"
@@ -89,6 +90,16 @@
     }
 }
 
+WGPUPassTimestampWrites ToWGPU(const TimestampWrites& writes) {
+    return {
+        .nextInChain = nullptr,
+        // TODO(crbug.com/440123094): Do this when GetInnerHandle is implemented for QuerySetWGPU
+        .querySet = nullptr /*ToBackend(writes.querySet)->GetInnerHandle()*/,
+        .beginningOfPassWriteIndex = writes.beginningOfPassWriteIndex,
+        .endOfPassWriteIndex = writes.endOfPassWriteIndex,
+    };
+}
+
 WGPUTexelCopyTextureInfo ToWGPU(const TextureCopy& copy) {
     return {
         .texture = ToBackend(copy.texture)->GetInnerHandle(),
@@ -102,8 +113,14 @@
                        WGPUCommandEncoder innerEncoder,
                        CommandIterator& commands,
                        BeginComputePassCmd* computePassCmd) {
-    // TODO(crbug.com/440123094): Create actual compute pass descriptor
-    WGPUComputePassEncoder passEncoder = wgpu.commandEncoderBeginComputePass(innerEncoder, nullptr);
+    WGPUPassTimestampWrites timestampWrites = ToWGPU(computePassCmd->timestampWrites);
+    WGPUComputePassDescriptor passDescriptor{
+        .nextInChain = nullptr,
+        .label = ToOutputStringView(computePassCmd->label),
+        .timestampWrites = &timestampWrites,
+    };
+    WGPUComputePassEncoder passEncoder =
+        wgpu.commandEncoderBeginComputePass(innerEncoder, &passDescriptor);
 
     Command type;
     while (commands.NextCommandId(&type)) {