1
0
Fork 0
forked from wry/wry

vulkan: unify Tex/OutColorManagementData

This commit is contained in:
Julian Orth 2025-09-08 18:04:02 +02:00
parent 05bf029a55
commit a2e089d9e3
6 changed files with 31 additions and 31 deletions

View file

@ -25,10 +25,10 @@ use {
sampler::VulkanSampler,
semaphore::VulkanSemaphore,
shaders::{
FILL_FRAG, FILL_VERT, FillPushConstants, LEGACY_FILL_FRAG, LEGACY_FILL_VERT,
LEGACY_TEX_FRAG, LEGACY_TEX_VERT, LegacyFillPushConstants, LegacyTexPushConstants,
OUT_FRAG, OUT_VERT, OutColorManagementData, OutPushConstants, TEX_FRAG, TEX_VERT,
TexColorManagementData, TexPushConstants, TexVertex, VulkanShader,
ColorManagementData, FILL_FRAG, FILL_VERT, FillPushConstants, LEGACY_FILL_FRAG,
LEGACY_FILL_VERT, LEGACY_TEX_FRAG, LEGACY_TEX_VERT, LegacyFillPushConstants,
LegacyTexPushConstants, OUT_FRAG, OUT_VERT, OutPushConstants, TEX_FRAG, TEX_VERT,
TexPushConstants, TexVertex, VulkanShader,
},
},
io_uring::IoUring,
@ -352,7 +352,7 @@ impl VulkanDevice {
};
let uniform_buffer_cache = {
let usage = BufferUsageFlags::SHADER_DEVICE_ADDRESS | BufferUsageFlags::UNIFORM_BUFFER;
let align = align_of::<TexColorManagementData>() as DeviceSize;
let align = align_of::<ColorManagementData>() as DeviceSize;
VulkanBufferCache::new(self, &allocator, usage, align)
};
let render = Rc::new(VulkanRenderer {
@ -575,7 +575,7 @@ impl VulkanRenderer {
if let Some(addr) = memory.blend_buffer_color_management_data_address {
let uniform_buffer = DescriptorAddressInfoEXT::default()
.address(addr)
.range(size_of::<OutColorManagementData>() as _);
.range(size_of::<ColorManagementData>() as _);
let info = DescriptorGetInfoEXT::default()
.ty(DescriptorType::UNIFORM_BUFFER)
.data(DescriptorDataEXT {
@ -603,7 +603,7 @@ impl VulkanRenderer {
if let Some(addr) = c.color_management_data_address {
let uniform_buffer = DescriptorAddressInfoEXT::default()
.address(addr)
.range(size_of::<TexColorManagementData>() as _);
.range(size_of::<ColorManagementData>() as _);
let info = DescriptorGetInfoEXT::default()
.ty(DescriptorType::UNIFORM_BUFFER)
.data(DescriptorDataEXT {
@ -2233,7 +2233,7 @@ impl ColorTransforms {
) -> Option<DeviceSize> {
let ct = self.get_or_create(src, dst)?;
if ct.offset.is_none() {
let data = TexColorManagementData {
let data = ColorManagementData {
matrix: ct.matrix.to_f32(),
};
let offset = writer.write(uniform_buffer_offset_mask, &data);

View file

@ -63,19 +63,11 @@ unsafe impl Packed for TexPushConstants {}
#[derive(Copy, Clone, Debug)]
#[repr(C, align(16))]
pub struct TexColorManagementData {
pub struct ColorManagementData {
pub matrix: [[f32; 4]; 4],
}
unsafe impl Packed for TexColorManagementData {}
#[derive(Copy, Clone, Debug)]
#[repr(C, align(16))]
pub struct OutColorManagementData {
pub matrix: [[f32; 4]; 4],
}
unsafe impl Packed for OutColorManagementData {}
unsafe impl Packed for ColorManagementData {}
#[derive(Copy, Clone, Debug)]
#[repr(C)]

View file

@ -2,6 +2,7 @@
#define EOTFS_GLSL
#include "frag_spec_const.glsl"
#include "tex_set.glsl"
#define TF_LINEAR 1
#define TF_ST2084_PQ 2

View file

@ -3,18 +3,17 @@
#extension GL_EXT_samplerless_texture_functions : require
#extension GL_EXT_scalar_block_layout : require
#include "frag_spec_const.glsl"
#include "eotfs.glsl"
#include "out.common.glsl"
#define TEX_SET 0
#include "frag_spec_const.glsl"
#include "out.common.glsl"
#include "tex_set.glsl"
#include "eotfs.glsl"
layout(set = 0, binding = 0) uniform texture2D in_color;
layout(set = 0, binding = 1, row_major, std430) uniform ColorManagementData {
mat4x4 matrix;
} cm_data;
layout(location = 0) out vec4 out_color;
void main() {
vec4 c = texelFetch(in_color, ivec2(gl_FragCoord.xy), 0);
vec4 c = texelFetch(tex, ivec2(gl_FragCoord.xy), 0);
if (eotf != inv_eotf || has_matrix) {
vec3 rgb = c.rgb;
rgb /= mix(c.a, 1.0, c.a == 0.0);

View file

@ -2,15 +2,14 @@
#extension GL_EXT_scalar_block_layout : require
#define TEX_SET 1
#include "frag_spec_const.glsl"
#include "eotfs.glsl"
#include "tex.common.glsl"
#include "tex_set.glsl"
#include "eotfs.glsl"
layout(set = 0, binding = 0) uniform sampler sam;
layout(set = 1, binding = 0) uniform texture2D tex;
layout(set = 1, binding = 1, row_major, std430) uniform ColorManagementData {
mat4x4 matrix;
} cm_data;
layout(location = 0) in vec2 tex_pos;
layout(location = 0) out vec4 out_color;

View file

@ -0,0 +1,9 @@
#ifndef TEX_SET_GLSL
#define TEX_SET_GLSL
layout(set = TEX_SET, binding = 0) uniform texture2D tex;
layout(set = TEX_SET, binding = 1, row_major, std430) uniform ColorManagementData {
mat4x4 matrix;
} cm_data;
#endif