summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-11-13 20:10:20 -0800
committerPokechu22 <Pokechu022@gmail.com>2021-11-17 20:04:34 -0800
commit51e3334526ec3d86655c49307577f9bcffd05aa6 (patch)
tree8ced44c2c4db128ad229af1c0d6d9dfe4f01eae7 /Source/Core/VideoCommon/PixelShaderGen.cpp
parentddf26913955cdfad9ca502aa444cdf94bc0964e8 (diff)
VideoCommon: Use coarse derivatives for Manual Texture Sampling if possible
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index b2a1166fd6..dd2d9f41ad 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -628,15 +628,35 @@ uint WrapCoord(int coord, uint wrap, int size) {{
BitfieldExtract<&SamplerState::TM1::max_lod>("texmode1"));
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
- out.Write(R"(
+ {
+ if (g_ActiveConfig.backend_info.bSupportsCoarseDerivatives)
+ {
+ // The software renderer uses the equivalent of coarse derivatives, so use them here for
+ // consistency. This hasn't been hardware tested.
+ // Note that bSupportsCoarseDerivatives being false only means dFdxCoarse and dFdxFine don't
+ // exist. The GPU may still implement dFdx using coarse derivatives; we just don't have the
+ // ability to specifically require it.
+ out.Write(R"(
+ float2 uv_delta_x = abs(dFdxCoarse(float2(uv)));
+ float2 uv_delta_y = abs(dFdyCoarse(float2(uv)));
+)");
+ }
+ else
+ {
+ out.Write(R"(
float2 uv_delta_x = abs(dFdx(float2(uv)));
float2 uv_delta_y = abs(dFdy(float2(uv)));
)");
+ }
+ }
else if (api_type == APIType::D3D)
+ {
+ ASSERT(g_ActiveConfig.backend_info.bSupportsCoarseDerivatives);
out.Write(R"(
- float2 uv_delta_x = abs(ddx(float2(uv)));
- float2 uv_delta_y = abs(ddy(float2(uv)));
+ float2 uv_delta_x = abs(ddx_coarse(float2(uv)));
+ float2 uv_delta_y = abs(ddy_coarse(float2(uv)));
)");
+ }
// TODO: LOD bias is normally S2.5 (Dolphin uses S7.8 for arbitrary mipmap detection and higher
// IRs), but (at least per the software renderer) actual LOD is S28.4. How does this work?