nv2a: Implement z16 float shadow comparison

This commit is contained in:
Erik Abair 2022-05-31 11:03:06 -07:00 committed by mborgerson
parent 84fa8dac3e
commit 8a97cec99f
2 changed files with 11 additions and 4 deletions

View File

@ -299,6 +299,11 @@ static const ColorFormatInfo kelvin_color_format_map[66] = {
[NV097_SET_TEXTURE_FORMAT_COLOR_LC_IMAGE_YB8CR8YA8CB8] =
{2, true, GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV},
/* Additional information is passed to the pixel shader via the swizzle:
* RED: The depth value.
* GREEN: 0 for 16-bit, 1 for 24 bit
* BLUE: 0 for fixed, 1 for float
*/
[NV097_SET_TEXTURE_FORMAT_COLOR_SZ_DEPTH_Y16_FIXED] =
{2, false, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,
{GL_RED, GL_ZERO, GL_ZERO, GL_ZERO}, true},
@ -313,8 +318,8 @@ static const ColorFormatInfo kelvin_color_format_map[66] = {
{2, true, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,
{GL_RED, GL_ZERO, GL_ZERO, GL_ZERO}, true},
[NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_Y16_FLOAT] =
{2, true, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_FLOAT,
{GL_RED, GL_ZERO, GL_ZERO, GL_ZERO}, true},
{2, true, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_HALF_FLOAT,
{GL_RED, GL_ZERO, GL_ONE, GL_ZERO}, true},
[NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_Y16] =
{2, true, GL_R16, GL_RED, GL_UNSIGNED_SHORT,

View File

@ -640,6 +640,8 @@ static void psh_append_shadowmap(const struct PixelShader *ps, int i, bool compa
i, i, i, i, i);
const char *comparison = shadow_comparison_map[ps->state.shadow_depth_func];
// Depth.y != 0 indicates 24 bit; depth.z != 0 indicates float.
if (compare_z) {
mstring_append_fmt(
vars,
@ -647,13 +649,13 @@ static void psh_append_shadowmap(const struct PixelShader *ps, int i, bool compa
"if (t%d_depth.y > 0) {\n"
" t%d_max_depth = 0xFFFFFF;\n"
"} else {\n"
" t%d_max_depth = 0xFFFF; // TODO: Support float max.\n"
" t%d_max_depth = t%d_depth.z > 0 ? 511.9375 : 0xFFFF;\n"
"}\n"
"t%d_depth.x *= t%d_max_depth;\n"
"pT%d.z = clamp(pT%d.z / pT%d.w, 0, t%d_max_depth);\n"
"vec4 t%d = vec4(t%d_depth.x %s pT%d.z ? 1.0 : 0.0);\n",
i, i, i, i, i,
i, i, i, i, i,
i, i, i, i, i, i,
i, i, comparison, i);
} else {
mstring_append_fmt(