diff options
author | Christian König <[email protected]> | 2012-08-22 12:35:02 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2012-08-22 15:33:54 +0200 |
commit | 302c66ff813221998bbdcd56887a440aa3c60650 (patch) | |
tree | 4b8bf912765f74e2e24a4d3f782eb40288e871c5 /src/gallium/drivers | |
parent | 07838603b9a69c05911edbcd351bfce5ad9b5a2c (diff) |
radeonsi: rework vertex format handling
Preventing piglit's draw-vertices test from hanging the GPU.
Signed-off-by: Christian König <[email protected]>
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 68 |
1 files 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) |