Skip to content

Commit

Permalink
Replace EnumerateFeatures with GetFeatures (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x authored Sep 23, 2024
1 parent 39fbb64 commit 63983c5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 18 deletions.
58 changes: 50 additions & 8 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ struct WGPUShaderSourceSPIRV;
struct WGPUShaderSourceWGSL;
struct WGPUStencilFaceState;
struct WGPUStorageTextureBindingLayout;
struct WGPUSupportedFeatures;
struct WGPUSurfaceCapabilities;
struct WGPUSurfaceConfiguration;
struct WGPUSurfaceDescriptor;
Expand Down Expand Up @@ -1363,6 +1364,12 @@ typedef struct WGPUStorageTextureBindingLayout {
WGPUTextureViewDimension viewDimension;
} WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPUSupportedFeatures {
WGPUChainedStructOut * nextInChain;
size_t featureCount;
WGPUFeatureName const * features;
} WGPUSupportedFeatures WGPU_STRUCTURE_ATTRIBUTE;

/**
* Filled by `::wgpuSurfaceGetCapabilities` with what's supported for `::wgpuSurfaceConfigure` for a pair of @ref WGPUSurface and @ref WGPUAdapter.
*/
Expand Down Expand Up @@ -1809,10 +1816,10 @@ typedef WGPUProc (*WGPUProcGetProcAddress)(char const * procName) WGPU_FUNCTION_

// Procs of Adapter
/**
* Proc pointer type for @ref wgpuAdapterEnumerateFeatures:
* > @copydoc wgpuAdapterEnumerateFeatures
* Proc pointer type for @ref wgpuAdapterGetFeatures:
* > @copydoc wgpuAdapterGetFeatures
*/
typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE;
typedef WGPUStatus (*WGPUProcAdapterGetFeatures)(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE;
/**
* Proc pointer type for @ref wgpuAdapterGetInfo:
* > @copydoc wgpuAdapterGetInfo
Expand Down Expand Up @@ -2197,10 +2204,10 @@ typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextur
*/
typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE;
/**
* Proc pointer type for @ref wgpuDeviceEnumerateFeatures:
* > @copydoc wgpuDeviceEnumerateFeatures
* Proc pointer type for @ref wgpuDeviceGetFeatures:
* > @copydoc wgpuDeviceGetFeatures
*/
typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE;
typedef WGPUStatus (*WGPUProcDeviceGetFeatures)(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE;
/**
* Proc pointer type for @ref wgpuDeviceGetLimits:
* > @copydoc wgpuDeviceGetLimits
Expand Down Expand Up @@ -2632,6 +2639,13 @@ typedef void (*WGPUProcShaderModuleAddRef)(WGPUShaderModule shaderModule) WGPU_F
*/
typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE;

// Procs of SupportedFeatures
/**
* Proc pointer type for @ref wgpuSupportedFeaturesFreeMembers:
* > @copydoc wgpuSupportedFeaturesFreeMembers
*/
typedef void (*WGPUProcSupportedFeaturesFreeMembers)(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE;

// Procs of Surface
/**
* Proc pointer type for @ref wgpuSurfaceConfigure:
Expand Down Expand Up @@ -2804,7 +2818,14 @@ WGPU_EXPORT WGPUProc wgpuGetProcAddress(char const * procName) WGPU_FUNCTION_ATT
*
* @{
*/
WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE;
/**
* Get the list of @ref WGPUFeatureName values supported by the adapter.
*
* @returns Return @ref WGPUStatus_Error (and leaves `features` uninitialized) if:
*
* - `features` has an invalid struct chain.
*/
WGPU_EXPORT WGPUStatus wgpuAdapterGetFeatures(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE;
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 wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE;
Expand Down Expand Up @@ -2971,7 +2992,14 @@ WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE
WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE;
/**
* Get the list of @ref WGPUFeatureName values supported by the device.
*
* @returns Return @ref WGPUStatus_Error (and leaves `features` uninitialized) if:
*
* - `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 WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE;
Expand Down Expand Up @@ -3173,6 +3201,20 @@ WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUN



/**
* \defgroup WGPUSupportedFeaturesMethods WGPUSupportedFeatures methods
* \brief Functions whose first argument has type WGPUSupportedFeatures.
*
* @{
*/
/**
* Frees array members of WGPUSupportedFeatures which were allocated by the API.
*/
WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE;
/** @} */



/**
* \defgroup WGPUSurfaceMethods WGPUSurface methods
* \brief Functions whose first argument has type WGPUSurface.
Expand Down
35 changes: 25 additions & 10 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,17 @@ structs:
doc: |
TODO
type: enum.texture_view_dimension
- name: supported_features
doc: |
TODO
type: base_out
free_members: true
members:
- name: features
doc: |
TODO
type: array<enum.feature_name>
pointer: immutable
- name: supported_limits
doc: |
TODO
Expand Down Expand Up @@ -3189,18 +3200,20 @@ objects:
doc: |
TODO
type: enum.feature_name
- name: enumerate_features
- name: get_features
doc: |
TODO
Get the list of @ref WGPUFeatureName values supported by the adapter.
returns:
doc: |
TODO
type: usize
Return @ref WGPUStatus_Error (and leaves `features` uninitialized) if:
- `features` has an invalid struct chain.
type: enum.status
args:
- name: features
doc: |
TODO
type: enum.feature_name
type: struct.supported_features
pointer: mutable
- name: get_info
doc: |
Expand Down Expand Up @@ -3875,18 +3888,20 @@ objects:
doc: |
TODO
type: enum.feature_name
- name: enumerate_features
- name: get_features
doc: |
TODO
Get the list of @ref WGPUFeatureName values supported by the device.
returns:
doc: |
TODO
type: usize
Return @ref WGPUStatus_Error (and leaves `features` uninitialized) if:
- `features` has an invalid struct chain.
type: enum.status
args:
- name: features
doc: |
TODO
type: enum.feature_name
type: struct.supported_features
pointer: mutable
- name: get_queue
doc: |
Expand Down

0 comments on commit 63983c5

Please sign in to comment.