Skip to content

Commit a93ea07

Browse files
authored
Merge pull request #432 from mahkoh/jorth/cm-2
wp-color-management-v1: update to version 2
2 parents 7562479 + b5c0e3a commit a93ea07

21 files changed

+200
-29
lines changed

docs/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Jay supports the following wayland protocols:
174174
| wl_shm | 2 | |
175175
| wl_subcompositor | 1 | |
176176
| wp_alpha_modifier_v1 | 1 | |
177-
| wp_color_manager_v1 | 1 | |
177+
| wp_color_manager_v1 | 2 | |
178178
| wp_commit_timing_manager_v1 | 1 | |
179179
| wp_content_type_manager_v1 | 1 | |
180180
| wp_cursor_shape_manager_v1 | 2 | |

src/client/objects.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use {
22
crate::{
33
client::{Client, ClientError},
44
ifs::{
5-
color_management::wp_image_description_v1::WpImageDescriptionV1,
5+
color_management::{
6+
wp_image_description_reference_v1::WpImageDescriptionReferenceV1,
7+
wp_image_description_v1::WpImageDescriptionV1,
8+
},
69
ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
710
ext_image_capture_source_v1::ExtImageCaptureSourceV1,
811
ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1,
@@ -48,10 +51,11 @@ use {
4851
ExtImageCopyCaptureSessionV1Id, ExtWorkspaceGroupHandleV1Id, JayHeadErrorV1Id,
4952
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
5053
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
51-
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpImageDescriptionV1Id,
52-
WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId, XdgPositionerId, XdgSurfaceId,
53-
XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwlrOutputHeadV1Id,
54-
ZwlrOutputModeV1Id, ZwpPrimarySelectionSourceV1Id, ZwpTabletToolV2Id,
54+
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpImageDescriptionReferenceV1Id,
55+
WpImageDescriptionV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId, XdgPositionerId,
56+
XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
57+
ZwlrOutputHeadV1Id, ZwlrOutputModeV1Id, ZwpPrimarySelectionSourceV1Id,
58+
ZwpTabletToolV2Id,
5559
},
5660
},
5761
std::{cell::RefCell, rc::Rc},
@@ -94,6 +98,8 @@ pub struct Objects {
9498
pub ext_workspace_groups:
9599
CopyHashMap<ExtWorkspaceGroupHandleV1Id, Rc<ExtWorkspaceGroupHandleV1>>,
96100
pub wp_image_description: CopyHashMap<WpImageDescriptionV1Id, Rc<WpImageDescriptionV1>>,
101+
pub wp_image_description_reference:
102+
CopyHashMap<WpImageDescriptionReferenceV1Id, Rc<WpImageDescriptionReferenceV1>>,
97103
pub jay_head_errors: CopyHashMap<JayHeadErrorV1Id, Rc<JayHeadErrorV1>>,
98104
ids: RefCell<Vec<usize>>,
99105
}
@@ -136,6 +142,7 @@ impl Objects {
136142
ext_data_sources: Default::default(),
137143
ext_workspace_groups: Default::default(),
138144
wp_image_description: Default::default(),
145+
wp_image_description_reference: Default::default(),
139146
jay_head_errors: Default::default(),
140147
ids: RefCell::new(vec![]),
141148
}
@@ -182,6 +189,8 @@ impl Objects {
182189
self.ext_data_sources.clear();
183190
self.ext_workspace_groups.clear();
184191
self.jay_head_errors.clear();
192+
self.wp_image_description.clear();
193+
self.wp_image_description_reference.clear();
185194
}
186195

187196
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>

src/cmm/cmm_eotf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub enum Eotf {
1313
Log316,
1414
St428,
1515
Pow(EotfPow),
16+
CompoundPower24,
1617
}
1718

1819
const MUL: u32 = 10_000;

src/gfx_apis/vulkan/eotfs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub const EOTF_LOG316: u32 = 9;
1111
pub const EOTF_ST428: u32 = 10;
1212
pub const EOTF_POW: u32 = 11;
1313
pub const EOTF_GAMMA24: u32 = 12;
14+
pub const EOTF_COMPOUND_POWER_2_4: u32 = 13;
1415

1516
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Linearize)]
1617
pub enum VulkanEotf {
@@ -25,6 +26,7 @@ pub enum VulkanEotf {
2526
Log316,
2627
St428,
2728
Pow,
29+
CompoundPower24,
2830
}
2931

3032
pub trait EotfExt: Sized {
@@ -54,6 +56,7 @@ impl EotfExt for Eotf {
5456
Log316,
5557
St428,
5658
Pow,
59+
CompoundPower24,
5760
}
5861
}
5962
}
@@ -72,6 +75,7 @@ impl VulkanEotf {
7275
Self::Log316 => EOTF_LOG316,
7376
Self::St428 => EOTF_ST428,
7477
Self::Pow => EOTF_POW,
78+
Self::CompoundPower24 => EOTF_COMPOUND_POWER_2_4,
7579
}
7680
}
7781
}

src/gfx_apis/vulkan/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl VulkanRenderer {
766766
}
767767
}
768768
};
769-
for (index, op) in opts.into_iter().enumerate() {
769+
for (index, op) in opts.iter().enumerate() {
770770
match op {
771771
GfxApiOpt::Sync => {
772772
sync(memory);

src/gfx_apis/vulkan/shaders/eotfs.glsl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define TF_ST428 10
1616
#define TF_POW 11
1717
#define TF_GAMMA24 12
18+
#define TF_COMPOUND_POWER_2_4 13
1819

1920
vec3 eotf_bt1886(vec3 c) {
2021
c = clamp(c, 0.0, 1.0);
@@ -101,6 +102,22 @@ vec3 inv_eotf_st428(vec3 c) {
101102
return pow(vec3(48.0) * c / vec3(52.37), vec3(1.0 / 2.6));
102103
}
103104

105+
vec3 eotf_compound_power_2_4(vec3 c) {
106+
return mix(
107+
c * vec3(1.0 / 12.92),
108+
pow((c + vec3(0.055)) * vec3(1.0 / 1.055), vec3(2.4)),
109+
greaterThanEqual(c, vec3(0.04045))
110+
);
111+
}
112+
113+
vec3 inv_eotf_compound_power_2_4(vec3 c) {
114+
return mix(
115+
vec3(12.92) * c,
116+
vec3(1.055) * pow(c, vec3(1.0 / 2.4)) - vec3(0.055),
117+
greaterThanEqual(c, vec3(0.0031308))
118+
);
119+
}
120+
104121
vec3 apply_eotf(vec3 c) {
105122
switch (eotf) {
106123
case TF_LINEAR: return c;
@@ -114,6 +131,7 @@ vec3 apply_eotf(vec3 c) {
114131
case TF_LOG316: return eotf_log316(c);
115132
case TF_ST428: return eotf_st428(c);
116133
case TF_POW: return sign(c) * pow(abs(c), vec3(cm_eotf_args.arg1));
134+
case TF_COMPOUND_POWER_2_4: return eotf_compound_power_2_4(c);
117135
default: return c;
118136
}
119137
}
@@ -131,6 +149,7 @@ vec3 apply_inv_eotf(vec3 c) {
131149
case TF_LOG316: return inv_eotf_log316(c);
132150
case TF_ST428: return inv_eotf_st428(c);
133151
case TF_POW: return sign(c) * pow(abs(c), vec3(cm_inv_eotf_args.arg1));
152+
case TF_COMPOUND_POWER_2_4: return inv_eotf_compound_power_2_4(c);
134153
default: return c;
135154
}
136155
}
1.04 KB
Binary file not shown.
1.04 KB
Binary file not shown.

src/gfx_apis/vulkan/shaders_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
f49076a6465a6790c72a6d290c13d5f14c7dae8ae3eed6ca71c57424e3306f66 src/gfx_apis/vulkan/shaders/eotfs.glsl
1+
b6a0df1e231fab533499329636b7a580384784418baee06c147af5fcc384cf5c src/gfx_apis/vulkan/shaders/eotfs.glsl
22
8a38df18851cd13884499820f26939fb7319f45d913d867f254d8118d59fb117 src/gfx_apis/vulkan/shaders/fill.common.glsl
33
21c488d12aa5ad2f109ec44cb856dfe837e02ea9025b5ed64439d742c17cbf30 src/gfx_apis/vulkan/shaders/fill.frag
44
4fb481d8d73afdfb0d8f077eb8665d86f06c8a32a91e44ed369ef5dff554646d src/gfx_apis/vulkan/shaders/fill.vert

src/ifs/color_management.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::object::Version;
12
pub use consts::*;
23

34
pub mod wp_color_management_output_v1;
@@ -6,8 +7,13 @@ pub mod wp_color_manager_v1;
67
pub mod wp_image_description_creator_icc_v1;
78
pub mod wp_image_description_creator_params_v1;
89
pub mod wp_image_description_info_v1;
10+
pub mod wp_image_description_reference_v1;
911
pub mod wp_image_description_v1;
1012

13+
const UNIQUE_CM_IDS_SINCE: Version = Version(2);
14+
const SRGB_DEPRECATED_SINCE: Version = Version(2);
15+
const COMPOUND_POWER_2_4_SINCE: Version = Version(2);
16+
1117
const PRIMARIES_MUL: f64 = 1_000_000.0;
1218
const PRIMARIES_MUL_INV: f64 = 1.0 / PRIMARIES_MUL;
1319

@@ -55,6 +61,7 @@ mod consts {
5561
pub const TRANSFER_FUNCTION_ST2084_PQ: u32 = 11;
5662
pub const TRANSFER_FUNCTION_ST428: u32 = 12;
5763
pub const TRANSFER_FUNCTION_HLG: u32 = 13;
64+
pub const TRANSFER_FUNCTION_COMPOUND_POWER_2_4: u32 = 14;
5865

5966
pub const CAUSE_LOW_VERSION: u32 = 0;
6067
pub const CAUSE_UNSUPPORTED: u32 = 1;

0 commit comments

Comments
 (0)