summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2004-06-03 13:54:20 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2004-06-03 13:54:20 +0000
commitae27f9a6855f04892eacab307b4f0da2ac881b84 (patch)
tree45b8a9c444b930560aad86adf6f9c194119ffab2
parent80704437d6253bc203040b95ff38e7ce01e2b570 (diff)
downloadmesa_20040309_branch.tar.gz
Fix problems when sizeof(Node) != sizeof(float)mesa_20040309_branch
-rw-r--r--src/mesa/main/dlist.c160
1 files changed, 78 insertions, 82 deletions
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 26bf76a0077..b4a6ec42664 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -618,11 +618,7 @@ static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
/***** Public *****/
/**********************************************************************/
-/**
- * Do one-time initialiazations for display lists.
- */
-void
-_mesa_init_lists( void )
+void _mesa_init_lists( void )
{
static int init_flag = 0;
@@ -793,32 +789,6 @@ _mesa_init_lists( void )
}
-
-/**
- * Wrapper for _mesa_unpack_image() that handles pixel buffer objects.
- * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
- */
-static GLvoid *
-unpack_image( GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *unpack )
-{
- if (unpack->BufferObj->Name == 0) {
- /* no PBO */
- return _mesa_unpack_image(width, height, depth, format, type,
- pixels, unpack);
- }
- else if (_mesa_validate_pbo_access(unpack, width, height, depth, format,
- type, pixels)) {
- const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
- return _mesa_unpack_image(width, height, depth, format, type,
- src, unpack);
- }
- /* bad access! */
- return NULL;
-}
-
-
/*
* Allocate space for a display list instruction.
* \param opcode - type of instruction
@@ -1285,8 +1255,8 @@ static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
format, type, table );
}
else {
- GLvoid *image = unpack_image(width, 1, 1, format, type, table,
- &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
+ &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
@@ -1374,8 +1344,8 @@ static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei
const GLvoid *table)
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(count, 1, 1, format, type, table,
- &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
+ &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
@@ -1445,8 +1415,8 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
GLenum format, GLenum type, const GLvoid *filter)
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(width, 1, 1, format, type, filter,
- &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
+ &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
@@ -1474,8 +1444,8 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
GLenum type, const GLvoid *filter)
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(width, height, 1, format, type, filter,
- &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
+ &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
@@ -1839,8 +1809,8 @@ static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- GLvoid *image = unpack_image(width, height, 1, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
+ pixels, &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
@@ -3395,8 +3365,8 @@ static void GLAPIENTRY save_TexImage1D( GLenum target,
border, format, type, pixels );
}
else {
- GLvoid *image = unpack_image(width, 1, 1, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
+ pixels, &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
@@ -3434,8 +3404,8 @@ static void GLAPIENTRY save_TexImage2D( GLenum target,
height, border, format, type, pixels );
}
else {
- GLvoid *image = unpack_image(width, height, 1, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
+ pixels, &ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
@@ -3476,8 +3446,8 @@ static void GLAPIENTRY save_TexImage3D( GLenum target,
}
else {
Node *n;
- GLvoid *image = unpack_image(width, height, depth, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
+ pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
if (n) {
@@ -3509,8 +3479,8 @@ static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xof
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- GLvoid *image = unpack_image(width, 1, 1, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
+ pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
if (n) {
@@ -3540,8 +3510,8 @@ static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- GLvoid *image = unpack_image(width, height, 1, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
+ pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
if (n) {
@@ -3573,8 +3543,8 @@ static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- GLvoid *image = unpack_image(width, height, depth, format, type,
- pixels, &ctx->Unpack);
+ GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
+ pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
if (n) {
@@ -5313,8 +5283,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_BITMAP:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
ctx->Unpack = save; /* restore */
@@ -5384,8 +5354,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_COLOR_TABLE:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
n[5].e, n[6].data );
ctx->Unpack = save; /* restore */
@@ -5413,8 +5383,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_COLOR_SUB_TABLE:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
n[4].e, n[5].e, n[6].data );
ctx->Unpack = save; /* restore */
@@ -5422,8 +5392,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_CONVOLUTION_FILTER_1D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
n[4].e, n[5].e, n[6].data );
ctx->Unpack = save; /* restore */
@@ -5431,8 +5401,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_CONVOLUTION_FILTER_2D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
n[4].i, n[5].e, n[6].e, n[7].data );
ctx->Unpack = save; /* restore */
@@ -5516,8 +5486,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_DRAW_PIXELS:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
n[5].data );
ctx->Unpack = save; /* restore */
@@ -5785,8 +5755,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_TEX_IMAGE1D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->TexImage1D)(
n[1].e, /* target */
n[2].i, /* level */
@@ -5801,8 +5771,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_TEX_IMAGE2D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->TexImage2D)(
n[1].e, /* target */
n[2].i, /* level */
@@ -5818,8 +5788,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_TEX_IMAGE3D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->TexImage3D)(
n[1].e, /* target */
n[2].i, /* level */
@@ -5836,8 +5806,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_TEX_SUB_IMAGE1D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
n[4].i, n[5].e,
n[6].e, n[7].data );
@@ -5846,8 +5816,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_TEX_SUB_IMAGE2D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
n[4].i, n[5].e,
n[6].i, n[7].e, n[8].e, n[9].data );
@@ -5856,8 +5826,8 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_TEX_SUB_IMAGE3D:
{
- const struct gl_pixelstore_attrib save = ctx->Unpack;
- ctx->Unpack = ctx->DefaultPacking;
+ struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
n[4].i, n[5].i, n[6].i, n[7].i,
n[8].i, n[9].e, n[10].e,
@@ -5980,16 +5950,42 @@ execute_list( GLcontext *ctx, GLuint list )
(*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f);
break;
case OPCODE_ATTR_2F:
- (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
+ /* Really shouldn't have to do this - the Node structure
+ * is convenient, but it would be better to store the data
+ * packed appropriately so that it can be sent directly
+ * on. With x86_64 becoming common, this will start to
+ * matter more.
+ */
+ if (sizeof(Node)==sizeof(GLfloat))
+ (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
+ else
+ (*ctx->Exec->VertexAttrib2fNV)(n[1].e, n[2].f, n[3].f);
break;
case OPCODE_ATTR_3F:
- (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
+ if (sizeof(Node)==sizeof(GLfloat))
+ (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
+ else
+ (*ctx->Exec->VertexAttrib3fNV)(n[1].e, n[2].f, n[3].f,
+ n[4].f);
break;
case OPCODE_ATTR_4F:
- (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
+ if (sizeof(Node)==sizeof(GLfloat))
+ (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
+ else
+ (*ctx->Exec->VertexAttrib4fNV)(n[1].e, n[2].f, n[3].f,
+ n[4].f, n[5].f);
break;
case OPCODE_MATERIAL:
- (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
+ if (sizeof(Node)==sizeof(GLfloat))
+ (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
+ else {
+ GLfloat f[4];
+ f[0] = n[3].f;
+ f[1] = n[4].f;
+ f[2] = n[5].f;
+ f[3] = n[6].f;
+ (*ctx->Exec->Materialfv)(n[1].e, n[2].e, f);
+ }
break;
case OPCODE_INDEX:
(*ctx->Exec->Indexi)(n[1].i);
@@ -6010,7 +6006,7 @@ execute_list( GLcontext *ctx, GLuint list )
(*ctx->Exec->EvalCoord1f)(n[1].f);
break;
case OPCODE_EVAL_C2:
- (*ctx->Exec->EvalCoord2fv)(&n[1].f);
+ (*ctx->Exec->EvalCoord2f)(n[1].f, n[2].f);
break;
case OPCODE_EVAL_P1:
(*ctx->Exec->EvalPoint1)(n[1].i);