r300_translate_vertex_data_type(enum pipe_format format) {
uint32_t result = 0;
const struct util_format_description *desc;
- unsigned components = util_format_get_nr_components(format);
desc = util_format_description(format);
switch (desc->channel[0].type) {
/* Half-floats, floats, doubles */
case UTIL_FORMAT_TYPE_FLOAT:
- switch (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
+ switch (desc->channel[0].size) {
case 16:
/* XXX Supported only on RV350 and later. */
- if (components > 2) {
+ if (desc->nr_channels > 2) {
result = R300_DATA_TYPE_FLT16_4;
} else {
result = R300_DATA_TYPE_FLT16_2;
}
break;
case 32:
- result = R300_DATA_TYPE_FLOAT_1 + (components - 1);
+ result = R300_DATA_TYPE_FLOAT_1 + (desc->nr_channels - 1);
break;
default:
fprintf(stderr, "r300: Bad format %s in %s:%d\n",
case UTIL_FORMAT_TYPE_UNSIGNED:
/* Signed ints */
case UTIL_FORMAT_TYPE_SIGNED:
- switch (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
+ switch (desc->channel[0].size) {
case 8:
result = R300_DATA_TYPE_BYTE;
break;
case 16:
- if (components > 2) {
+ if (desc->nr_channels > 2) {
result = R300_DATA_TYPE_SHORT_4;
} else {
result = R300_DATA_TYPE_SHORT_2;
default:
fprintf(stderr, "r300: Bad format %s in %s:%d\n",
util_format_name(format), __FUNCTION__, __LINE__);
- fprintf(stderr, "r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
- util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0));
+ fprintf(stderr, "r300: desc->channel[0].size == %d\n",
+ desc->channel[0].size);
assert(0);
}
break;
{
uint32_t result = 0;
const struct util_format_description *desc;
- unsigned components = 0, i;
+ unsigned i;
boolean uniform = TRUE;
const uint32_t swizzle_shift[4] = {
R300_TX_FORMAT_R_SHIFT,
}
}
- /* Get the number of components. */
- for (i = 0; i < 4; i++) {
- if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
- ++components;
- }
- }
-
/* Add sign. */
- for (i = 0; i < components; i++) {
+ for (i = 0; i < desc->nr_channels; i++) {
if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
result |= sign_bit[i];
}
}
/* See whether the components are of the same size. */
- for (i = 1; i < components; i++) {
+ for (i = 1; i < desc->nr_channels; i++) {
uniform = uniform && desc->channel[0].size == desc->channel[i].size;
}
/* Non-uniform formats. */
if (!uniform) {
- switch (components) {
+ switch (desc->nr_channels) {
case 3:
if (desc->channel[0].size == 5 &&
desc->channel[1].size == 6 &&
switch (desc->channel[0].size) {
case 4:
- switch (components) {
+ switch (desc->nr_channels) {
case 2:
return R300_TX_FORMAT_Y4X4 | result;
case 4:
return ~0;
case 8:
- switch (components) {
+ switch (desc->nr_channels) {
case 1:
return R300_TX_FORMAT_X8 | result;
case 2:
return ~0;
case 16:
- switch (components) {
+ switch (desc->nr_channels) {
case 1:
return R300_TX_FORMAT_X16 | result;
case 2:
case UTIL_FORMAT_TYPE_FLOAT:
switch (desc->channel[0].size) {
case 16:
- switch (components) {
+ switch (desc->nr_channels) {
case 1:
return R300_TX_FORMAT_16F | result;
case 2:
return ~0;
case 32:
- switch (components) {
+ switch (desc->nr_channels) {
case 1:
return R300_TX_FORMAT_32F | result;
case 2: