Browse Source

STUPID SHADER

pull/3688/head
lizzie 2 days ago
parent
commit
6f342ec8b6
  1. 55
      src/video_core/host_shaders/y8v8u8_n420.comp

55
src/video_core/host_shaders/y8v8u8_n420.comp

@ -1,55 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#version 450
#ifdef VULKAN
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
#define END_PUSH_CONSTANTS };
#define UNIFORM(n)
#define BINDING_INPUT_BUFFER 0
#define BINDING_OUTPUT_IMAGE 1
#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv
#define BEGIN_PUSH_CONSTANTS
#define END_PUSH_CONSTANTS
#define UNIFORM(n) layout(location = n) uniform
#define BINDING_INPUT_BUFFER 0
#define BINDING_OUTPUT_IMAGE 0
#endif
BEGIN_PUSH_CONSTANTS
UNIFORM(1) uint in_luma_stride;
UNIFORM(2) uint in_chroma_stride;
UNIFORM(3) uint out_luma_stride;
UNIFORM(4) uint out_chroma_stride;
UNIFORM(5) uint is_planar;
UNIFORM(6) uint planar_alpha;
END_PUSH_CONSTANTS
// R = Luma, G = chroma V, B = chroma U
layout(binding = 0) uniform sampler2D yuv_buffer_lm;
layout(binding = 0) uniform sampler2D yuv_buffer_cv;
layout(binding = 0) uniform sampler2D yuv_buffer_cu;
layout(location = 0) out vec4 output_color;
ivec2 IndexTexelCoord(ivec2 scale, uint i) {
return ivec2(i % scale.x, i / scale.x);
}
void main() {
ivec2 texel_scale = textureSize(yuv_buffer, 0).xy;
ivec2 texel_pos = ivec2(gl_FragCoord.xy * vec2(texel_scale));
uint src_luma = uint(texel_pos.y) * in_luma_stride;
uint src_chroma = (uint(texel_pos.y) / 2) * in_chroma_stride;
uint dst = uint(texel_pos.y) * out_luma_stride;
uint yuv_r = uint(texelFetch(yuv_buffer, IndexTexelCoord(src_luma + x), 0).r * 255.f);
uint yuv_g;
uint yuv_b;
if (is_planar) {
yuv_g = uint(texelFetch(yuv_buffer, IndexTexelCoord(src_chroma + x / 2), 0).r * 255.f) << 2;
yuv_b = uint(texelFetch(yuv_buffer, IndexTexelCoord(src_chroma + x / 2), 0).r * 255.f) << 2;
} else {
yuv_g = uint(texelFetch(yuv_buffer, IndexTexelCoord(src_chroma + (x & ~1) + 0), 0).r * 255.f) << 2;
yuv_b = uint(texelFetch(yuv_buffer, IndexTexelCoord(src_chroma + (x & ~1) + 1), 0).r * 255.f) << 2;
}
output_color = vec4(uvec4(yuv_r, yuv_g, yuv_b, planar_alpha)) / 255.f;
}
Loading…
Cancel
Save