diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index bc245635906..941834f482e 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -340,7 +340,7 @@ static inline uint16_t r300_translate_vertex_data_type(enum pipe_format format) { uint32_t result = 0; const struct util_format_description *desc; - unsigned i; + int i = util_format_get_first_non_void_channel(format); if (!format) format = PIPE_FORMAT_R32_FLOAT; @@ -351,13 +351,6 @@ r300_translate_vertex_data_type(enum pipe_format format) { return R300_INVALID_FORMAT; } - /* Find the first non-VOID channel. */ - for (i = 0; i < 4; i++) { - if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) { - break; - } - } - switch (desc->channel[i].type) { /* Half-floats, floats, doubles */ case UTIL_FORMAT_TYPE_FLOAT: diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index cfc6eff6689..b5b85ffb6fb 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -169,7 +169,7 @@ uint32_t r300_translate_texformat(enum pipe_format format, { uint32_t result = 0; const struct util_format_description *desc; - unsigned i; + int i; boolean uniform = TRUE; const uint32_t sign_bit[4] = { R300_TX_FORMAT_SIGNED_W, @@ -358,14 +358,8 @@ uint32_t r300_translate_texformat(enum pipe_format format, return ~0; /* Unsupported/unknown. */ } - /* Find the first non-VOID channel. */ - for (i = 0; i < 4; i++) { - if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) { - break; - } - } - - if (i == 4) + i = util_format_get_first_non_void_channel(format); + if (i == -1) return ~0; /* Unsupported/unknown. */ /* And finally, uniform formats. */ @@ -591,21 +585,15 @@ static uint32_t r300_translate_zsformat(enum pipe_format format) static uint32_t r300_translate_out_fmt(enum pipe_format format) { uint32_t modifier = 0; - unsigned i; + int i; const struct util_format_description *desc; boolean uniform_sign; format = r300_unbyteswap_array_format(format); desc = util_format_description(format); - /* Find the first non-VOID channel. */ - for (i = 0; i < 4; i++) { - if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) { - break; - } - } - - if (i == 4) + i = util_format_get_first_non_void_channel(format); + if (i == -1) return ~0; /* Unsupported/unknown. */ /* Specifies how the shader output is written to the fog unit. */