summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-03-05 22:40:10 +0000
committerBrian Paul <[email protected]>2001-03-05 22:40:10 +0000
commitac859a4cbdd55aa51275ab8ed44e67b0c5ba71db (patch)
treec3c34e54aaf7dc2bf1298a73063cba1819f26624 /src/mesa/drivers/common
parent75280a2c742ee241d392618a3b29548fce1520a9 (diff)
fixed segfaults when tex unit 1 enabled, but not unit 0 (conform)
Diffstat (limited to 'src/mesa/drivers/common')
-rw-r--r--src/mesa/drivers/common/t_dd_vbtmp.h276
1 files changed, 160 insertions, 116 deletions
diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h
index 4b7c1cb9f0f..a13c6dc680d 100644
--- a/src/mesa/drivers/common/t_dd_vbtmp.h
+++ b/src/mesa/drivers/common/t_dd_vbtmp.h
@@ -112,8 +112,8 @@ static void TAG(emit)( GLcontext *ctx,
GLuint stride )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLfloat (*tc0)[4], (*tc1)[4], *fog;
- GLfloat (*tc2)[4], (*tc3)[4];
+ GLfloat (*tc0)[4], (*tc1)[4], (*tc2)[4], (*tc3)[4];
+ GLfloat *fog;
GLubyte (*col)[4], (*spec)[4];
GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride;
GLuint tc2_stride, tc3_stride;
@@ -138,34 +138,62 @@ static void TAG(emit)( GLcontext *ctx,
if (DO_TEX3) {
const GLuint t3 = GET_TEXSOURCE(3);
- tc3 = VB->TexCoordPtr[t3]->data;
- tc3_stride = VB->TexCoordPtr[t3]->stride;
- if (DO_PTEX)
- tc3_size = VB->TexCoordPtr[t3]->size;
+ if (VB->TexCoordPtr[t3]) {
+ tc3 = VB->TexCoordPtr[t3]->data;
+ tc3_stride = VB->TexCoordPtr[t3]->stride;
+ if (DO_PTEX)
+ tc3_size = VB->TexCoordPtr[t3]->size;
+ }
+ else {
+ tc3 = NULL;
+ tc3_stride = 0; /* just to silence warnings */
+ tc3_size = 0;
+ }
}
if (DO_TEX2) {
const GLuint t2 = GET_TEXSOURCE(2);
- tc2 = VB->TexCoordPtr[t2]->data;
- tc2_stride = VB->TexCoordPtr[t2]->stride;
- if (DO_PTEX)
- tc2_size = VB->TexCoordPtr[t2]->size;
+ if (VB->TexCoordPtr[t2]) {
+ tc2 = VB->TexCoordPtr[t2]->data;
+ tc2_stride = VB->TexCoordPtr[t2]->stride;
+ if (DO_PTEX)
+ tc2_size = VB->TexCoordPtr[t2]->size;
+ }
+ else {
+ tc2 = NULL;
+ tc2_stride = 0;
+ tc2_size = 0;
+ }
}
if (DO_TEX1) {
const GLuint t1 = GET_TEXSOURCE(1);
- tc1 = VB->TexCoordPtr[t1]->data;
- tc1_stride = VB->TexCoordPtr[t1]->stride;
- if (DO_PTEX)
- tc1_size = VB->TexCoordPtr[t1]->size;
+ if (VB->TexCoordPtr[t1]) {
+ tc1 = VB->TexCoordPtr[t1]->data;
+ tc1_stride = VB->TexCoordPtr[t1]->stride;
+ if (DO_PTEX)
+ tc1_size = VB->TexCoordPtr[t1]->size;
+ }
+ else {
+ tc1 = NULL;
+ tc1_stride = 0;
+ tc1_size = 0;
+ }
}
if (DO_TEX0) {
const GLuint t0 = GET_TEXSOURCE(0);
- tc0_stride = VB->TexCoordPtr[t0]->stride;
- tc0 = VB->TexCoordPtr[t0]->data;
- if (DO_PTEX)
- tc0_size = VB->TexCoordPtr[t0]->size;
+ if (VB->TexCoordPtr[t0]) {
+ tc0_stride = VB->TexCoordPtr[t0]->stride;
+ tc0 = VB->TexCoordPtr[t0]->data;
+ if (DO_PTEX)
+ tc0_size = VB->TexCoordPtr[t0]->size;
+ }
+ else {
+ tc0 = NULL;
+ tc0_stride = 0;
+ tc0_size = 0;
+ }
}
if (DO_RGBA) {
@@ -187,15 +215,19 @@ static void TAG(emit)( GLcontext *ctx,
/* May have nonstandard strides:
*/
if (start) {
- coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
+ coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
if (DO_TEX0)
- tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
- if (DO_TEX1)
- tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
- if (DO_TEX2)
- tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + start * tc2_stride);
- if (DO_TEX3)
- tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + start * tc3_stride);
+ if (tc0)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (DO_TEX1)
+ if (tc1)
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (DO_TEX2)
+ if (tc2)
+ tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + start * tc2_stride);
+ if (DO_TEX3)
+ if (tc3)
+ tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + start * tc3_stride);
if (DO_RGBA)
STRIDE_4UB(col, start * col_stride);
if (DO_SPEC)
@@ -237,71 +269,79 @@ static void TAG(emit)( GLcontext *ctx,
STRIDE_F(fog, fog_stride);
}
if (DO_TEX0) {
- v->v.u0 = tc0[0][0];
- v->v.v0 = tc0[0][1];
- if (DO_PTEX) {
- if (HAVE_PTEX_VERTICES) {
- if (tc0_size == 4)
- v->pv.q0 = tc0[0][3];
- else
- v->pv.q0 = 1.0;
- }
- else if (tc0_size == 4) {
- float rhw = 1.0 / tc0[0][3];
- v->v.w *= tc0[0][3];
- v->v.u0 *= rhw;
- v->v.v0 *= rhw;
- }
- }
- tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ if (tc0) {
+ v->v.u0 = tc0[0][0];
+ v->v.v0 = tc0[0][1];
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ if (tc0_size == 4)
+ v->pv.q0 = tc0[0][3];
+ else
+ v->pv.q0 = 1.0;
+ }
+ else if (tc0_size == 4) {
+ float rhw = 1.0 / tc0[0][3];
+ v->v.w *= tc0[0][3];
+ v->v.u0 *= rhw;
+ v->v.v0 *= rhw;
+ }
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
}
if (DO_TEX1) {
- if (DO_PTEX) {
- v->pv.u1 = tc1[0][0];
- v->pv.v1 = tc1[0][1];
- if (tc1_size == 4)
- v->pv.q1 = tc1[0][3];
- else
- v->pv.q1 = 1.0;
- }
- else {
- v->v.u1 = tc1[0][0];
- v->v.v1 = tc1[0][1];
- }
- tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ if (tc1) {
+ if (DO_PTEX) {
+ v->pv.u1 = tc1[0][0];
+ v->pv.v1 = tc1[0][1];
+ if (tc1_size == 4)
+ v->pv.q1 = tc1[0][3];
+ else
+ v->pv.q1 = 1.0;
+ }
+ else {
+ v->v.u1 = tc1[0][0];
+ v->v.v1 = tc1[0][1];
+ }
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
}
else if (DO_PTEX) {
*(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
}
if (DO_TEX2) {
- if (DO_PTEX) {
- v->pv.u2 = tc2[0][0];
- v->pv.v2 = tc2[0][1];
- if (tc2_size == 4)
- v->pv.q2 = tc2[0][3];
- else
- v->pv.q2 = 1.0;
- }
- else {
- v->v.u2 = tc2[0][0];
- v->v.v2 = tc2[0][1];
- }
- tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + tc2_stride);
+ if (tc2) {
+ if (DO_PTEX) {
+ v->pv.u2 = tc2[0][0];
+ v->pv.v2 = tc2[0][1];
+ if (tc2_size == 4)
+ v->pv.q2 = tc2[0][3];
+ else
+ v->pv.q2 = 1.0;
+ }
+ else {
+ v->v.u2 = tc2[0][0];
+ v->v.v2 = tc2[0][1];
+ }
+ tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + tc2_stride);
+ }
}
if (DO_TEX3) {
- if (DO_PTEX) {
- v->pv.u3 = tc3[0][0];
- v->pv.v3 = tc3[0][1];
- if (tc3_size == 4)
- v->pv.q3 = tc3[0][3];
- else
- v->pv.q3 = 1.0;
- }
- else {
- v->v.u3 = tc3[0][0];
- v->v.v3 = tc3[0][1];
- }
- tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + tc3_stride);
+ if (tc3) {
+ if (DO_PTEX) {
+ v->pv.u3 = tc3[0][0];
+ v->pv.v3 = tc3[0][1];
+ if (tc3_size == 4)
+ v->pv.q3 = tc3[0][3];
+ else
+ v->pv.q3 = 1.0;
+ }
+ else {
+ v->v.u3 = tc3[0][0];
+ v->v.v3 = tc3[0][1];
+ }
+ tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + tc3_stride);
+ }
}
}
}
@@ -335,42 +375,46 @@ static void TAG(emit)( GLcontext *ctx,
v->v.specular.alpha = fog[i] * 255.0;
}
if (DO_TEX0) {
- if (DO_PTEX) {
- v->pv.u0 = tc0[i][0];
- v->pv.v0 = tc0[i][1];
- if (HAVE_PTEX_VERTICES) {
- if (tc0_size == 4)
- v->pv.q0 = tc0[i][3];
- else
- v->pv.q0 = 1.0;
-
- v->pv.q1 = 0; /* radeon */
- }
- else if (tc0_size == 4) {
- float rhw = 1.0 / tc0[i][3];
- v->v.w *= tc0[i][3];
- v->v.u0 *= rhw;
- v->v.v0 *= rhw;
- }
- }
- else {
- v->v.u0 = tc0[i][0];
- v->v.v0 = tc0[i][1];
- }
+ if (tc0) {
+ if (DO_PTEX) {
+ v->pv.u0 = tc0[i][0];
+ v->pv.v0 = tc0[i][1];
+ if (HAVE_PTEX_VERTICES) {
+ if (tc0_size == 4)
+ v->pv.q0 = tc0[i][3];
+ else
+ v->pv.q0 = 1.0;
+
+ v->pv.q1 = 0; /* radeon */
+ }
+ else if (tc0_size == 4) {
+ float rhw = 1.0 / tc0[i][3];
+ v->v.w *= tc0[i][3];
+ v->v.u0 *= rhw;
+ v->v.v0 *= rhw;
+ }
+ }
+ else {
+ v->v.u0 = tc0[i][0];
+ v->v.v0 = tc0[i][1];
+ }
+ }
}
if (DO_TEX1) {
- if (DO_PTEX) {
- v->pv.u1 = tc1[i][0];
- v->pv.v1 = tc1[i][1];
- if (tc1_size == 4)
- v->pv.q1 = tc1[i][3];
- else
- v->pv.q1 = 1.0;
- }
- else {
- v->v.u1 = tc1[i][0];
- v->v.v1 = tc1[i][1];
- }
+ if (tc1) {
+ if (DO_PTEX) {
+ v->pv.u1 = tc1[i][0];
+ v->pv.v1 = tc1[i][1];
+ if (tc1_size == 4)
+ v->pv.q1 = tc1[i][3];
+ else
+ v->pv.q1 = 1.0;
+ }
+ else {
+ v->v.u1 = tc1[i][0];
+ v->v.v1 = tc1[i][1];
+ }
+ }
}
}
}