[UI] UI common shaders to XeSL

This commit is contained in:
Triang3l
2022-02-06 22:48:24 +03:00
parent e07ed95f53
commit 9b1fdac986
76 changed files with 6490 additions and 6926 deletions

View File

@@ -0,0 +1,55 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2022 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xesl.xesli"
#if XE_GUEST_OUTPUT_DITHER
#include "dither_8bpc.xesli"
#endif // XE_GUEST_OUTPUT_DITHER
xesl_push_constants_begin(b0, space0)
// 16 used by the vertex shader (GLSL push constant offsets are across
// stages).
xesl_block_offset_member(16, c0.x, xesl_int2, xe_bilinear_output_offset)
// CasSetup const1.x.
xesl_block_offset_member(24, c0.z, xesl_float2, xe_bilinear_output_size_inv)
xesl_push_constants_end
xesl_entry
xesl_sampler(xesl_sampler2D, xe_bilinear_source, set=0, binding=0, t0,
space0, s0, space0)
xesl_entry_bindings_end
xesl_input_frag_coord
xesl_entry_signature_next
xesl_output_color(xesl_float4, xe_bilinear_color, 0)
xesl_entry_signature_end
xesl_uint2 pixel_coord =
xesl_uint2(xesl_int2(xesl_FragCoord.xy) -
xesl_push_constant(xe_bilinear_output_offset));
// + 0.5 so the origin is at the pixel center, and at 1:1 the original pixel
// is taken.
// Interpolating the four colors in the perceptual space because doing it in
// linear space causes, in particular, bright text on a dark background to
// become too thick, and aliasing of bright parts on top of dark areas to be
// too apparent (4D5307E6 HUD, for example, mainly the edges of the
// multiplayer score bars).
xe_bilinear_color.rgb =
xesl_textureSampleLod2D_comb(
xe_bilinear_source,
(xesl_float2(pixel_coord) + 0.5) *
xesl_push_constant(xe_bilinear_output_size_inv),
0.0).rgb;
#if XE_GUEST_OUTPUT_DITHER
// Clamping because on Vulkan, the surface may specify any format, including
// floating-point.
xe_bilinear_color.rgb =
xesl_saturate(xe_bilinear_color.rgb + XeDitherOffset8bpc(pixel_coord));
#endif // XE_GUEST_OUTPUT_DITHER
xe_bilinear_color.a = 1.0;
xesl_entry_end