mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 05:28:56 +02:00
STUPID SHADER
This commit is contained in:
parent
3c39217cc8
commit
6f342ec8b6
1 changed files with 0 additions and 55 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue