r300: Endianness fixes for recent vertex path changes.

Signed-off-by: Maciej Cencora <m.cencora@gmail.com>
This commit is contained in:
Michel Dänzer 2009-06-04 08:42:29 +02:00 committed by Dave Airlie
parent 58982f8af1
commit e2aedfa620
2 changed files with 37 additions and 9 deletions

View file

@ -67,19 +67,43 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
if (mesa_ind_buf->type == GL_UNSIGNED_BYTE) {
GLubyte *in = (GLubyte *)src_ptr;
GLushort *out = _mesa_malloc(sizeof(GLushort) * mesa_ind_buf->count);
GLuint *out = _mesa_malloc(sizeof(GLushort) * ((mesa_ind_buf->count + 1) & ~1));
int i;
for (i = 0; i < mesa_ind_buf->count; ++i) {
out[i] = (GLushort) in[i];
ind_buf->ptr = out;
for (i = 0; i + 1 < mesa_ind_buf->count; i += 2) {
*out++ = in[i] | in[i + 1] << 16;
}
if (i < mesa_ind_buf->count) {
*out++ = in[i];
}
ind_buf->ptr = out;
ind_buf->free_needed = GL_TRUE;
ind_buf->is_32bit = GL_FALSE;
} else if (mesa_ind_buf->type == GL_UNSIGNED_SHORT) {
#if MESA_BIG_ENDIAN
GLushort *in = (GLushort *)src_ptr;
GLuint *out = _mesa_malloc(sizeof(GLushort) *
((mesa_ind_buf->count + 1) & ~1));
int i;
ind_buf->ptr = out;
for (i = 0; i + 1 < mesa_ind_buf->count; i += 2) {
*out++ = in[i] | in[i + 1] << 16;
}
if (i < mesa_ind_buf->count) {
*out++ = in[i];
}
ind_buf->free_needed = GL_TRUE;
#else
ind_buf->ptr = src_ptr;
ind_buf->free_needed = GL_FALSE;
#endif
ind_buf->is_32bit = GL_FALSE;
} else {
ind_buf->ptr = src_ptr;
@ -160,7 +184,11 @@ static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const st
stride = (input->StrideB == 0) ? getTypeSize(input->Type) * input->Size : input->StrideB;
if (input->Type == GL_DOUBLE || input->Type == GL_UNSIGNED_INT || input->Type == GL_INT || stride < 4){
if (input->Type == GL_DOUBLE || input->Type == GL_UNSIGNED_INT || input->Type == GL_INT ||
#if MESA_BIG_ENDIAN
getTypeSize(input->Type) != 4 ||
#endif
stride < 4) {
if (RADEON_DEBUG & DEBUG_FALLBACKS) {
fprintf(stderr, "%s: Converting vertex attributes, attribute data format %x,", __FUNCTION__, input->Type);
fprintf(stderr, "stride %d, components %d\n", stride, input->Size);

View file

@ -176,15 +176,15 @@ static void r300EmitElts(GLcontext * ctx, unsigned long n_elts)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
void *out;
GLbyte el_size;
GLuint size;
el_size = rmesa->ind_buf.is_32bit ? 4 : 2;
size = ((rmesa->ind_buf.is_32bit ? 4 : 2) * n_elts + 3) & ~3;
radeonAllocDmaRegion(&rmesa->radeon, &rmesa->radeon.tcl.elt_dma_bo,
&rmesa->radeon.tcl.elt_dma_offset, n_elts * el_size, 4);
&rmesa->radeon.tcl.elt_dma_offset, size, 4);
radeon_bo_map(rmesa->radeon.tcl.elt_dma_bo, 1);
out = rmesa->radeon.tcl.elt_dma_bo->ptr + rmesa->radeon.tcl.elt_dma_offset;
memcpy(out, rmesa->ind_buf.ptr, n_elts * el_size);
memcpy(out, rmesa->ind_buf.ptr, size);
radeon_bo_unmap(rmesa->radeon.tcl.elt_dma_bo);
}