color-management: implement set_tf_power
This commit is contained in:
parent
a2d726e508
commit
c37567f1cd
8 changed files with 121 additions and 28 deletions
|
|
@ -9,6 +9,7 @@ pub const EOTF_ST240: u32 = 6;
|
|||
pub const EOTF_LOG100: u32 = 8;
|
||||
pub const EOTF_LOG316: u32 = 9;
|
||||
pub const EOTF_ST428: u32 = 10;
|
||||
pub const EOTF_POW: u32 = 11;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Linearize)]
|
||||
pub enum VulkanEotf {
|
||||
|
|
@ -21,6 +22,7 @@ pub enum VulkanEotf {
|
|||
Log100,
|
||||
Log316,
|
||||
St428,
|
||||
Pow,
|
||||
}
|
||||
|
||||
pub trait EotfExt: Sized {
|
||||
|
|
@ -48,6 +50,7 @@ impl EotfExt for Eotf {
|
|||
Log100,
|
||||
Log316,
|
||||
St428,
|
||||
Pow,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -64,6 +67,7 @@ impl VulkanEotf {
|
|||
Self::Log100 => EOTF_LOG100,
|
||||
Self::Log316 => EOTF_LOG316,
|
||||
Self::St428 => EOTF_ST428,
|
||||
Self::Pow => EOTF_POW,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use {
|
|||
async_engine::{AsyncEngine, SpawnedFuture},
|
||||
cmm::{
|
||||
cmm_description::{ColorDescription, LinearColorDescription, LinearColorDescriptionId},
|
||||
cmm_eotf::{Eotf, EotfPow},
|
||||
cmm_transform::ColorMatrix,
|
||||
},
|
||||
cpu_worker::PendingJob,
|
||||
|
|
@ -2327,21 +2328,48 @@ impl ColorTransforms {
|
|||
|
||||
#[derive(Default)]
|
||||
struct EotfArgsCache {
|
||||
map: AHashMap<(), EotfArg>,
|
||||
map: AHashMap<(EotfPow, bool), EotfArg>,
|
||||
}
|
||||
|
||||
struct EotfArg {
|
||||
_offset: DeviceSize,
|
||||
offset: DeviceSize,
|
||||
}
|
||||
|
||||
impl EotfArgsCache {
|
||||
fn get_offset(
|
||||
&mut self,
|
||||
_desc: &ColorDescription,
|
||||
_inv: bool,
|
||||
_uniform_buffer_offset_mask: DeviceSize,
|
||||
_writer: &mut GenericBufferWriter,
|
||||
desc: &ColorDescription,
|
||||
inv: bool,
|
||||
uniform_buffer_offset_mask: DeviceSize,
|
||||
writer: &mut GenericBufferWriter,
|
||||
) -> Option<DeviceSize> {
|
||||
None
|
||||
let Eotf::Pow(pow) = desc.eotf else {
|
||||
return None;
|
||||
};
|
||||
let ct = match self.map.entry((pow, inv)) {
|
||||
Entry::Occupied(o) => o.into_mut(),
|
||||
Entry::Vacant(e) => {
|
||||
if inv {
|
||||
let data = InvEotfArgs {
|
||||
arg1: pow.inv_eotf_f32(),
|
||||
arg2: 0.0,
|
||||
arg3: 0.0,
|
||||
arg4: 0.0,
|
||||
};
|
||||
let offset = writer.write(uniform_buffer_offset_mask, &data);
|
||||
e.insert(EotfArg { offset })
|
||||
} else {
|
||||
let data = EotfArgs {
|
||||
arg1: pow.eotf_f32(),
|
||||
arg2: 0.0,
|
||||
arg3: 0.0,
|
||||
arg4: 0.0,
|
||||
};
|
||||
let offset = writer.write(uniform_buffer_offset_mask, &data);
|
||||
e.insert(EotfArg { offset })
|
||||
}
|
||||
}
|
||||
};
|
||||
Some(ct.offset)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#define TF_LOG100 8
|
||||
#define TF_LOG316 9
|
||||
#define TF_ST428 10
|
||||
#define TF_POW 11
|
||||
|
||||
vec3 eotf_st2084_pq(vec3 c) {
|
||||
c = clamp(c, 0.0, 1.0);
|
||||
|
|
@ -92,6 +93,7 @@ vec3 apply_eotf(vec3 c) {
|
|||
case TF_LOG100: return eotf_log100(c);
|
||||
case TF_LOG316: return eotf_log316(c);
|
||||
case TF_ST428: return eotf_st428(c);
|
||||
case TF_POW: return sign(c) * pow(abs(c), vec3(cm_eotf_args.arg1));
|
||||
default: return c;
|
||||
}
|
||||
}
|
||||
|
|
@ -107,6 +109,7 @@ vec3 apply_inv_eotf(vec3 c) {
|
|||
case TF_LOG100: return inv_eotf_log100(c);
|
||||
case TF_LOG316: return inv_eotf_log316(c);
|
||||
case TF_ST428: return inv_eotf_st428(c);
|
||||
case TF_POW: return sign(c) * pow(abs(c), vec3(cm_inv_eotf_args.arg1));
|
||||
default: return c;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue