#define R300_RESOURCE_FLAG_TRANSFER PIPE_RESOURCE_FLAG_DRV_PRIV
+#define R300_INVALID_FORMAT (~0)
+
/* XXX: this is just a bandaid on larger problems in
* r300_screen_buffer.h which doesn't seem to be fully ported to
* gallium-resources.
#include "r300_context.h"
#include "r300_texture.h"
#include "r300_screen_buffer.h"
+#include "r300_state_inlines.h"
#include "r300_winsys.h"
/* Return the identifier behind whom the brave coders responsible for this
uint32_t retval = 0;
boolean is_r500 = r300_screen(screen)->caps.is_r500;
boolean is_r400 = r300_screen(screen)->caps.is_r400;
+ boolean is_rv350 = r300_screen(screen)->caps.is_rv350;
boolean is_z24 = format == PIPE_FORMAT_X8Z24_UNORM ||
format == PIPE_FORMAT_S8_USCALED_Z24_UNORM;
boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM ||
format == PIPE_FORMAT_RGTC1_SNORM;
boolean is_ati2n = format == PIPE_FORMAT_RGTC2_UNORM ||
format == PIPE_FORMAT_RGTC2_SNORM;
+ boolean is_half_float = format == PIPE_FORMAT_R16_FLOAT ||
+ format == PIPE_FORMAT_R16G16_FLOAT ||
+ format == PIPE_FORMAT_R16G16B16_FLOAT ||
+ format == PIPE_FORMAT_R16G16B16A16_FLOAT;
if (target >= PIPE_MAX_TEXTURE_TYPES) {
fprintf(stderr, "r300: Implementation error: Received bogus texture "
retval |= PIPE_BIND_DEPTH_STENCIL;
}
+ /* Check vertex buffer format support. */
+ if (usage & PIPE_BIND_VERTEX_BUFFER &&
+ /* Half float is supported on >= RV350. */
+ (is_rv350 || !is_half_float) &&
+ r300_translate_vertex_data_type(format) != R300_INVALID_FORMAT) {
+ retval |= PIPE_BIND_VERTEX_BUFFER;
+ }
+
return retval == usage;
}
for (i = 0; i < velems->count; i++) {
format = velems->velem[i].src_format;
- type = r300_translate_vertex_data_type(format) |
- (i << R300_DST_VEC_LOC_SHIFT);
+ type = r300_translate_vertex_data_type(format);
+ if (type == R300_INVALID_FORMAT) {
+ fprintf(stderr, "r300: Bad vertex format %s.\n",
+ util_format_short_name(format));
+ assert(0);
+ abort();
+ }
+
+ type |= i << R300_DST_VEC_LOC_SHIFT;
swizzle = r300_translate_vertex_data_swizzle(format);
if (i & 1) {
format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
/* Obtain the type of data in this attribute. */
- type = r300_translate_vertex_data_type(format) |
- vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT;
+ type = r300_translate_vertex_data_type(format);
+ if (type == R300_INVALID_FORMAT) {
+ fprintf(stderr, "r300: Bad vertex format %s.\n",
+ util_format_short_name(format));
+ assert(0);
+ abort();
+ }
+
+ type |= vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT;
/* Obtain the swizzle for this attribute. Note that the default
* swizzle in the hardware is not XYZW! */
desc = util_format_description(format);
if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
- fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_short_name(format),
- __FUNCTION__, __LINE__);
- assert(0);
- abort();
+ return R300_INVALID_FORMAT;
}
switch (desc->channel[0].type) {
case UTIL_FORMAT_TYPE_FLOAT:
switch (desc->channel[0].size) {
case 16:
- /* XXX Supported only on RV350 and later. */
+ /* Supported only on RV350 and later. */
if (desc->nr_channels > 2) {
result = R300_DATA_TYPE_FLT16_4;
} else {
result = R300_DATA_TYPE_FLOAT_1 + (desc->nr_channels - 1);
break;
default:
- fprintf(stderr, "r300: Bad format %s in %s:%d\n",
- util_format_short_name(format), __FUNCTION__, __LINE__);
- assert(0);
- abort();
+ return R300_INVALID_FORMAT;
}
break;
/* Unsigned ints */
}
break;
default:
- fprintf(stderr, "r300: Bad format %s in %s:%d\n",
- util_format_short_name(format), __FUNCTION__, __LINE__);
- fprintf(stderr, "r300: desc->channel[0].size == %d\n",
- desc->channel[0].size);
- assert(0);
- abort();
+ return R300_INVALID_FORMAT;
}
break;
default:
- fprintf(stderr, "r300: Bad format %s in %s:%d\n",
- util_format_short_name(format), __FUNCTION__, __LINE__);
- assert(0);
- abort();
+ return R300_INVALID_FORMAT;
}
if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {