Skip to content

Commit

Permalink
better explanation of why we want zero-init
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Dec 3, 2024
1 parent 4dee137 commit 31e4087
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ func (g *Generator) DefaultValue(member ParameterType, isDocString bool) string
return ref("WGPU_" + ConstantCase(typ) + "_INIT")
} else if *member.Default == "zero" {
if isDocString {
return "zero (so the entry is `BindingNotUsed`)"
return "zero (which sets the entry to `BindingNotUsed`)"
} else {
return literal("_wgpu_STRUCT_ZERO_INIT")
}
Expand Down
2 changes: 1 addition & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"number",
"boolean"
],
"description": "Default value assigned to this parameter when using initializer macro"
"description": "Default value assigned to this parameter when using initializer macro. Special context-dependent values include constant names (`constant.*`), bitflag names (unprefixed), and `zero` for struct-zero-init (where zero-init is known to have the desired result)."
}
},
"required": [
Expand Down
8 changes: 4 additions & 4 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3423,19 +3423,19 @@ typedef struct WGPUBindGroupLayoutEntry {
*/
WGPUShaderStage visibility;
/**
* The `INIT` macro sets this to zero (so the entry is `BindingNotUsed`).
* The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`).
*/
WGPUBufferBindingLayout buffer;
/**
* The `INIT` macro sets this to zero (so the entry is `BindingNotUsed`).
* The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`).
*/
WGPUSamplerBindingLayout sampler;
/**
* The `INIT` macro sets this to zero (so the entry is `BindingNotUsed`).
* The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`).
*/
WGPUTextureBindingLayout texture;
/**
* The `INIT` macro sets this to zero (so the entry is `BindingNotUsed`).
* The `INIT` macro sets this to zero (which sets the entry to `BindingNotUsed`).
*/
WGPUStorageTextureBindingLayout storageTexture;
} WGPUBindGroupLayoutEntry WGPU_STRUCTURE_ATTRIBUTE;
Expand Down
12 changes: 12 additions & 0 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1618,21 +1618,33 @@ structs:
doc: |
TODO
type: struct.buffer_binding_layout
# Use struct-zero-init here to get .type=BindingNotUsed (0), instead of
# Undefined which is the default in WGPU_BUFFER_BINDING_LAYOUT_INIT.
# Zero-init is conveniently correct for the rest of the fields, too.
default: zero
- name: sampler
doc: |
TODO
type: struct.sampler_binding_layout
# Use struct-zero-init here to get .type=BindingNotUsed (0), instead of
# Undefined which is the default in WGPU_SAMPLER_BINDING_LAYOUT_INIT.
# Zero-init is conveniently correct for the rest of the fields, too.
default: zero
- name: texture
doc: |
TODO
type: struct.texture_binding_layout
# Use struct-zero-init here to get .sampleType=BindingNotUsed (0), instead of
# Undefined which is the default in WGPU_TEXTURE_BINDING_LAYOUT_INIT.
# Zero-init is conveniently correct for the rest of the fields, too.
default: zero
- name: storage_texture
doc: |
TODO
type: struct.storage_texture_binding_layout
# Use struct-zero-init here to get .access=BindingNotUsed (0), instead of
# Undefined which is the default in WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT.
# Zero-init is conveniently correct for the rest of the fields, too.
default: zero
- name: blend_component
doc: |
Expand Down

0 comments on commit 31e4087

Please sign in to comment.