nv2a/vsh: Use double precision in clip range remap

This commit is contained in:
Erik Abair 2021-11-18 16:17:59 -08:00 committed by GitHub
parent 1c6e75885c
commit 1a15d83c44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -776,9 +776,15 @@ void vsh_translate(uint16_t version,
* Note this makes the values in the depth buffer wrong. This should be
* handled with gl_ClipDistance instead, but that has performance issues
* on OS X.
*
* This conversion is performed at double precision to handle max depth
* clipping in the Xbox z24s8 floating point mode.
*/
" if (clipRange.y != clipRange.x) {\n"
" oPos.z = (oPos.z - clipRange.x)/(0.5*(clipRange.y - clipRange.x)) - 1;\n"
" double work = double(oPos.z - clipRange.x);\n"
" double half_full_distance = 0.5 * double(clipRange.y - clipRange.x);\n"
" oPos.z = float(work / half_full_distance);\n"
" oPos.z = oPos.z - 1;\n"
" }\n"
/* Correct for the perspective divide */
@ -794,4 +800,3 @@ void vsh_translate(uint16_t version,
);
}