#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)
}
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;
}
return f * 256.0f;
}
-/* clamped float [0.0 .. 1.0] -> [0 .. (1<<bits)-1] */
-static inline uint32_t
-etna_cfloat_to_uintN(float f, int bits)
-{
- if (f <= 0.0f)
- return 0;
-
- if (f >= (1.0f - 1.0f / (1 << bits)))
- return (1 << bits) - 1;
-
- return f * (1 << bits);
-}
-
/* 1/log10(2) */
#define RCPLOG2 (1.4426950408889634f)