mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-16 11:48:36 +12:00
rsx: Implement strict clamp16 operation needed for NVIDIA cards
This commit is contained in:
parent
2ade3c594c
commit
ee319f7c13
1 changed files with 20 additions and 3 deletions
|
@ -249,7 +249,7 @@ std::string FragmentProgramDecompiler::ClampValue(const std::string& code, u32 p
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
return "clamp(" + code + ", -65504., 65504.)";
|
return "clamp16(" + code + ")";
|
||||||
case 2:
|
case 2:
|
||||||
return "clamp(" + code + ", -2., 2.)";
|
return "clamp(" + code + ", -2., 2.)";
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -545,10 +545,27 @@ std::string FragmentProgramDecompiler::BuildCode()
|
||||||
insertOutputs(OS);
|
insertOutputs(OS);
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
|
|
||||||
//Insert global function definitions
|
// Insert global function definitions
|
||||||
insertGlobalFunctions(OS);
|
insertGlobalFunctions(OS);
|
||||||
|
|
||||||
//Declare register gather/merge if needed
|
// Accurate float to half clamping (preserves IEEE-754 NaN)
|
||||||
|
OS <<
|
||||||
|
"vec4 clamp16(vec4 x)\n"
|
||||||
|
"{\n"
|
||||||
|
" bvec4 sel = isnan(x);\n"
|
||||||
|
" vec4 clamped = clamp(x, -65504., +65504.);\n"
|
||||||
|
" if (!any(sel))\n"
|
||||||
|
" {\n"
|
||||||
|
" return clamped;\n"
|
||||||
|
" }\n\n"
|
||||||
|
" return _select(clamped, x, sel);\n"
|
||||||
|
"}\n\n"
|
||||||
|
|
||||||
|
"vec3 clamp16(vec3 x){ return clamp16(x.xyzz).xyz; }\n"
|
||||||
|
"vec2 clamp16(vec2 x){ return clamp16(x.xyxy).xy; }\n"
|
||||||
|
"float clamp16(float x){ return isnan(x)? x : clamp(x, -65504., +65504.); }\n";
|
||||||
|
|
||||||
|
// Declare register gather/merge if needed
|
||||||
if (properties.has_gather_op)
|
if (properties.has_gather_op)
|
||||||
{
|
{
|
||||||
std::string float2 = getFloatTypeName(2);
|
std::string float2 = getFloatTypeName(2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue