Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ struct WGPUSurfaceSourceXlibWindow;
struct WGPUSurfaceTexture;
struct WGPUTexelCopyBufferLayout;
struct WGPUTextureBindingLayout;
struct WGPUTextureComponentSwizzle;
struct WGPUTextureViewDescriptor;
struct WGPUVertexAttribute;
struct WGPUBindGroupDescriptor;
Expand All @@ -314,6 +315,7 @@ struct WGPUShaderModuleDescriptor;
struct WGPUSurfaceDescriptor;
struct WGPUTexelCopyBufferInfo;
struct WGPUTexelCopyTextureInfo;
struct WGPUTextureComponentSwizzleDescriptor;
struct WGPUTextureDescriptor;
struct WGPUVertexBufferLayout;
struct WGPUBindGroupLayoutDescriptor;
Expand Down Expand Up @@ -501,6 +503,38 @@ typedef enum WGPUCompilationMessageType {
WGPUCompilationMessageType_Force32 = 0x7FFFFFFF
} WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE;

typedef enum WGPUComponentSwizzle {
/**
* `0`. Indicates no value is passed for this argument. See @ref SentinelValues.
*/
WGPUComponentSwizzle_Undefined = 0x00000000,
/**
* Force its value to 0.
*/
WGPUComponentSwizzle_Zero = 0x00000001,
/**
* Force its value to 1.
*/
WGPUComponentSwizzle_One = 0x00000002,
/**
* Take its value from the red channel of the texture.
*/
WGPUComponentSwizzle_R = 0x00000003,
/**
* Take its value from the green channel of the texture.
*/
WGPUComponentSwizzle_G = 0x00000004,
/**
* Take its value from the blue channel of the texture.
*/
WGPUComponentSwizzle_B = 0x00000005,
/**
* Take its value from the alpha channel of the texture.
*/
WGPUComponentSwizzle_A = 0x00000006,
WGPUComponentSwizzle_Force32 = 0x7FFFFFFF
} WGPUComponentSwizzle WGPU_ENUM_ATTRIBUTE;

/**
* Describes how frames are composited with other contents on the screen when @ref wgpuSurfacePresent is called.
*/
Expand Down Expand Up @@ -618,6 +652,7 @@ typedef enum WGPUFeatureName {
WGPUFeatureName_TextureFormatsTier1 = 0x00000013,
WGPUFeatureName_TextureFormatsTier2 = 0x00000014,
WGPUFeatureName_PrimitiveIndex = 0x00000015,
WGPUFeatureName_TextureComponentSwizzle = 0x00000016,
WGPUFeatureName_Force32 = 0x7FFFFFFF
} WGPUFeatureName WGPU_ENUM_ATTRIBUTE;

Expand Down Expand Up @@ -3539,6 +3574,51 @@ typedef struct WGPUTextureBindingLayout {
/*.multisampled=*/WGPU_FALSE _wgpu_COMMA \
})

/**
* When accessed by a shader, the red/green/blue/alpha channels are replaced
* by the value corresponding to the component specified in r, g, b, and a,
* respectively unlike the JS API which uses a string of length four, with
* each character mapping to the texture view's red/green/blue/alpha channels.
*
* Default values can be set using @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT as initializer.
*/
typedef struct WGPUTextureComponentSwizzle {
/**
* The value that replaces the red channel in the shader.
*
* The `INIT` macro sets this to @ref WGPUComponentSwizzle_R.
*/
WGPUComponentSwizzle r;
/**
* The value that replaces the green channel in the shader.
*
* The `INIT` macro sets this to @ref WGPUComponentSwizzle_G.
*/
WGPUComponentSwizzle g;
/**
* The value that replaces the blue channel in the shader.
*
* The `INIT` macro sets this to @ref WGPUComponentSwizzle_B.
*/
WGPUComponentSwizzle b;
/**
* The value that replaces the alpha channel in the shader.
*
* The `INIT` macro sets this to @ref WGPUComponentSwizzle_A.
*/
WGPUComponentSwizzle a;
} WGPUTextureComponentSwizzle WGPU_STRUCTURE_ATTRIBUTE;

/**
* Initializer for @ref WGPUTextureComponentSwizzle.
*/
#define WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureComponentSwizzle, { \
/*.r=*/WGPUComponentSwizzle_R _wgpu_COMMA \
/*.g=*/WGPUComponentSwizzle_G _wgpu_COMMA \
/*.b=*/WGPUComponentSwizzle_B _wgpu_COMMA \
/*.a=*/WGPUComponentSwizzle_A _wgpu_COMMA \
})

/**
* Default values can be set using @ref WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT as initializer.
*/
Expand Down Expand Up @@ -4222,6 +4302,28 @@ typedef struct WGPUTexelCopyTextureInfo {
/*.aspect=*/WGPUTextureAspect_Undefined _wgpu_COMMA \
})

/**
* Default values can be set using @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_DESCRIPTOR_INIT as initializer.
*/
typedef struct WGPUTextureComponentSwizzleDescriptor {
WGPUChainedStruct chain;
/**
* The `INIT` macro sets this to @ref WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT.
*/
WGPUTextureComponentSwizzle swizzle;
} WGPUTextureComponentSwizzleDescriptor WGPU_STRUCTURE_ATTRIBUTE;

/**
* Initializer for @ref WGPUTextureComponentSwizzleDescriptor.
*/
#define WGPU_TEXTURE_COMPONENT_SWIZZLE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUTextureComponentSwizzleDescriptor, { \
/*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \
/*.next=*/NULL _wgpu_COMMA \
/*.sType=*/WGPUSType_TextureComponentSwizzleDescriptor _wgpu_COMMA \
}) _wgpu_COMMA \
/*.swizzle=*/WGPU_TEXTURE_COMPONENT_SWIZZLE_INIT _wgpu_COMMA \
})

/**
* Default values can be set using @ref WGPU_TEXTURE_DESCRIPTOR_INIT as initializer.
*/
Expand Down
84 changes: 84 additions & 0 deletions webgpu.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,30 @@ enums:
- name: info
doc: |
TODO
- name: component_swizzle
doc: |
TODO
entries:
- name: undefined
doc: Indicates no value is passed for this argument. See @ref SentinelValues.
- name: zero
doc: |
Force its value to 0.
- name: one
doc: |
Force its value to 1.
- name: r
doc: |
Take its value from the red channel of the texture.
- name: g
doc: |
Take its value from the green channel of the texture.
- name: b
doc: |
Take its value from the blue channel of the texture.
- name: a
doc: |
Take its value from the alpha channel of the texture.
- name: composite_alpha_mode
doc: Describes how frames are composited with other contents on the screen when @ref wgpuSurfacePresent is called.
entries:
Expand Down Expand Up @@ -505,6 +529,9 @@ enums:
- name: primitive_index
doc: |
TODO
- name: texture_component_swizzle
doc: |
TODO
- name: filter_mode
doc: |
TODO
Expand Down Expand Up @@ -3162,6 +3189,45 @@ structs:
TODO
type: bool
default: false
- name: texture_component_swizzle
doc: |
When accessed by a shader, the red/green/blue/alpha channels are replaced
by the value corresponding to the component specified in r, g, b, and a,
respectively unlike the JS API which uses a string of length four, with
each character mapping to the texture view's red/green/blue/alpha channels.
type: standalone
members:
- name: r
doc: |
The value that replaces the red channel in the shader.
type: enum.component_swizzle
default: r
- name: g
doc: |
The value that replaces the green channel in the shader.
type: enum.component_swizzle
default: g
- name: b
doc: |
The value that replaces the blue channel in the shader.
type: enum.component_swizzle
default: b
- name: a
doc: |
The value that replaces the alpha channel in the shader.
type: enum.component_swizzle
default: a
- name: texture_component_swizzle_descriptor
doc: |
TODO
type: extension
extends:
- struct.texture_view_descriptor
members:
- name: swizzle
doc: |
TODO
type: struct.texture_component_swizzle
- name: texture_descriptor
doc: |
TODO
Expand Down