diff --git a/webgpu.h b/webgpu.h index b95d18a..78005a8 100644 --- a/webgpu.h +++ b/webgpu.h @@ -296,6 +296,7 @@ struct WGPUSurfaceSourceXlibWindow; struct WGPUSurfaceTexture; struct WGPUTexelCopyBufferLayout; struct WGPUTextureBindingLayout; +struct WGPUTextureComponentSwizzle; struct WGPUTextureViewDescriptor; struct WGPUVertexAttribute; struct WGPUBindGroupDescriptor; @@ -314,6 +315,7 @@ struct WGPUShaderModuleDescriptor; struct WGPUSurfaceDescriptor; struct WGPUTexelCopyBufferInfo; struct WGPUTexelCopyTextureInfo; +struct WGPUTextureComponentSwizzleDescriptor; struct WGPUTextureDescriptor; struct WGPUVertexBufferLayout; struct WGPUBindGroupLayoutDescriptor; @@ -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. */ @@ -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; @@ -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. */ @@ -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. */ diff --git a/webgpu.json b/webgpu.json index 33c9ca1..1ee57e5 100644 --- a/webgpu.json +++ b/webgpu.json @@ -779,6 +779,40 @@ ], "name": "compilation_message_type" }, + { + "doc": "TODO\n", + "entries": [ + { + "doc": "Indicates no value is passed for this argument. See @ref SentinelValues.", + "name": "undefined" + }, + { + "doc": "Force its value to 0.\n", + "name": "zero" + }, + { + "doc": "Force its value to 1.\n", + "name": "one" + }, + { + "doc": "Take its value from the red channel of the texture.\n", + "name": "r" + }, + { + "doc": "Take its value from the green channel of the texture.\n", + "name": "g" + }, + { + "doc": "Take its value from the blue channel of the texture.\n", + "name": "b" + }, + { + "doc": "Take its value from the alpha channel of the texture.\n", + "name": "a" + } + ], + "name": "component_swizzle" + }, { "doc": "Describes how frames are composited with other contents on the screen when @ref wgpuSurfacePresent is called.", "entries": [ @@ -1024,6 +1058,10 @@ { "doc": "TODO\n", "name": "primitive_index" + }, + { + "doc": "TODO\n", + "name": "texture_component_swizzle" } ], "name": "feature_name" @@ -6497,6 +6535,52 @@ "name": "texture_binding_layout", "type": "extensible" }, + { + "doc": "When accessed by a shader, the red/green/blue/alpha channels are replaced\nby the value corresponding to the component specified in r, g, b, and a,\nrespectively unlike the JS API which uses a string of length four, with\neach character mapping to the texture view's red/green/blue/alpha channels.\n", + "members": [ + { + "default": "r", + "doc": "The value that replaces the red channel in the shader.\n", + "name": "r", + "type": "enum.component_swizzle" + }, + { + "default": "g", + "doc": "The value that replaces the green channel in the shader.\n", + "name": "g", + "type": "enum.component_swizzle" + }, + { + "default": "b", + "doc": "The value that replaces the blue channel in the shader.\n", + "name": "b", + "type": "enum.component_swizzle" + }, + { + "default": "a", + "doc": "The value that replaces the alpha channel in the shader.\n", + "name": "a", + "type": "enum.component_swizzle" + } + ], + "name": "texture_component_swizzle", + "type": "standalone" + }, + { + "doc": "TODO\n", + "extends": [ + "struct.texture_view_descriptor" + ], + "members": [ + { + "doc": "TODO\n", + "name": "swizzle", + "type": "struct.texture_component_swizzle" + } + ], + "name": "texture_component_swizzle_descriptor", + "type": "extension" + }, { "doc": "TODO\n", "members": [ diff --git a/webgpu.yml b/webgpu.yml index 2468d39..08097b6 100644 --- a/webgpu.yml +++ b/webgpu.yml @@ -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: @@ -505,6 +529,9 @@ enums: - name: primitive_index doc: | TODO + - name: texture_component_swizzle + doc: | + TODO - name: filter_mode doc: | TODO @@ -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