From: Lucas Stach Date: Wed, 23 Nov 2022 11:29:40 +0000 (+0100) Subject: etnaviv: fix ZS clear value computation X-Git-Tag: upstream/23.3.3~16349 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=58259e14377c8facc1648cab3d361a6942b59d96;p=platform%2Fupstream%2Fmesa.git etnaviv: fix ZS clear value computation Instead of hand-rolling our own conversion and apparently getting the rounding wrong, just use the common util function. Fixes piglit test spec@!opengl 1.1@depthstencil-default_fb-clear Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_translate.h b/src/gallium/drivers/etnaviv/etnaviv_translate.h index d155542..eb81001 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_translate.h +++ b/src/gallium/drivers/etnaviv/etnaviv_translate.h @@ -39,6 +39,7 @@ #include "util/format/u_format.h" #include "util/u_math.h" +#include "util/u_pack_color.h" /* Returned when there is no match of pipe value to etna value */ #define ETNA_NO_MATCH (~0) @@ -449,24 +450,14 @@ translate_draw_mode(unsigned mode) } static inline uint32_t -translate_clear_depth_stencil(enum pipe_format format, float depth, - unsigned stencil) +translate_clear_depth_stencil(enum pipe_format format, double depth, + uint8_t stencil) { - uint32_t clear_value = 0; + uint32_t clear_value = util_pack_z_stencil(format, depth, stencil); - // XXX util_pack_color - switch (format) { - case PIPE_FORMAT_Z16_UNORM: - clear_value = etna_cfloat_to_uintN(depth, 16); + if (format == PIPE_FORMAT_Z16_UNORM) clear_value |= clear_value << 16; - break; - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8_UINT_Z24_UNORM: - clear_value = (etna_cfloat_to_uintN(depth, 24) << 8) | (stencil & 0xFF); - break; - default: - DBG("Unhandled pipe format for depth stencil clear: %i", format); - } + return clear_value; } diff --git a/src/gallium/drivers/etnaviv/etnaviv_util.h b/src/gallium/drivers/etnaviv/etnaviv_util.h index f6fe4c4..48b1e7d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_util.h +++ b/src/gallium/drivers/etnaviv/etnaviv_util.h @@ -43,19 +43,6 @@ etna_cfloat_to_uint8(float f) return f * 256.0f; } -/* clamped float [0.0 .. 1.0] -> [0 .. (1<= (1.0f - 1.0f / (1 << bits))) - return (1 << bits) - 1; - - return f * (1 << bits); -} - /* 1/log10(2) */ #define RCPLOG2 (1.4426950408889634f)