Kotlin: Correctly construct default=zero member structures

Equivalent to handling marked _wgpu_STRUCT_ZERO_INIT in the C headers.

Test: StructuresTest
Bug: 414795549
Change-Id: I39891bcfeb17fdb0446352662e056dff5beabc24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/247134
Commit-Queue: Jim Blackler <jimblackler@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/generator/templates/art/api_kotlin_types.kt b/generator/templates/art/api_kotlin_types.kt
index a8a7e1d..3fc5c86 100644
--- a/generator/templates/art/api_kotlin_types.kt
+++ b/generator/templates/art/api_kotlin_types.kt
@@ -56,7 +56,17 @@
         {{- type.name.CamelCase() }}{{ '?' if optional }}
         {%- if emit_defaults -%}
             {%- if type.has_basic_constructor -%}
-                {{ ' ' }}= {{ type.name.CamelCase() }}()
+                {{ ' ' }}= {{ type.name.CamelCase() }}(
+                    {%- if arg.default_value == 'zero' %}
+                        {%- for member in kotlin_record_members(type.members) %}
+                            {% if member.type.category in ['bitmask', 'enum'] %}
+                                {%- for value in member.type.values if value.value == 0 -%}
+                                    {{ member.name.camelCase() }} =
+                                        {{- member.type.name.CamelCase() }}.{{ as_ktName(value.name.CamelCase()) }},{{ ' ' }}
+                                {%- endfor %}
+                            {%- endif %}
+                        {%- endfor %}
+                    {%- endif %})
             {%- elif optional -%}
                 {{ ' ' }}= null
             {%- endif %}
diff --git a/tools/android/webgpu/src/test/java/android/dawn/StructuresTest.kt b/tools/android/webgpu/src/test/java/android/dawn/StructuresTest.kt
new file mode 100644
index 0000000..39e02d9
--- /dev/null
+++ b/tools/android/webgpu/src/test/java/android/dawn/StructuresTest.kt
@@ -0,0 +1,20 @@
+package android.dawn
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class StructuresTest {
+  @Test
+  fun defaultZeroTest() {
+    val bindingLayoutEntry = BindGroupLayoutEntry(binding = 0, visibility = ShaderStage.Vertex)
+    assertEquals("default=zero member structures not initializing enums to their zero value",
+      SamplerBindingType.BindingNotUsed, bindingLayoutEntry.sampler.type)
+  }
+
+  @Test
+  fun defaultTest() {
+    val sampler = SamplerBindingLayout()
+    assertEquals("Non-defaulted structure not initialized enum to IDL-specified default",
+      SamplerBindingType.Filtering, sampler.type)
+  }
+}