mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
i965/clear: Quantize the depth clear value based on the format
Inf9fd976e8awe changed the clear value to be stored as an isl_color_value. This had the side-effect same clear value check is now happening directly between the f32[0] field of the isl_color_value and ctx->Depth.Clear. This isn't what we want for two reasons. One is that the comparison happens in floating point even for Z16 and Z24 formats. Worse than that, ctx->Depth.Clear is a double so, even for 32-bit float formats, we were comparing as doubles and not floats. This means that the test basically always fails for anything other than 0.0f and 1.0f. This caused a slight performance regression in Lightsmark 2008 because it was using a depth clear value of 0.999 which can't be stored in a 32-bit float so we were doing unneeded resolves. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Bugzilla: https://bugs.freedesktop.org/101678 Cc: "17.2" <mesa-stable@lists.freedesktop.org> (cherry picked from commit0ae9ce0f29) Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> [Emil Velikov: squash trivial conflicts] Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Conflicts: src/mesa/drivers/dri/i965/brw_clear.c
This commit is contained in:
parent
9ba7693a9a
commit
91715a3681
1 changed files with 12 additions and 2 deletions
|
|
@ -159,14 +159,24 @@ brw_fast_clear_depth(struct gl_context *ctx)
|
|||
break;
|
||||
}
|
||||
|
||||
/* Quantize the clear value to what can be stored in the actual depth
|
||||
* buffer. This makes the following check more accurate because it now
|
||||
* checks if the actual depth bits will match. It also prevents us from
|
||||
* getting a too-accurate depth value during depth testing or when sampling
|
||||
* with HiZ enabled.
|
||||
*/
|
||||
float clear_value =
|
||||
mt->format == MESA_FORMAT_Z_FLOAT32 ? ctx->Depth.Clear :
|
||||
(unsigned)(ctx->Depth.Clear * fb->_DepthMax) / (float)fb->_DepthMax;
|
||||
|
||||
/* If we're clearing to a new clear value, then we need to resolve any clear
|
||||
* flags out of the HiZ buffer into the real depth buffer.
|
||||
*/
|
||||
if (mt->fast_clear_color.f32[0] != ctx->Depth.Clear) {
|
||||
if (mt->fast_clear_color.f32[0] != clear_value) {
|
||||
intel_miptree_prepare_access(brw, mt, 0, INTEL_REMAINING_LEVELS,
|
||||
0, INTEL_REMAINING_LAYERS,
|
||||
ISL_AUX_USAGE_HIZ, false);
|
||||
mt->fast_clear_color.f32[0] = ctx->Depth.Clear;
|
||||
mt->fast_clear_color.f32[0] = clear_value;
|
||||
}
|
||||
|
||||
if (depth_att->Layered) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue