1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 10:24:12 +01:00

[d3d9] Move some YUV helpers to common and cleanup YUY2 shader

This commit is contained in:
Joshua Ashton 2020-08-06 07:19:50 +01:00 committed by Joshie
parent ad6b91d84a
commit 2cfd219024
2 changed files with 26 additions and 19 deletions

View File

@ -9,5 +9,21 @@ float snormalize(int value, int bits) {
// Min because, -32 and -31 map to -1.0f, and we
// divide by 31.
return max(float(value) / float(range), -1.0f);
return max(float(value) / float(range), -1.0);
}
float unpackUnorm(uint p) {
return float(p) / 255.0;
}
mat3x4 g_yuv_to_rgb = {
{ 298 / 256, 0, 409 / 256, 0.5 },
{ 298 / 256, -100 / 256, -208 / 256, 0.5 },
{ 298 / 256, 516 / 256, 0, 0.5 }
};
vec4 convertYUV(vec3 yuv) {
vec3 value = vec4(yuv, 1 / 255.0) * g_yuv_to_rgb;
return vec4(clamp(value, 0, 1), 1);
}

View File

@ -1,4 +1,7 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "d3d9_convert_common.h"
layout(constant_id = 1249) const bool s_is_uyvy = false;
@ -17,18 +20,6 @@ uniform u_info_t {
uvec2 extent;
} u_info;
mat3x4 g_yuv_to_rgb = {
{ 298 / 256, 0, 409 / 256, 0.5 },
{ 298 / 256, -100 / 256, -208 / 256, 0.5 },
{ 298 / 256, 516 / 256, 0, 0.5 }
};
vec4 convertYUV(vec3 cde) {
vec3 value = vec4(cde, 1 / 255.0) * g_yuv_to_rgb;
return vec4(clamp(value, 0, 1), 1);
}
void main() {
ivec3 thread_id = ivec3(gl_GlobalInvocationID);
@ -44,13 +35,13 @@ void main() {
if (s_is_uyvy)
data = data.yxwz;
float c0 = data.x - (16 / 255.0);
float d = data.y - (128 / 255.0);
float c1 = data.z - (16 / 255.0);
float e = data.w - (128 / 255.0);
float y0 = data.x - (16 / 255.0);
float u = data.y - (128 / 255.0);
float y1 = data.z - (16 / 255.0);
float v = data.w - (128 / 255.0);
vec4 color0 = convertYUV(vec3(c0, d, e));
vec4 color1 = convertYUV(vec3(c1, d, e));
vec4 color0 = convertYUV(vec3(y0, u, v));
vec4 color1 = convertYUV(vec3(y1, u, v));
// YUY2 has a macropixel of [2, 1]
// so we write 2 pixels in this run.