From e11209ac79aaf8a9e8c5caaa8b247a95a665fce9 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 9 Feb 2018 16:33:08 +0100 Subject: [PATCH] (D3D12) precompute alpha before scaling when generating mipmaps. --- gfx/drivers/d3d_shaders/mimpapgen_sm5.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gfx/drivers/d3d_shaders/mimpapgen_sm5.h b/gfx/drivers/d3d_shaders/mimpapgen_sm5.h index 937b9a2ab0..35632e9981 100644 --- a/gfx/drivers/d3d_shaders/mimpapgen_sm5.h +++ b/gfx/drivers/d3d_shaders/mimpapgen_sm5.h @@ -35,7 +35,12 @@ SRC( float4 c = 0.0f; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) - c += w[i] * w[j] * t0.SampleLevel(s0, texel_size * (DTid.xy + 0.5f * float2(i - 0.5f,j - 0.5f)), src_level); + { + float4 c0 = t0.SampleLevel(s0, texel_size * (DTid.xy + 0.5f * float2(i - 0.5f,j - 0.5f)), src_level); + c0.rgb *= c0.a; + c += w[i] * w[j] * c0; + } + c.rgb /= c.a; u0[DTid.xy] = c; return;