Skip to content

Commit 4172299

Browse files
committed
Fix linking of TextureViewSwizzle to TextureViewDescriptor.
"extends" shouldn't have the "struct." prefix. Adds a check in the validator to check that the linking works correctly.
1 parent 3eb62ed commit 4172299

5 files changed

Lines changed: 78 additions & 68 deletions

File tree

gen/validator.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ func mergeAndValidateDuplicates(yamlPaths []string) (errs error) {
135135
objects[o.Name] = o
136136
}
137137
}
138+
139+
for _, s := range structs {
140+
if s.Type == "extension" {
141+
for _, extend := range s.Extends {
142+
if _, exists := structs[extend]; !exists {
143+
errs = errors.Join(errs, fmt.Errorf("merge: struct.%s extends struct.%s that's not found (listed extends should not have the 'struct.' prefix)", s.Name, extend))
144+
}
145+
}
146+
}
147+
}
138148
}
139149
return
140150
}

tests/compile/init_tests_autogen.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
{ WGPUTextureBindingLayout x = WGPU_TEXTURE_BINDING_LAYOUT_INIT; }
6060
{ WGPUTextureBindingViewDimension x = WGPU_TEXTURE_BINDING_VIEW_DIMENSION_INIT; }
6161
{ WGPUTextureComponentSwizzle x = WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT; }
62-
{ WGPUTextureViewDescriptor x = WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT; }
6362
{ WGPUVertexAttribute x = WGPU_VERTEX_ATTRIBUTE_INIT; }
6463
{ WGPUBindGroupEntry x = WGPU_BIND_GROUP_ENTRY_INIT; }
6564
{ WGPUBindGroupLayoutEntry x = WGPU_BIND_GROUP_LAYOUT_ENTRY_INIT; }
@@ -86,6 +85,7 @@
8685
{ WGPUComputePipelineDescriptor x = WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT; }
8786
{ WGPUDeviceDescriptor x = WGPU_DEVICE_DESCRIPTOR_INIT; }
8887
{ WGPURenderPassDescriptor x = WGPU_RENDER_PASS_DESCRIPTOR_INIT; }
88+
{ WGPUTextureViewDescriptor x = WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT; }
8989
{ WGPUVertexState x = WGPU_VERTEX_STATE_INIT; }
9090
{ WGPUFragmentState x = WGPU_FRAGMENT_STATE_INIT; }
9191
{ WGPURenderPipelineDescriptor x = WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT; }

webgpu.h

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ struct WGPUTexelCopyBufferLayout;
303303
struct WGPUTextureBindingLayout;
304304
struct WGPUTextureBindingViewDimension;
305305
struct WGPUTextureComponentSwizzle;
306-
struct WGPUTextureViewDescriptor;
307306
struct WGPUVertexAttribute;
308307
struct WGPUBindGroupEntry;
309308
struct WGPUBindGroupLayoutEntry;
@@ -330,6 +329,7 @@ struct WGPUColorTargetState;
330329
struct WGPUComputePipelineDescriptor;
331330
struct WGPUDeviceDescriptor;
332331
struct WGPURenderPassDescriptor;
332+
struct WGPUTextureViewDescriptor;
333333
struct WGPUVertexState;
334334
struct WGPUFragmentState;
335335
struct WGPURenderPipelineDescriptor;
@@ -3528,70 +3528,6 @@ typedef struct WGPUTextureComponentSwizzle {
35283528
/*.a=*/WGPUComponentSwizzle_Undefined _wgpu_COMMA \
35293529
})
35303530

3531-
/**
3532-
* Default values can be set using @ref WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT as initializer.
3533-
*/
3534-
typedef struct WGPUTextureViewDescriptor {
3535-
WGPUChainedStruct * nextInChain;
3536-
/**
3537-
* This is a \ref NonNullInputString.
3538-
*
3539-
* The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT.
3540-
*/
3541-
WGPUStringView label;
3542-
/**
3543-
* The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined.
3544-
*/
3545-
WGPUTextureFormat format;
3546-
/**
3547-
* The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined.
3548-
*/
3549-
WGPUTextureViewDimension dimension;
3550-
/**
3551-
* The `INIT` macro sets this to `0`.
3552-
*/
3553-
uint32_t baseMipLevel;
3554-
/**
3555-
* The `INIT` macro sets this to @ref WGPU_MIP_LEVEL_COUNT_UNDEFINED.
3556-
*/
3557-
uint32_t mipLevelCount;
3558-
/**
3559-
* The `INIT` macro sets this to `0`.
3560-
*/
3561-
uint32_t baseArrayLayer;
3562-
/**
3563-
* The `INIT` macro sets this to @ref WGPU_ARRAY_LAYER_COUNT_UNDEFINED.
3564-
*/
3565-
uint32_t arrayLayerCount;
3566-
/**
3567-
* If set to @ref WGPUTextureAspect_Undefined,
3568-
* [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All.
3569-
*
3570-
* The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined.
3571-
*/
3572-
WGPUTextureAspect aspect;
3573-
/**
3574-
* The `INIT` macro sets this to @ref WGPUTextureUsage_None.
3575-
*/
3576-
WGPUTextureUsage usage;
3577-
} WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE;
3578-
3579-
/**
3580-
* Initializer for @ref WGPUTextureViewDescriptor.
3581-
*/
3582-
#define WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureViewDescriptor, { \
3583-
/*.nextInChain=*/NULL _wgpu_COMMA \
3584-
/*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \
3585-
/*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \
3586-
/*.dimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \
3587-
/*.baseMipLevel=*/0 _wgpu_COMMA \
3588-
/*.mipLevelCount=*/WGPU_MIP_LEVEL_COUNT_UNDEFINED _wgpu_COMMA \
3589-
/*.baseArrayLayer=*/0 _wgpu_COMMA \
3590-
/*.arrayLayerCount=*/WGPU_ARRAY_LAYER_COUNT_UNDEFINED _wgpu_COMMA \
3591-
/*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \
3592-
/*.usage=*/WGPUTextureUsage_None _wgpu_COMMA \
3593-
})
3594-
35953531
/**
35963532
* Default values can be set using @ref WGPU_VERTEX_ATTRIBUTE_INIT as initializer.
35973533
*/
@@ -4721,6 +4657,70 @@ typedef struct WGPURenderPassDescriptor {
47214657
/*.timestampWrites=*/NULL _wgpu_COMMA \
47224658
})
47234659

4660+
/**
4661+
* Default values can be set using @ref WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT as initializer.
4662+
*/
4663+
typedef struct WGPUTextureViewDescriptor {
4664+
WGPUChainedStruct * nextInChain;
4665+
/**
4666+
* This is a \ref NonNullInputString.
4667+
*
4668+
* The `INIT` macro sets this to @ref WGPU_STRING_VIEW_INIT.
4669+
*/
4670+
WGPUStringView label;
4671+
/**
4672+
* The `INIT` macro sets this to @ref WGPUTextureFormat_Undefined.
4673+
*/
4674+
WGPUTextureFormat format;
4675+
/**
4676+
* The `INIT` macro sets this to @ref WGPUTextureViewDimension_Undefined.
4677+
*/
4678+
WGPUTextureViewDimension dimension;
4679+
/**
4680+
* The `INIT` macro sets this to `0`.
4681+
*/
4682+
uint32_t baseMipLevel;
4683+
/**
4684+
* The `INIT` macro sets this to @ref WGPU_MIP_LEVEL_COUNT_UNDEFINED.
4685+
*/
4686+
uint32_t mipLevelCount;
4687+
/**
4688+
* The `INIT` macro sets this to `0`.
4689+
*/
4690+
uint32_t baseArrayLayer;
4691+
/**
4692+
* The `INIT` macro sets this to @ref WGPU_ARRAY_LAYER_COUNT_UNDEFINED.
4693+
*/
4694+
uint32_t arrayLayerCount;
4695+
/**
4696+
* If set to @ref WGPUTextureAspect_Undefined,
4697+
* [defaults](@ref SentinelValues) to @ref WGPUTextureAspect_All.
4698+
*
4699+
* The `INIT` macro sets this to @ref WGPUTextureAspect_Undefined.
4700+
*/
4701+
WGPUTextureAspect aspect;
4702+
/**
4703+
* The `INIT` macro sets this to @ref WGPUTextureUsage_None.
4704+
*/
4705+
WGPUTextureUsage usage;
4706+
} WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE;
4707+
4708+
/**
4709+
* Initializer for @ref WGPUTextureViewDescriptor.
4710+
*/
4711+
#define WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureViewDescriptor, { \
4712+
/*.nextInChain=*/NULL _wgpu_COMMA \
4713+
/*.label=*/WGPU_STRING_VIEW_INIT _wgpu_COMMA \
4714+
/*.format=*/WGPUTextureFormat_Undefined _wgpu_COMMA \
4715+
/*.dimension=*/WGPUTextureViewDimension_Undefined _wgpu_COMMA \
4716+
/*.baseMipLevel=*/0 _wgpu_COMMA \
4717+
/*.mipLevelCount=*/WGPU_MIP_LEVEL_COUNT_UNDEFINED _wgpu_COMMA \
4718+
/*.baseArrayLayer=*/0 _wgpu_COMMA \
4719+
/*.arrayLayerCount=*/WGPU_ARRAY_LAYER_COUNT_UNDEFINED _wgpu_COMMA \
4720+
/*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \
4721+
/*.usage=*/WGPUTextureUsage_None _wgpu_COMMA \
4722+
})
4723+
47244724
/**
47254725
* Default values can be set using @ref WGPU_VERTEX_STATE_INIT as initializer.
47264726
*/

webgpu.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webgpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,7 @@ structs:
33203320
TODO
33213321
type: extension
33223322
extends:
3323-
- struct.texture_view_descriptor
3323+
- texture_view_descriptor
33243324
members:
33253325
- name: swizzle
33263326
doc: |

0 commit comments

Comments
 (0)