summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-10-16 12:41:46 -0700
committerPokechu22 <Pokechu022@gmail.com>2021-11-17 20:04:34 -0800
commitee80298ca4b4fb810b02334508e11c5405aa77d2 (patch)
tree5fc9646b654447b8411895f397e1a5a852589386 /Source/Core/VideoCommon/PixelShaderGen.cpp
parentb9288212a018bfac1bf2239c4dd778ad74bff186 (diff)
VideoCommon: Implement diagonal LOD
Note that both GLSL and HLSL provide a fwidth (fragment width) function defined as `fwidth(p) = abs(dFdx(p)) + abs(dFdy(p))`. However, it's easy enough to implement this ourselves (and it makes the code a bit more obvious).
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index dd2d9f41ad..bff76d4246 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -662,9 +662,8 @@ uint WrapCoord(int coord, uint wrap, int size) {{
// IRs), but (at least per the software renderer) actual LOD is S28.4. How does this work?
// Also, note that we can make some assumptions due to use of a SamplerState version of the BP
// configuration, which tidies things compared to whatever nonsense games can put in.
- // TODO: This doesn't support diagonal LOD
out.Write(R"(
- float2 uv_delta = max(uv_delta_x, uv_delta_y);
+ float2 uv_delta = diag_lod ? uv_delta_x + uv_delta_y : max(uv_delta_x, uv_delta_y);
float max_delta = max(uv_delta.x / 128.0, uv_delta.y / 128.0);
// log2(x) is undefined if x <= 0, but in practice it seems log2(0) is -infinity, which becomes INT_MIN.
// If lod_bias is negative, adding it to INT_MIN causes an underflow, resulting in a large positive value.