Skip to content

Commit

Permalink
Flatten limits structures, fix WGPUInstanceFeatures chain constness (w…
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x authored Oct 18, 2024
1 parent 1430e17 commit 6f549cc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 62 deletions.
16 changes: 9 additions & 7 deletions gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ Since the generator does some duplication validation, the order of the files mat
| `float64` |
| `c_void` |

| Structure types | |
| --------------- | ------------------------------------------------------- |
| `base_in` | in-structs that can be extended |
| `base_out` | out-structs that can be extended |
| `extension_in` | in-structs that are extensions |
| `extension_out` | out-structs that are extensions |
| `standalone` | structs that are niether extensions nor can be extended |
| Structure types | |
| --------------------- | ------------------------------------------------------- |
| `base_in` | in-structs that can be extended |
| `base_out` | out-structs that can be extended |
| `base_in_or_out` | extensible structs used as either input or output |
| `extension_in` | extension structs used in `base_in` chains |
| `extension_out` | extension structs used in `base_out` chains |
| `extension_in_or_out` | extension structs used `base_in_or_out` chains |
| `standalone` | structs that are niether extensions nor can be extended |

#### Arrays

Expand Down
6 changes: 6 additions & 0 deletions gen/cheader.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,16 @@ typedef struct WGPU{{.Name | PascalCase}}{{$.ExtSuffix}} {
WGPUChainedStruct const * nextInChain;
{{- else if eq .Type "base_out" }}
WGPUChainedStructOut * nextInChain;
{{- else if eq .Type "base_in_or_out" }}
/** This struct chain is used as mutable in some places and immutable in others. */
WGPUChainedStructOut * nextInChain;
{{- else if eq .Type "extension_in"}}
WGPUChainedStruct chain;
{{- else if eq .Type "extension_out"}}
WGPUChainedStructOut chain;
{{- else if eq .Type "extension_in_or_out"}}
/** This struct chain is used as mutable in some places and immutable in others. */
WGPUChainedStructOut chain;
{{- end}}
{{- range $memberIndex, $_ := .Members}}
{{- MCommentMember . 4 }}
Expand Down
2 changes: 2 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,10 @@
"enum": [
"base_in",
"base_out",
"base_in_or_out",
"extension_in",
"extension_out",
"extension_in_or_out",
"standalone"
]
},
Expand Down
55 changes: 23 additions & 32 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,18 @@ struct WGPUBlendState;
struct WGPUCompilationInfo;
struct WGPUComputePassDescriptor;
struct WGPUDepthStencilState;
struct WGPUDeviceDescriptor;
struct WGPUFutureWaitInfo;
struct WGPUImageCopyBuffer;
struct WGPUImageCopyTexture;
struct WGPUInstanceDescriptor;
struct WGPUProgrammableStageDescriptor;
struct WGPURenderPassColorAttachment;
struct WGPURequiredLimits;
struct WGPUSupportedLimits;
struct WGPUTextureDescriptor;
struct WGPUVertexBufferLayout;
struct WGPUBindGroupLayoutDescriptor;
struct WGPUColorTargetState;
struct WGPUComputePipelineDescriptor;
struct WGPUDeviceDescriptor;
struct WGPURenderPassDescriptor;
struct WGPUVertexState;
struct WGPUFragmentState;
Expand Down Expand Up @@ -1450,7 +1448,8 @@ typedef struct WGPUFuture {
* Features enabled on the WGPUInstance
*/
typedef struct WGPUInstanceFeatures {
WGPUChainedStruct const * nextInChain;
/** This struct chain is used as mutable in some places and immutable in others. */
WGPUChainedStructOut * nextInChain;
/**
* Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`.
*/
Expand All @@ -1462,6 +1461,8 @@ typedef struct WGPUInstanceFeatures {
} WGPUInstanceFeatures WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPULimits {
/** This struct chain is used as mutable in some places and immutable in others. */
WGPUChainedStructOut * nextInChain;
uint32_t maxTextureDimension1D;
uint32_t maxTextureDimension2D;
uint32_t maxTextureDimension3D;
Expand Down Expand Up @@ -1937,6 +1938,20 @@ typedef struct WGPUDepthStencilState {
float depthBiasClamp;
} WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPUDeviceDescriptor {
WGPUChainedStruct const * nextInChain;
/**
* This is a \ref NonNullInputString.
*/
WGPUStringView label;
size_t requiredFeatureCount;
WGPUFeatureName const * requiredFeatures;
WGPU_NULLABLE WGPULimits const * requiredLimits;
WGPUQueueDescriptor defaultQueue;
WGPUDeviceLostCallbackInfo deviceLostCallbackInfo;
WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo;
} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE;

/**
* Struct holding a future to wait on, and a `completed` boolean flag.
*/
Expand Down Expand Up @@ -1992,16 +2007,6 @@ typedef struct WGPURenderPassColorAttachment {
WGPUColor clearValue;
} WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPURequiredLimits {
WGPUChainedStruct const * nextInChain;
WGPULimits limits;
} WGPURequiredLimits WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPUSupportedLimits {
WGPUChainedStructOut * nextInChain;
WGPULimits limits;
} WGPUSupportedLimits WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPUTextureDescriptor {
WGPUChainedStruct const * nextInChain;
/**
Expand Down Expand Up @@ -2062,20 +2067,6 @@ typedef struct WGPUComputePipelineDescriptor {
WGPUProgrammableStageDescriptor compute;
} WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPUDeviceDescriptor {
WGPUChainedStruct const * nextInChain;
/**
* This is a \ref NonNullInputString.
*/
WGPUStringView label;
size_t requiredFeatureCount;
WGPUFeatureName const * requiredFeatures;
WGPU_NULLABLE WGPURequiredLimits const * requiredLimits;
WGPUQueueDescriptor defaultQueue;
WGPUDeviceLostCallbackInfo deviceLostCallbackInfo;
WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo;
} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPURenderPassDescriptor {
WGPUChainedStruct const * nextInChain;
/**
Expand Down Expand Up @@ -2168,7 +2159,7 @@ typedef void (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * in
* Proc pointer type for @ref wgpuAdapterGetLimits:
* > @copydoc wgpuAdapterGetLimits
*/
typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE;
typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE;
/**
* Proc pointer type for @ref wgpuAdapterHasFeature:
* > @copydoc wgpuAdapterHasFeature
Expand Down Expand Up @@ -2551,7 +2542,7 @@ typedef WGPUStatus (*WGPUProcDeviceGetFeatures)(WGPUDevice device, WGPUSupported
* Proc pointer type for @ref wgpuDeviceGetLimits:
* > @copydoc wgpuDeviceGetLimits
*/
typedef WGPUBool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE;
typedef WGPUBool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE;
/**
* Proc pointer type for @ref wgpuDeviceGetQueue:
* > @copydoc wgpuDeviceGetQueue
Expand Down Expand Up @@ -3177,7 +3168,7 @@ WGPU_EXPORT WGPUStatus wgpuAdapterGetFeatures(WGPUAdapter adapter, WGPUSupported
* This parameter is @ref ReturnedWithOwnership.
*/
WGPU_EXPORT void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUFuture wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT void wgpuAdapterAddRef(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE;
Expand Down Expand Up @@ -3354,7 +3345,7 @@ WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE;
* - `features` has an invalid struct chain.
*/
WGPU_EXPORT WGPUStatus wgpuDeviceGetFeatures(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE;
Expand Down
28 changes: 5 additions & 23 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ structs:
- name: required_limits
doc: |
TODO
type: struct.required_limits
type: struct.limits
pointer: immutable
optional: true
- name: default_queue
Expand Down Expand Up @@ -2025,7 +2025,7 @@ structs:
- name: instance_features
doc: |
Features enabled on the WGPUInstance
type: base_in
type: base_in_or_out
members:
- name: timed_wait_any_enable
doc: Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`.
Expand All @@ -2036,7 +2036,7 @@ structs:
- name: limits
doc: |
TODO
type: standalone
type: base_in_or_out
members:
- name: max_texture_dimension_1D
doc: |
Expand Down Expand Up @@ -2509,15 +2509,6 @@ structs:
doc: |
TODO
type: bool
- name: required_limits
doc: |
TODO
type: base_in
members:
- name: limits
doc: |
TODO
type: struct.limits
- name: sampler_binding_layout
doc: |
TODO
Expand Down Expand Up @@ -2661,15 +2652,6 @@ structs:
TODO
type: array<enum.feature_name>
pointer: immutable
- name: supported_limits
doc: |
TODO
type: base_out
members:
- name: limits
doc: |
TODO
type: struct.limits
- name: surface_capabilities
doc: Filled by `::wgpuSurfaceGetCapabilities` with what's supported for `::wgpuSurfaceConfigure` for a pair of @ref WGPUSurface and @ref WGPUAdapter.
type: base_out
Expand Down Expand Up @@ -3208,7 +3190,7 @@ objects:
- name: limits
doc: |
TODO
type: struct.supported_limits
type: struct.limits
pointer: mutable
- name: has_feature
doc: |
Expand Down Expand Up @@ -3914,7 +3896,7 @@ objects:
- name: limits
doc: |
TODO
type: struct.supported_limits
type: struct.limits
pointer: mutable
- name: has_feature
doc: |
Expand Down

0 comments on commit 6f549cc

Please sign in to comment.