emdawnwebgpu: fix for unclippedDepth moving into PrimitiveState

Found by Emscripten codegen crashing due to trying to stringify a
{{{template insertion}}} from a C_STRUCTS value that didn't exist

Bug: 42241174
Change-Id: I869e50076c32f8de72f323e6e8943ab19a4dbfbb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/205614
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js
index fb72053..10d6aab 100644
--- a/third_party/emdawnwebgpu/library_webgpu.js
+++ b/third_party/emdawnwebgpu/library_webgpu.js
@@ -211,27 +211,21 @@
 
     makeRenderPipelineDesc: (descriptor) => {
       {{{ gpu.makeCheckDescriptor('descriptor') }}}
-      function makePrimitiveState(rsPtr) {
-        if (!rsPtr) return undefined;
-        {{{ gpu.makeCheck('rsPtr') }}}
 
-        // TODO: This small hack assumes that there's only one type that can be in the chain of
-        // WGPUPrimitiveState. The correct thing would be to traverse the chain, but unclippedDepth
-        // is going to move into the core object soon, so we'll just do this for now. See:
-        // https://github.com/webgpu-native/webgpu-headers/issues/212#issuecomment-1682801259
-        var nextInChainPtr = {{{ makeGetValue('rsPtr', C_STRUCTS.WGPUPrimitiveState.nextInChain, '*') }}};
-        var sType = nextInChainPtr ? {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}} : 0;
-
+      function makePrimitiveState(psPtr) {
+        if (!psPtr) return undefined;
+        {{{ gpu.makeCheckDescriptor('psPtr') }}}
         return {
           "topology": WebGPU.PrimitiveTopology[
-            {{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.topology) }}}],
+            {{{ gpu.makeGetU32('psPtr', C_STRUCTS.WGPUPrimitiveState.topology) }}}],
           "stripIndexFormat": WebGPU.IndexFormat[
-            {{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.stripIndexFormat) }}}],
+            {{{ gpu.makeGetU32('psPtr', C_STRUCTS.WGPUPrimitiveState.stripIndexFormat) }}}],
           "frontFace": WebGPU.FrontFace[
-            {{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.frontFace) }}}],
+            {{{ gpu.makeGetU32('psPtr', C_STRUCTS.WGPUPrimitiveState.frontFace) }}}],
           "cullMode": WebGPU.CullMode[
-            {{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.cullMode) }}}],
-          "unclippedDepth": sType === {{{ gpu.SType.PrimitiveDepthClipControl }}} && {{{ gpu.makeGetBool('nextInChainPtr', C_STRUCTS.WGPUPrimitiveDepthClipControl.unclippedDepth) }}},
+            {{{ gpu.makeGetU32('psPtr', C_STRUCTS.WGPUPrimitiveState.cullMode) }}}],
+          "unclippedDepth":
+            {{{ gpu.makeGetBool('psPtr', C_STRUCTS.WGPUPrimitiveState.unclippedDepth) }}},
         };
       }