From 302c66ff813221998bbdcd56887a440aa3c60650 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Wed, 22 Aug 2012 12:35:02 +0200 Subject: [PATCH] radeonsi: rework vertex format handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Preventing piglit's draw-vertices test from hanging the GPU. Signed-off-by: Christian König Reviewed-by: Michel Dänzer --- src/gallium/drivers/radeonsi/si_state.c | 68 +++++++++++++++++++++---- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 9a9a2506088..27bca31f124 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -1258,23 +1258,71 @@ static uint32_t si_translate_vertexformat(struct pipe_screen *screen, const struct util_format_description *desc, int first_non_void) { - uint32_t result; + unsigned type = desc->channel[first_non_void].type; + int i; + + if (type == UTIL_FORMAT_TYPE_FIXED) + return V_008F0C_BUF_DATA_FORMAT_INVALID; + + /* See whether the components are of the same size. */ + for (i = 0; i < desc->nr_channels; i++) { + if (desc->channel[first_non_void].size != desc->channel[i].size) + return V_008F0C_BUF_DATA_FORMAT_INVALID; + } - if (desc->channel[first_non_void].type == UTIL_FORMAT_TYPE_FIXED) - return ~0; + switch (desc->channel[first_non_void].size) { + case 8: + switch (desc->nr_channels) { + case 1: + return V_008F0C_BUF_DATA_FORMAT_8; + case 2: + return V_008F0C_BUF_DATA_FORMAT_8_8; + case 3: + case 4: + return V_008F0C_BUF_DATA_FORMAT_8_8_8_8; + } + break; + case 16: + switch (desc->nr_channels) { + case 1: + return V_008F0C_BUF_DATA_FORMAT_16; + case 2: + return V_008F0C_BUF_DATA_FORMAT_16_16; + case 3: + case 4: + return V_008F0C_BUF_DATA_FORMAT_16_16_16_16; + } + break; + case 32: + if (type != UTIL_FORMAT_TYPE_FLOAT) + return V_008F0C_BUF_DATA_FORMAT_INVALID; - result = si_translate_texformat(screen, format, desc, first_non_void); - if (result == V_008F0C_BUF_DATA_FORMAT_INVALID || - result > V_008F0C_BUF_DATA_FORMAT_32_32_32_32) - result = ~0; + switch (desc->nr_channels) { + case 1: + return V_008F0C_BUF_DATA_FORMAT_32; + case 2: + return V_008F0C_BUF_DATA_FORMAT_32_32; + case 3: + return V_008F0C_BUF_DATA_FORMAT_32_32_32; + case 4: + return V_008F0C_BUF_DATA_FORMAT_32_32_32_32; + } + break; + } - return result; + return V_008F0C_BUF_DATA_FORMAT_INVALID; } static bool si_is_vertex_format_supported(struct pipe_screen *screen, enum pipe_format format) { - return si_translate_vertexformat(screen, format, util_format_description(format), - util_format_get_first_non_void_channel(format)) != ~0U; + const struct util_format_description *desc; + int first_non_void; + unsigned data_format; + + desc = util_format_description(format); + first_non_void = util_format_get_first_non_void_channel(format); + data_format = si_translate_vertexformat(screen, format, desc, first_non_void); + return data_format != V_008F0C_BUF_DATA_FORMAT_INVALID; } static bool si_is_colorbuffer_format_supported(enum pipe_format format) -- 2.30.2