diff --git a/bin/resources/shaders/dx11/tfx.fx b/bin/resources/shaders/dx11/tfx.fx index 73933e12d3..f063ff5625 100644 --- a/bin/resources/shaders/dx11/tfx.fx +++ b/bin/resources/shaders/dx11/tfx.fx @@ -261,10 +261,21 @@ float manual_lod(float uv_w) #endif #if PS_ANISOTROPIC_FILTERING > 1 +bool2 nan_or_inf(float2 xy) +{ + // FXC (<=SM5.1) may optimise away isnan and isinf. + // DXC (>=SM6.0) will preserve them. +#ifdef __hlsl_dx_compiler + return isinf(xy) | isnan(xy); +#else + return (asuint(xy) & 0x7f800000) == 0x7f800000; +#endif +} + float4 sample_c_af(float2 uv, float uv_w) { // HW sampler will reject bad UVs, match that here. - uv = any(isnan(uv) | isinf(uv)) ? float2(0, 0) : uv; + uv = any(nan_or_inf(uv)) ? float2(0, 0) : uv; // Large floating point values risk NaN/Inf values. // Above this value floats lose decimal precision, so seems a resonable limit for UVs. @@ -281,7 +292,7 @@ float4 sample_c_af(float2 uv, float uv_w) bool d_zero = length(dX) == 0 || length(dY) == 0; bool d_par = (dX.x * dY.y - dY.x * dX.y) == 0; bool d_per = dot(dX, dY) == 0; - bool d_inf_nan = any(isinf(dX) | isinf(dY) | isnan(dX) | isnan(dY)); + bool d_inf_nan = any(nan_or_inf(dX) | nan_or_inf(dY)); if (!(d_zero || d_par || d_per || d_inf_nan)) { @@ -305,7 +316,7 @@ float4 sample_c_af(float2 uv, float uv_w) sqrt(F * (t + p) / (t * (q - t))) ); - d_inf_nan = any(isinf(new_dX) | isinf(new_dY) | isnan(new_dX) | isnan(new_dY)); + d_inf_nan = any(nan_or_inf(new_dX) | nan_or_inf(new_dY)); if (!d_inf_nan) { dX = new_dX; diff --git a/pcsx2/GS/Renderers/DX11/D3D.cpp b/pcsx2/GS/Renderers/DX11/D3D.cpp index 0e05af71a1..96414df850 100644 --- a/pcsx2/GS/Renderers/DX11/D3D.cpp +++ b/pcsx2/GS/Renderers/DX11/D3D.cpp @@ -523,8 +523,8 @@ wil::com_ptr_nothrow D3D::CompileShader(D3D::ShaderType type, D3D::Sha break; } - static constexpr UINT flags_non_debug = D3DCOMPILE_OPTIMIZATION_LEVEL3 | D3DCOMPILE_IEEE_STRICTNESS; - static constexpr UINT flags_debug = D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_DEBUG | D3DCOMPILE_DEBUG_NAME_FOR_SOURCE | D3DCOMPILE_IEEE_STRICTNESS; + static constexpr UINT flags_non_debug = D3DCOMPILE_OPTIMIZATION_LEVEL3; + static constexpr UINT flags_debug = D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_DEBUG | D3DCOMPILE_DEBUG_NAME_FOR_SOURCE; wil::com_ptr_nothrow blob; wil::com_ptr_nothrow error_blob; diff --git a/pcsx2/ShaderCacheVersion.h b/pcsx2/ShaderCacheVersion.h index 069db4c6b0..86923b8981 100644 --- a/pcsx2/ShaderCacheVersion.h +++ b/pcsx2/ShaderCacheVersion.h @@ -3,4 +3,4 @@ /// Version number for GS and other shaders. Increment whenever any of the contents of the /// shaders change, to invalidate the cache. -static constexpr u32 SHADER_CACHE_VERSION = 95; // Last changed in PR 14439 +static constexpr u32 SHADER_CACHE_VERSION = 96; // Last changed in PR 14479