75 lines
2.2 KiB
Text
75 lines
2.2 KiB
Text
#version 450
|
|
|
|
#extension GL_GOOGLE_include_directive : require
|
|
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require
|
|
#extension GL_EXT_scalar_block_layout : require
|
|
|
|
#include "descriptor_set.h"
|
|
|
|
layout(
|
|
local_size_x = 8,
|
|
local_size_y = 8,
|
|
local_size_z = 1) in;
|
|
|
|
// NV12 Format is:
|
|
// YYYYYYYYYYYYYYY...
|
|
// YYYYYYYYYYYYYYY...
|
|
// UVUVUVUVUVUVUVU...
|
|
|
|
const uint u_frameId = 0;
|
|
const uint8_t u_shaderFilter[VKR_MAX_LAYERS] = { uint8_t(filter_linear_emulated), uint8_t(0), uint8_t(0), uint8_t(0), uint8_t(0), uint8_t(0) };
|
|
const float u_linearToNits = 400.0f;
|
|
const float u_nitsToLinear = 1.0f / 100.0f;
|
|
const float u_itmSdrNits = 100.f;
|
|
const float u_itmTargetNits = 1000.f;
|
|
|
|
layout(binding = 0, scalar)
|
|
uniform layers_t {
|
|
vec2 u_scale[1];
|
|
vec2 u_offset[1];
|
|
float u_opacity[1];
|
|
mat3x4 u_ctm[1];
|
|
mat3x4 u_outputCTM;
|
|
uint u_borderMask;
|
|
uvec2 u_halfExtent;
|
|
};
|
|
|
|
#include "composite.h"
|
|
|
|
vec4 sampleLayer(uint layerIdx, vec2 uv) {
|
|
return sampleLayer(s_samplers[layerIdx], layerIdx, uv, true);
|
|
}
|
|
|
|
vec3 applyColorMatrix(vec3 rgb, mat3x4 matrix) {
|
|
return vec4(linearToSrgb(rgb), 1.0f) * matrix;
|
|
}
|
|
|
|
void main() {
|
|
ivec3 thread_id = ivec3(gl_GlobalInvocationID);
|
|
|
|
// todo: fix
|
|
if (all(lessThan(thread_id.xy, ivec2(u_halfExtent.x, u_halfExtent.y)))) {
|
|
ivec2 offset_table[4] = {
|
|
ivec2(0, 0), ivec2(1, 0), ivec2(0, 1), ivec2(1, 1),
|
|
};
|
|
|
|
ivec2 chroma_uv = thread_id.xy;
|
|
ivec2 luma_uv = thread_id.xy * 2;
|
|
|
|
vec3 color[4] = {
|
|
sampleLayer(0, vec2(luma_uv.x + offset_table[0].x, luma_uv.y + offset_table[0].y)).rgb,
|
|
sampleLayer(0, vec2(luma_uv.x + offset_table[1].x, luma_uv.y + offset_table[1].y)).rgb,
|
|
sampleLayer(0, vec2(luma_uv.x + offset_table[2].x, luma_uv.y + offset_table[2].y)).rgb,
|
|
sampleLayer(0, vec2(luma_uv.x + offset_table[3].x, luma_uv.y + offset_table[3].y)).rgb,
|
|
};
|
|
|
|
vec3 avg_color = (color[0] + color[1] + color[2] + color[3]) / 4.0f;
|
|
vec2 uv = applyColorMatrix(avg_color, u_outputCTM).yz;
|
|
imageStore(dst_chroma, chroma_uv, vec4(uv, 0.0f, 1.0f));
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
float y = applyColorMatrix(color[i], u_outputCTM).x;
|
|
imageStore(dst_luma, luma_uv + offset_table[i], vec4(y, 0.0f, 0.0f, 1.0f));
|
|
}
|
|
}
|
|
}
|