Skip to content

Commit

Permalink
Add WGPUFeatureLevel (webgpu-native#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x authored Nov 12, 2024
1 parent 9cbeebb commit f848447
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
39 changes: 37 additions & 2 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,23 @@ typedef enum WGPUErrorType {
WGPUErrorType_Force32 = 0x7FFFFFFF
} WGPUErrorType WGPU_ENUM_ATTRIBUTE;

/**
* See @ref WGPURequestAdapterOptions::featureLevel.
*/
typedef enum WGPUFeatureLevel {
/**
* `0x00000001`.
* "Compatibility" profile which can be supported on OpenGL ES 3.1.
*/
WGPUFeatureLevel_Compatibility = 0x00000001,
/**
* `0x00000002`.
* "Core" profile which can be supported on Vulkan/Metal/D3D12.
*/
WGPUFeatureLevel_Core = 0x00000002,
WGPUFeatureLevel_Force32 = 0x7FFFFFFF
} WGPUFeatureLevel WGPU_ENUM_ATTRIBUTE;

typedef enum WGPUFeatureName {
WGPUFeatureName_Undefined = 0x00000000,
WGPUFeatureName_DepthClipControl = 0x00000001,
Expand Down Expand Up @@ -1637,10 +1654,28 @@ typedef struct WGPURenderPassTimestampWrites {

typedef struct WGPURequestAdapterOptions {
WGPUChainedStruct const * nextInChain;
WGPU_NULLABLE WGPUSurface compatibleSurface;
/**
* "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level.
*
* Implementations may ignore @ref WGPUFeatureLevel_Compatibility and provide @ref WGPUFeatureLevel_Core instead. @ref WGPUFeatureLevel_Core is the default in the JS API, but in C, this field is **required** (must not be undefined).
*/
WGPUFeatureLevel featureLevel;
WGPUPowerPreference powerPreference;
WGPUBackendType backendType;
/**
* If true, requires the adapter to be a "fallback" adapter as defined by the JS spec.
* If this is not possible, the request returns null.
*/
WGPUBool forceFallbackAdapter;
/**
* If set, requires the adapter to have a particular backend type.
* If this is not possible, the request returns null.
*/
WGPUBackendType backendType;
/**
* If set, requires the adapter to be able to output to a particular surface.
* If this is not possible, the request returns null.
*/
WGPU_NULLABLE WGPUSurface compatibleSurface;
} WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE;

typedef struct WGPUSamplerBindingLayout {
Expand Down
36 changes: 28 additions & 8 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ enums:
- name: unknown
doc: |
TODO
- name: feature_level
doc: |
See @ref WGPURequestAdapterOptions::featureLevel.
entries:
- null
- name: compatibility
doc: |
"Compatibility" profile which can be supported on OpenGL ES 3.1.
- name: core
doc: |
"Core" profile which can be supported on Vulkan/Metal/D3D12.
- name: feature_name
doc: |
TODO
Expand Down Expand Up @@ -2466,23 +2477,32 @@ structs:
TODO
type: base_in
members:
- name: compatible_surface
- name: feature_level
doc: |
TODO
type: object.surface
optional: true
"Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level.
Implementations may ignore @ref WGPUFeatureLevel_Compatibility and provide @ref WGPUFeatureLevel_Core instead. @ref WGPUFeatureLevel_Core is the default in the JS API, but in C, this field is **required** (must not be undefined).
type: enum.feature_level
- name: power_preference
doc: |
TODO
type: enum.power_preference
- name: force_fallback_adapter
doc: |
If true, requires the adapter to be a "fallback" adapter as defined by the JS spec.
If this is not possible, the request returns null.
type: bool
- name: backend_type
doc: |
TODO
If set, requires the adapter to have a particular backend type.
If this is not possible, the request returns null.
type: enum.backend_type
- name: force_fallback_adapter
- name: compatible_surface
doc: |
TODO
type: bool
If set, requires the adapter to be able to output to a particular surface.
If this is not possible, the request returns null.
type: object.surface
optional: true
- name: sampler_binding_layout
doc: |
TODO
Expand Down

0 comments on commit f848447

Please sign in to comment.