summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorMichel Dänzer <daenzer@vmware.com>2009-06-04 08:42:29 +0200
committerDave Airlie <airlied@redhat.com>2009-06-07 16:40:09 +1000
commite2aedfa62079ff1a333e1f4e56faea303cc36edb (patch)
treef7ed595c27a397c3a72536a914910741a3f93c57 /src/mesa/drivers/dri
parent58982f8af1496c4860fb7bf3e815977ed4a753ff (diff)
r300: Endianness fixes for recent vertex path changes.
Signed-off-by: Maciej Cencora <m.cencora@gmail.com>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/r300/r300_draw.c38
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c8
2 files changed, 37 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c
index 684b1d0ef8..cc5650fb7c 100644
--- a/src/mesa/drivers/dri/r300/r300_draw.c
+++ b/src/mesa/drivers/dri/r300/r300_draw.c
@@ -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);
diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
index adda92467a..dfbd79a389 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -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);
}