Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add surface color management extension #421

Merged
merged 2 commits into from
Dec 9, 2024
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
43 changes: 43 additions & 0 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ struct WGPUStorageTextureBindingLayout;
struct WGPUSupportedFeatures;
struct WGPUSupportedWGSLLanguageFeatures;
struct WGPUSurfaceCapabilities;
struct WGPUSurfaceColorManagement;
struct WGPUSurfaceConfiguration;
struct WGPUSurfaceDescriptor;
struct WGPUSurfaceSourceAndroidNativeWindow;
Expand Down Expand Up @@ -663,6 +664,12 @@ typedef enum WGPUPowerPreference {
WGPUPowerPreference_Force32 = 0x7FFFFFFF
} WGPUPowerPreference WGPU_ENUM_ATTRIBUTE;

typedef enum WGPUPredefinedColorSpace {
WGPUPredefinedColorSpace_SRGB = 0x00000001,
WGPUPredefinedColorSpace_DisplayP3 = 0x00000002,
WGPUPredefinedColorSpace_Force32 = 0x7FFFFFFF
} WGPUPredefinedColorSpace WGPU_ENUM_ATTRIBUTE;

/**
* Describes when and in which order frames are presented on the screen when @ref wgpuSurfacePresent is called.
*/
Expand Down Expand Up @@ -752,6 +759,7 @@ typedef enum WGPUSType {
WGPUSType_SurfaceSourceWaylandSurface = 0x00000007,
WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008,
WGPUSType_SurfaceSourceXCBWindow = 0x00000009,
WGPUSType_SurfaceColorManagement = 0x0000000A,
WGPUSType_Force32 = 0x7FFFFFFF
} WGPUSType WGPU_ENUM_ATTRIBUTE;

Expand Down Expand Up @@ -1038,6 +1046,12 @@ typedef enum WGPUTextureViewDimension {
WGPUTextureViewDimension_Force32 = 0x7FFFFFFF
} WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE;

typedef enum WGPUToneMappingMode {
WGPUToneMappingMode_Standard = 0x00000001,
WGPUToneMappingMode_Extended = 0x00000002,
WGPUToneMappingMode_Force32 = 0x7FFFFFFF
} WGPUToneMappingMode WGPU_ENUM_ATTRIBUTE;

typedef enum WGPUVertexFormat {
WGPUVertexFormat_Uint8 = 0x00000001,
WGPUVertexFormat_Uint8x2 = 0x00000002,
Expand Down Expand Up @@ -2932,6 +2946,35 @@ typedef struct WGPUSurfaceCapabilities {
/*.alphaModes=*/NULL _wgpu_COMMA \
})

/**
* Extension of @ref WGPUSurfaceConfiguration for color spaces and HDR.
*
* Default values can be set using @ref WGPU_SURFACE_COLOR_MANAGEMENT_INIT as initializer.
*/
typedef struct WGPUSurfaceColorManagement {
WGPUChainedStruct chain;
/**
* The `INIT` macro sets this to (@ref WGPUPredefinedColorSpace)0.
*/
WGPUPredefinedColorSpace colorSpace;
/**
* The `INIT` macro sets this to (@ref WGPUToneMappingMode)0.
*/
WGPUToneMappingMode toneMappingMode;
} WGPUSurfaceColorManagement WGPU_STRUCTURE_ATTRIBUTE;

/**
* Initializer for @ref WGPUSurfaceColorManagement.
*/
#define WGPU_SURFACE_COLOR_MANAGEMENT_INIT _wgpu_MAKE_INIT_STRUCT(WGPUSurfaceColorManagement, { \
/*.chain=*/_wgpu_MAKE_INIT_STRUCT(WGPUChainedStruct, { \
/*.next=*/NULL _wgpu_COMMA \
/*.sType=*/WGPUSType_SurfaceColorManagement _wgpu_COMMA \
}) _wgpu_COMMA \
/*.colorSpace=*/_wgpu_ENUM_ZERO_INIT(WGPUPredefinedColorSpace) _wgpu_COMMA \
/*.toneMappingMode=*/_wgpu_ENUM_ZERO_INIT(WGPUToneMappingMode) _wgpu_COMMA \
})

/**
* Options to @ref wgpuSurfaceConfigure for defining how a @ref WGPUSurface will be rendered to and presented to the user.
* See @ref Surface-Configuration for more details.
Expand Down
36 changes: 36 additions & 0 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,17 @@ enums:
- name: high_performance
doc: |
TODO
- name: predefined_color_space
doc: |
TODO
entries:
- null
- name: SRGB
doc: |
TODO
- name: display_p3
doc: |
TODO
- name: present_mode
doc: Describes when and in which order frames are presented on the screen when @ref wgpuSurfacePresent is called.
entries:
Expand Down Expand Up @@ -710,6 +721,9 @@ enums:
- name: surface_source_XCB_window
doc: |
TODO
- name: surface_color_management
doc: |
TODO
- name: sampler_binding_type
doc: |
TODO
Expand Down Expand Up @@ -1192,6 +1206,17 @@ enums:
- name: 3D
doc: |
TODO
- name: tone_mapping_mode
doc: |
TODO
entries:
- null
- name: standard
doc: |
TODO
- name: extended
doc: |
TODO
- name: vertex_format
doc: |
TODO
Expand Down Expand Up @@ -2789,6 +2814,17 @@ structs:
@ref WGPUCompositeAlphaMode_Auto will be an alias for the first element and will never be present in this array.
type: array<enum.composite_alpha_mode>
pointer: immutable
- name: surface_color_management
doc: |
Extension of @ref WGPUSurfaceConfiguration for color spaces and HDR.
type: extension
members:
- name: color_space
doc: TODO
type: enum.predefined_color_space
- name: tone_mapping_mode
doc: TODO
type: enum.tone_mapping_mode
- name: surface_configuration
doc: |
Options to @ref wgpuSurfaceConfigure for defining how a @ref WGPUSurface will be rendered to and presented to the user.
Expand Down
Loading