if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_FB_PHYSICAL,
&nmesa->vram_phys))
return GL_FALSE;
+ if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_FB_SIZE,
+ &nmesa->vram_size))
+ return GL_FALSE;
if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_PHYSICAL,
&nmesa->agp_phys))
return GL_FALSE;
+ if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_SIZE,
+ &nmesa->agp_size))
+ return GL_FALSE;
if (!nouveauFifoInit(nmesa))
return GL_FALSE;
nouveauObjectInit(nmesa);
nouveauShaderInitFuncs(ctx);
/* Install Mesa's fixed-function texenv shader support */
if (nmesa->screen->card->type >= NV_40)
- ctx->_MaintainTexEnvProgram = GL_TRUE;
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
/* Initialize the swrast */
_swrast_CreateContext( ctx );
#include "glheader.h"
#include "macros.h"
#include "enums.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
-#include "program.h"
-#include "program_instruction.h"
#include "r300_context.h"
#include "r300_fragprog.h"
#include "r300_reg.h"
cnstv[3] = 0.2225; // weight
rp->const_sin[0] = emit_const4fv(rp, cnstv);
- cnstv[0] = 0.5;
- cnstv[1] = -1.5;
+ cnstv[0] = 0.75;
+ cnstv[1] = 0.0;
cnstv[2] = 0.159154943; // 1/(2*PI)
cnstv[3] = 6.283185307; // 2*PI
rp->const_sin[1] = emit_const4fv(rp, cnstv);
struct gl_fragment_program *mp = &rp->mesa_program;
const struct prog_instruction *inst = mp->Base.Instructions;
struct prog_instruction *fpi;
- GLuint src[3], dest, temp;
+ GLuint src[3], dest, temp[2];
GLuint cnst;
int flags, mask = 0;
GLfloat cnstv[4] = {0.0, 0.0, 0.0, 0.0};
/*
* cos using a parabola (see SIN):
* cos(x):
- * x += PI/2
- * x = (x/(2*PI))+0.5
+ * x = (x/(2*PI))+0.75
* x = frac(x)
* x = (x*2*PI)-PI
* result = sin(x)
*/
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
make_sin_const(rp);
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
/* add 0.5*PI and do range reduction */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(rp->const_sin[0], Z, Z, Z, Z), //PI
- pfs_half,
- swizzle(keep(src[0]), X, X, X, X),
- 0);
-
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ swizzle(src[0], X, X, X, X),
swizzle(rp->const_sin[1], Z, Z, Z, Z),
- pfs_half,
+ swizzle(rp->const_sin[1], X, X, X, X),
0);
- emit_arith(rp, PFS_OP_FRC, temp, WRITEMASK_X,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_FRC, temp[0], WRITEMASK_X,
+ swizzle(temp[0], X, X, X, X),
undef,
undef,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z,
+ swizzle(temp[0], X, X, X, X),
swizzle(rp->const_sin[1], W, W, W, W), //2*PI
negate(swizzle(rp->const_sin[0], Z, Z, Z, Z)), //-PI
0);
/* SIN */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(temp, Z, Z, Z, Z),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[0], Z, Z, Z, Z),
rp->const_sin[0],
pfs_zero,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(temp, Z, Z, Z, Z)),
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ swizzle(temp[0], Y, Y, Y, Y),
+ absolute(swizzle(temp[0], Z, Z, Z, Z)),
+ swizzle(temp[0], X, X, X, X),
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Y,
- swizzle(temp, X, X, X, X),
- absolute(swizzle(temp, X, X, X, X)),
- negate(swizzle(temp, X, X, X, X)),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Y,
+ swizzle(temp[0], X, X, X, X),
+ absolute(swizzle(temp[0], X, X, X, X)),
+ negate(swizzle(temp[0], X, X, X, X)),
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- swizzle(temp, Y, Y, Y, Y),
+ swizzle(temp[0], Y, Y, Y, Y),
swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, X, X, X, X),
+ swizzle(temp[0], X, X, X, X),
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_DP3:
src[0] = t_src(rp, fpi->SrcReg[0]);
* DP4 dest, temp, src1
*/
#if 0
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
src[0].s_swz = SWIZZLE_ONE;
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
src[0], pfs_one, pfs_zero,
0);
emit_arith(rp, PFS_OP_DP4, dest, mask,
- temp, src[1], undef,
+ temp[0], src[1], undef,
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
#else
emit_arith(rp, PFS_OP_DP4, dest, mask,
swizzle(src[0], X, Y, Z, ONE), src[1],
break;
case OPCODE_FLR:
src[0] = t_src(rp, fpi->SrcReg[0]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* FRC temp, src0
* MAD dest, src0, 1.0, -temp
*/
- emit_arith(rp, PFS_OP_FRC, temp, mask,
+ emit_arith(rp, PFS_OP_FRC, temp[0], mask,
keep(src[0]), undef, undef,
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- src[0], pfs_one, negate(temp),
+ src[0], pfs_one, negate(temp[0]),
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_FRC:
src[0] = t_src(rp, fpi->SrcReg[0]);
*/
cnstv[0] = cnstv[1] = cnstv[2] = cnstv[3] = 0.50001;
src[0] = t_src(rp, fpi->SrcReg[0]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
cnst = emit_const4fv(rp, cnstv);
- emit_arith(rp, PFS_OP_CMP, temp,
+ emit_arith(rp, PFS_OP_CMP, temp[0],
WRITEMASK_X | WRITEMASK_Y,
src[0], pfs_zero, src[0], flags);
- emit_arith(rp, PFS_OP_MIN, temp, WRITEMASK_Z,
+ emit_arith(rp, PFS_OP_MIN, temp[0], WRITEMASK_Z,
swizzle(keep(src[0]), W, W, W, W),
cnst, undef, flags);
- emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W,
- swizzle(temp, Y, Y, Y, Y),
+ emit_arith(rp, PFS_OP_LG2, temp[0], WRITEMASK_W,
+ swizzle(temp[0], Y, Y, Y, Y),
undef, undef, flags);
- emit_arith(rp, PFS_OP_MAX, temp, WRITEMASK_Z,
- temp, negate(cnst), undef, flags);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- temp, swizzle(temp, Z, Z, Z, Z),
+ emit_arith(rp, PFS_OP_MAX, temp[0], WRITEMASK_Z,
+ temp[0], negate(cnst), undef, flags);
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W,
+ temp[0], swizzle(temp[0], Z, Z, Z, Z),
pfs_zero, flags);
- emit_arith(rp, PFS_OP_EX2, temp, WRITEMASK_W,
- temp, undef, undef, flags);
+ emit_arith(rp, PFS_OP_EX2, temp[0], WRITEMASK_W,
+ temp[0], undef, undef, flags);
emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_Y,
- swizzle(keep(temp), X, X, X, X),
+ swizzle(keep(temp[0]), X, X, X, X),
pfs_one, pfs_zero, flags);
#if 0
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- temp, pfs_one, pfs_half, flags);
- emit_arith(rp, PFS_OP_CMPH, temp, WRITEMASK_Z,
- swizzle(keep(temp), W, W, W, W),
- pfs_zero, swizzle(keep(temp), X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ temp[0], pfs_one, pfs_half, flags);
+ emit_arith(rp, PFS_OP_CMPH, temp[0], WRITEMASK_Z,
+ swizzle(keep(temp[0]), W, W, W, W),
+ pfs_zero, swizzle(keep(temp[0]), X, X, X, X),
flags);
#else
- emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_Z,
+ emit_arith(rp, PFS_OP_CMP, temp[0], WRITEMASK_Z,
pfs_zero,
- swizzle(keep(temp), W, W, W, W),
- negate(swizzle(keep(temp), X, X, X, X)),
+ swizzle(keep(temp[0]), W, W, W, W),
+ negate(swizzle(keep(temp[0]), X, X, X, X)),
flags);
#endif
emit_arith(rp, PFS_OP_CMP, dest, WRITEMASK_Z,
- pfs_zero, temp,
- negate(swizzle(keep(temp), Y, Y, Y, Y)),
+ pfs_zero, temp[0],
+ negate(swizzle(keep(temp[0]), Y, Y, Y, Y)),
flags);
emit_arith(rp, PFS_OP_MAD, dest,
WRITEMASK_X | WRITEMASK_W,
pfs_one,
pfs_zero,
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_LRP:
src[0] = t_src(rp, fpi->SrcReg[0]);
* MAD temp, -tmp0, tmp2, tmp2
* MAD result, tmp0, tmp1, temp
*/
- temp = get_temp_reg(rp);
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ temp[0] = get_temp_reg(rp);
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
negate(keep(src[0])), keep(src[2]), src[2],
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- src[0], src[1], temp,
+ src[0], src[1], temp[0],
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_MAD:
src[0] = t_src(rp, fpi->SrcReg[0]);
case OPCODE_POW:
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
src[1] = t_scalar_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
- emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W,
+ temp[0] = get_temp_reg(rp);
+ emit_arith(rp, PFS_OP_LG2, temp[0], WRITEMASK_W,
src[0], undef, undef,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- temp, src[1], pfs_zero,
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W,
+ temp[0], src[1], pfs_zero,
0);
emit_arith(rp, PFS_OP_EX2, dest, fpi->DstReg.WriteMask,
- temp, undef, undef,
+ temp[0], undef, undef,
0);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_RCP:
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
break;
case OPCODE_SCS:
/*
- * cos using a parabola (see SIN):
- * cos(x):
- * x += PI/2
- * x = (x/(2*PI))+0.5
- * x = frac(x)
- * x = (x*2*PI)-PI
- * result = sin(x)
+ * scs using a parabola :
+ * scs(x):
+ * result.x = sin(-abs(x)+0.5*PI) (cos)
+ * result.y = sin(x) (sin)
+ *
*/
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
+ temp[1] = get_temp_reg(rp);
make_sin_const(rp);
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
- /* add 0.5*PI and do range reduction */
+ /* x = -abs(x)+0.5*PI */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z,
+ swizzle(rp->const_sin[0], Z, Z, Z, Z), //PI
+ pfs_half,
+ negate(abs(swizzle(keep(src[0]), X, X, X, X))),
+ 0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X|WRITEMASK_Y,
- swizzle(rp->const_sin[0], Z, Z, Z, Z),
- rp->const_sin[1],
+ /* C*x (sin) */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W,
+ swizzle(rp->const_sin[0], Y, Y, Y, Y),
swizzle(keep(src[0]), X, X, X, X),
+ pfs_zero,
0);
- emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_W,
- swizzle(rp->const_sin[0], Z, Z, Z, Z),
- negate(pfs_half),
- swizzle(keep(src[0]), X, X, X, X),
+ /* B*x, C*x (cos) */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[0], Z, Z, Z, Z),
+ rp->const_sin[0],
+ pfs_zero,
0);
- emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_Z,
- swizzle(temp, X, X, X, X),
- swizzle(temp, Y, Y, Y, Y),
- swizzle(temp, W, W, W, W),
+ /* B*x (sin) */
+ emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_W,
+ swizzle(rp->const_sin[0], X, X, X, X),
+ keep(src[0]),
+ pfs_zero,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(temp, Z, Z, Z, Z),
- rp->const_sin[0],
- pfs_zero,
+ /* y = B*x + C*x*abs(x) (sin)*/
+ emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_Z,
+ absolute(src[0]),
+ swizzle(temp[0], W, W, W, W),
+ swizzle(temp[1], W, W, W, W),
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(temp, Z, Z, Z, Z)),
- swizzle(temp, X, X, X, X),
+ /* y = B*x + C*x*abs(x) (cos)*/
+ emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_W,
+ swizzle(temp[0], Y, Y, Y, Y),
+ absolute(swizzle(temp[0], Z, Z, Z, Z)),
+ swizzle(temp[0], X, X, X, X),
0);
- if(mask & WRITEMASK_Y)
- {
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(keep(src[0]), X, X, X, X),
- rp->const_sin[0],
- pfs_zero,
- 0);
-
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(keep(src[0]), X, X, X, X)),
- swizzle(temp, X, X, X, X),
- 0);
- }
+ /* y*abs(y) - y (cos), y*abs(y) - y (sin) */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[1], W, Z, Y, X),
+ absolute(swizzle(temp[1], W, Z, Y, X)),
+ negate(swizzle(temp[1], W, Z, Y, X)),
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z,
- swizzle(temp, W, W, W, W),
- absolute(swizzle(temp, W, W, W, W)),
- negate(swizzle(temp, W, W, W, W)),
0);
- emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_X,
- swizzle(temp, Z, Z, Z, Z),
+ /* dest.xy = mad(temp.xy, P, temp2.wz) */
+ emit_arith(rp, PFS_OP_MAD, dest, mask & (WRITEMASK_X | WRITEMASK_Y),
+ temp[0],
swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, W, W, W, W),
+ swizzle(temp[1], W, Z, Y, X),
flags);
- if(mask & WRITEMASK_Y)
- {
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- swizzle(temp, X, X, X, X),
- absolute(swizzle(temp, X, X, X, X)),
- negate(swizzle(temp, X, X, X, X)),
- 0);
-
- emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_Y,
- swizzle(temp, W, W, W, W),
- swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, X, X, X, X),
- flags);
- }
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
+ free_temp(rp, temp[1]);
break;
case OPCODE_SGE:
src[0] = t_src(rp, fpi->SrcReg[0]);
src[1] = t_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* temp = src0 - src1
* dest.c = (temp.c < 0.0) ? 0 : 1
*/
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
src[0], pfs_one, negate(src[1]),
0);
emit_arith(rp, PFS_OP_CMP, dest, mask,
- pfs_one, pfs_zero, temp,
+ pfs_one, pfs_zero, temp[0],
0);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_SIN:
/*
* itself squared.
*/
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
make_sin_const(rp);
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
+
/* do range reduction */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
swizzle(keep(src[0]), X, X, X, X),
swizzle(rp->const_sin[1], Z, Z, Z, Z),
pfs_half,
0);
- emit_arith(rp, PFS_OP_FRC, temp, WRITEMASK_X,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_FRC, temp[0], WRITEMASK_X,
+ swizzle(temp[0], X, X, X, X),
undef,
undef,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z,
+ swizzle(temp[0], X, X, X, X),
swizzle(rp->const_sin[1], W, W, W, W), //2*PI
negate(swizzle(rp->const_sin[0], Z, Z, Z, Z)), //PI
0);
/* SIN */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(temp, Z, Z, Z, Z),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[0], Z, Z, Z, Z),
rp->const_sin[0],
pfs_zero,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(temp, Z, Z, Z, Z)),
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ swizzle(temp[0], Y, Y, Y, Y),
+ absolute(swizzle(temp[0], Z, Z, Z, Z)),
+ swizzle(temp[0], X, X, X, X),
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Y,
- swizzle(temp, X, X, X, X),
- absolute(swizzle(temp, X, X, X, X)),
- negate(swizzle(temp, X, X, X, X)),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Y,
+ swizzle(temp[0], X, X, X, X),
+ absolute(swizzle(temp[0], X, X, X, X)),
+ negate(swizzle(temp[0], X, X, X, X)),
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- swizzle(temp, Y, Y, Y, Y),
+ swizzle(temp[0], Y, Y, Y, Y),
swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, X, X, X, X),
+ swizzle(temp[0], X, X, X, X),
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_SLT:
src[0] = t_src(rp, fpi->SrcReg[0]);
src[1] = t_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* temp = src0 - src1
* dest.c = (temp.c < 0.0) ? 1 : 0
*/
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
src[0], pfs_one, negate(src[1]),
0);
emit_arith(rp, PFS_OP_CMP, dest, mask,
- pfs_zero, pfs_one, temp,
+ pfs_zero, pfs_one, temp[0],
0);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_SUB:
src[0] = t_src(rp, fpi->SrcReg[0]);
case OPCODE_XPD: {
src[0] = t_src(rp, fpi->SrcReg[0]);
src[1] = t_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* temp = src0.zxy * src1.yzx */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_XYZ,
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_XYZ,
swizzle(keep(src[0]), Z, X, Y, W),
swizzle(keep(src[1]), Y, Z, X, W),
pfs_zero,
emit_arith(rp, PFS_OP_MAD, dest, mask & WRITEMASK_XYZ,
swizzle(src[0], Y, Z, X, W),
swizzle(src[1], Z, X, Y, W),
- negate(temp),
+ negate(temp[0]),
flags);
/* cleanup */
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
}
default:
#include "api_arrayelt.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "texformat.h"
static void update_early_z(GLcontext *ctx)
{
- /* updates register 0x4f14
- if depth test is not enabled it should be 0x00000000
- if depth is enabled and alpha not it should be 0x00000001
- if depth and alpha is enabled it should be 0x00000000
+ /* updates register R300_RB3D_EARLY_Z (0x4F14)
+ if depth test is not enabled it should be R300_EARLY_Z_DISABLE
+ if depth is enabled and alpha not it should be R300_EARLY_Z_ENABLE
+ if depth and alpha is enabled it should be R300_EARLY_Z_DISABLE
*/
r300ContextPtr r300 = R300_CONTEXT(ctx);
R300_STATECHANGE(r300, unk4F10);
if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
/* disable early Z */
- r300->hw.unk4F10.cmd[2] = 0x00000000;
+ r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_DISABLE;
else {
if (ctx->Depth.Test && ctx->Depth.Func != GL_NEVER)
/* enable early Z */
- r300->hw.unk4F10.cmd[2] = 0x00000001;
+ r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_ENABLE;
else
/* disable early Z */
- r300->hw.unk4F10.cmd[2] = 0x00000000;
+ r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_DISABLE;
}
}
#endif
}
-static void r300FetchStateParameter(GLcontext *ctx, const enum state_index state[],
- GLfloat *value)
+static void
+r300FetchStateParameter(GLcontext *ctx,
+ const gl_state_index state[STATE_LENGTH],
+ GLfloat *value)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLcontext *ctx;
ctx = rmesa->radeon.glCtx;
- #ifdef CB_DPATH
r300UpdateTextureState(ctx);
- #endif
r300SetupPixelShader(rmesa);
r300_setup_textures(ctx);
r300UpdateStateParameters(ctx, new_state);
- #ifndef CB_DPATH
- /* Go inefficiency! */
- r300ResetHwState(r300);
- #endif
#ifdef HW_VBOS
if(new_state & _NEW_ARRAY)
r300->state.VB.lock_uptodate = GL_FALSE;
#include "fbobject.h"
#include "feedback.h"
#include "fog.h"
+ #include "framebuffer.h"
#include "get.h"
#include "glthread.h"
#include "glapioffsets.h"
#include "math/m_xform.h"
#include "math/mathmod.h"
#endif
-#include "shaderobjects.h"
+#include "shader_api.h"
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
ss->ArrayObjects = _mesa_NewHashTable();
#if FEATURE_ARB_shader_objects
- ss->GL2Objects = _mesa_NewHashTable ();
+ ss->ShaderObjects = _mesa_NewHashTable();
#endif
ss->Default1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D);
_mesa_DeleteHashTable (ss->ArrayObjects);
#if FEATURE_ARB_shader_objects
- if (ss->GL2Objects)
- _mesa_DeleteHashTable (ss->GL2Objects);
+ if (ss->ShaderObjects)
+ _mesa_DeleteHashTable (ss->ShaderObjects);
#endif
#if FEATURE_EXT_framebuffer_object
}
/**
- * Callback for deleting an shader object. Called by _mesa_HashDeleteAll().
+ * Callback for deleting shader and shader programs objects.
+ * Called by _mesa_HashDeleteAll().
*/
static void
-delete_shaderobj_cb(GLuint id, void *data, void *userData)
+delete_shader_cb(GLuint id, void *data, void *userData)
{
- /* XXX probably need to fix this */
- _mesa_free(data);
+ GLcontext *ctx = (GLcontext *) userData;
+ struct gl_shader *sh = (struct gl_shader *) data;
+ if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) {
+ _mesa_free_shader(ctx, sh);
+ }
+ else {
+ struct gl_shader_program *shProg = (struct gl_shader_program *) data;
+ ASSERT(shProg->Type == GL_SHADER_PROGRAM);
+ _mesa_free_shader_program(ctx, shProg);
+ }
}
_mesa_DeleteHashTable(ss->ArrayObjects);
#if FEATURE_ARB_shader_objects
- _mesa_HashDeleteAll(ss->GL2Objects, delete_shaderobj_cb, ctx);
- _mesa_DeleteHashTable(ss->GL2Objects);
+ _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx);
+ _mesa_DeleteHashTable(ss->ShaderObjects);
#endif
#if FEATURE_EXT_framebuffer_object
* Initialize fields of gl_current_attrib (aka ctx->Current.*)
*/
static void
-_mesa_init_current( GLcontext *ctx )
+_mesa_init_current(GLcontext *ctx)
{
GLuint i;
* some of these values (such as number of texture units).
*/
static void
-_mesa_init_constants( GLcontext *ctx )
+_mesa_init_constants(GLcontext *ctx)
{
assert(ctx);
ctx->Const.VertexProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
ctx->Const.VertexProgram.MaxEnvParams = MAX_NV_VERTEX_PROGRAM_PARAMS;
ctx->Const.VertexProgram.MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
- ctx->Const.VertexProgram.MaxUniformComponents = MAX_VERTEX_UNIFORM_COMPONENTS;
+ ctx->Const.VertexProgram.MaxUniformComponents = 4 * MAX_UNIFORMS;
init_natives(&ctx->Const.VertexProgram);
#endif
+
#if FEATURE_ARB_fragment_program
ctx->Const.FragmentProgram.MaxInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS;
ctx->Const.FragmentProgram.MaxAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
ctx->Const.FragmentProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
ctx->Const.FragmentProgram.MaxEnvParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
ctx->Const.FragmentProgram.MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
- ctx->Const.FragmentProgram.MaxUniformComponents = MAX_FRAGMENT_UNIFORM_COMPONENTS;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 4 * MAX_UNIFORMS;
init_natives(&ctx->Const.FragmentProgram);
#endif
ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
#if FEATURE_ARB_vertex_shader
ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
- ctx->Const.MaxVaryingFloats = MAX_VARYING_FLOATS;
+ ctx->Const.MaxVarying = MAX_VARYING;
#endif
/* sanity checks */
ctx->Const.MaxTextureCoordUnits));
ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
ASSERT(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
+
+ ASSERT(MAX_NV_FRAGMENT_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
+ ASSERT(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
+ ASSERT(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX);
+ ASSERT(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX);
}
* functions for the more complex data structures.
*/
static GLboolean
-init_attrib_groups( GLcontext *ctx )
+init_attrib_groups(GLcontext *ctx)
{
assert(ctx);
_mesa_init_query( ctx );
_mesa_init_rastpos( ctx );
_mesa_init_scissor( ctx );
- _mesa_init_shaderobjects (ctx);
+ _mesa_init_shader_state( ctx );
_mesa_init_stencil( ctx );
_mesa_init_transform( ctx );
_mesa_init_varray( ctx );
* \param driverContext pointer to driver-specific context data
*/
GLboolean
-_mesa_initialize_context( GLcontext *ctx,
- const GLvisual *visual,
- GLcontext *share_list,
- const struct dd_function_table *driverFunctions,
- void *driverContext )
+_mesa_initialize_context(GLcontext *ctx,
+ const GLvisual *visual,
+ GLcontext *share_list,
+ const struct dd_function_table *driverFunctions,
+ void *driverContext)
{
ASSERT(driverContext);
assert(driverFunctions->NewTextureObject);
ctx->TnlModule.SwapCount = 0;
#endif
- ctx->_MaintainTexEnvProgram = (_mesa_getenv("MESA_TEX_PROG") != NULL);
- ctx->_UseTexEnvProgram = ctx->_MaintainTexEnvProgram;
-
- ctx->_MaintainTnlProgram = (_mesa_getenv("MESA_TNL_PROG") != NULL);
- if (ctx->_MaintainTnlProgram)
- ctx->_MaintainTexEnvProgram = 1; /* this is required... */
+ ctx->VertexProgram._MaintainTnlProgram
+ = (_mesa_getenv("MESA_TNL_PROG") != NULL);
+ if (ctx->VertexProgram._MaintainTnlProgram)
+ /* this is required... */
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+ else
+ ctx->FragmentProgram._MaintainTexEnvProgram
+ = (_mesa_getenv("MESA_TEX_PROG") != NULL);
ctx->FirstTimeCurrent = GL_TRUE;
* \return pointer to a new __GLcontextRec or NULL if error.
*/
GLcontext *
-_mesa_create_context( const GLvisual *visual,
- GLcontext *share_list,
- const struct dd_function_table *driverFunctions,
- void *driverContext )
-
+_mesa_create_context(const GLvisual *visual,
+ GLcontext *share_list,
+ const struct dd_function_table *driverFunctions,
+ void *driverContext)
{
GLcontext *ctx;
if (ctx == _mesa_get_current_context()) {
_mesa_make_current(NULL, NULL, NULL);
}
+ else {
+ /* unreference WinSysDraw/Read buffers */
+ _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
+ _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
+ _mesa_unreference_framebuffer(&ctx->DrawBuffer);
+ _mesa_unreference_framebuffer(&ctx->ReadBuffer);
+ }
_mesa_free_lighting_data( ctx );
_mesa_free_eval_data( ctx );
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
- #if 0
GET_CURRENT_CONTEXT(oldCtx);
- #endif
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(newCtx, "_mesa_make_current()\n");
}
}
+#if 0 /** XXX enable this someday */
+ if (oldCtx && oldCtx != newCtx) {
+ /* unbind old context's draw/read buffers */
+ if (oldCtx->DrawBuffer && oldCtx->DrawBuffer->Name == 0) {
+ oldCtx->DrawBuffer->RefCount--;
+ oldCtx->DrawBuffer = NULL;
+ }
+ if (oldCtx->ReadBuffer && oldCtx->ReadBuffer->Name == 0) {
+ oldCtx->ReadBuffer->RefCount--;
+ oldCtx->ReadBuffer = NULL;
+ }
+ if (oldCtx->WinSysDrawBuffer) {
+ ASSERT(oldCtx->WinSysDrawBuffer->Name == 0);
+ oldCtx->WinSysDrawBuffer->RefCount--;
+ oldCtx->WinSysDrawBuffer = NULL;
+ }
+ if (oldCtx->WinSysReadBuffer) {
+ ASSERT(oldCtx->WinSysReadBuffer->Name == 0);
+ oldCtx->WinSysReadBuffer->RefCount--;
+ oldCtx->WinSysReadBuffer = NULL;
+ }
+ }
+#endif
+
/* We used to call _glapi_check_multithread() here. Now do it in drivers */
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
+ if (oldCtx) {
+ _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer);
+ _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer);
+ }
+
if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
}
ASSERT(drawBuffer->Name == 0);
ASSERT(readBuffer->Name == 0);
- newCtx->WinSysDrawBuffer = drawBuffer;
- newCtx->WinSysReadBuffer = readBuffer;
+ _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
+ _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer);
/*
* Only set the context's Draw/ReadBuffer fields if they're NULL
* or not bound to a user-created FBO.
*/
if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
- newCtx->DrawBuffer = drawBuffer;
+ _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
}
if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
- newCtx->ReadBuffer = readBuffer;
+ _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
}
newCtx->NewState |= _NEW_BUFFERS;
/**
- * Get current context for the calling thread.
- *
- * \return pointer to the current GL context.
+ * \return pointer to the current GL context for this thread.
*
* Calls _glapi_get_context(). This isn't the fastest way to get the current
- * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in context.h.
+ * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in
+ * context.h.
*/
GLcontext *
_mesa_get_current_context( void )
return (GLcontext *) _glapi_get_context();
}
+
/**
* Get context's current API dispatch table.
*
* This is called via _mesa_error().
*/
void
-_mesa_record_error( GLcontext *ctx, GLenum error )
+_mesa_record_error(GLcontext *ctx, GLenum error)
{
if (!ctx)
return;
/* Call device driver's error handler, if any. This is used on the Mac. */
if (ctx->Driver.Error) {
- (*ctx->Driver.Error)( ctx );
+ ctx->Driver.Error(ctx);
}
}
+
/**
* Execute glFinish().
*
* dd_function_table::Finish driver callback, if not NULL.
*/
void GLAPIENTRY
-_mesa_Finish( void )
+_mesa_Finish(void)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (ctx->Driver.Finish) {
- (*ctx->Driver.Finish)( ctx );
+ ctx->Driver.Finish(ctx);
}
}
+
/**
* Execute glFlush().
*
* dd_function_table::Flush driver callback, if not NULL.
*/
void GLAPIENTRY
-_mesa_Flush( void )
+_mesa_Flush(void)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (ctx->Driver.Flush) {
- (*ctx->Driver.Flush)( ctx );
+ ctx->Driver.Flush(ctx);
}
}
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "bitset.h"
+/**
+ * Special, internal token
+ */
+#define GL_SHADER_PROGRAM 0x9999
+
+
/**
* Color channel data type.
*/
#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
/*@}*/
-/**
- * GLSL allows shader writers to allocate vertex result attributes (varyings) in
- * single float component granularity. This is in contrast to vertex / fragment
- * programs, where result attributes (actually texcoords) were allocated
- * in 4-component vectors of floats granularity.
- * For performance reasons, it would be optimal to stick with this scheme on a scalar
- * processor. Varyings will likely be allocated as 3-component vectors, so statistically
- * we win 2 floats.
- * The constant VARYINGS_PER_VECTOR tells us how much of float components we pack into
- * one result vector. For scalar processor it would be 1, for vector processor - 4.
- *
- * NOTE: Currently we pack varyings into vertex attributes.
- */
-#define VARYINGS_PER_VECTOR 2
-#define VARYING_EMIT_STYLE EMIT_2F
-#define MAX_VARYING_VECTORS ((MAX_VARYING_FLOATS + VARYINGS_PER_VECTOR - 1) / VARYINGS_PER_VECTOR)
/**
* Indexes for vertex program result attributes
#define VERT_RESULT_BFC0 13
#define VERT_RESULT_BFC1 14
#define VERT_RESULT_EDGE 15
-#define VERT_RESULT_MAX 16
+#define VERT_RESULT_VAR0 16 /**< shader varying */
+#define VERT_RESULT_MAX (VERT_RESULT_VAR0 + MAX_VARYING)
/*@}*/
FRAG_ATTRIB_TEX5 = 9,
FRAG_ATTRIB_TEX6 = 10,
FRAG_ATTRIB_TEX7 = 11,
- FRAG_ATTRIB_MAX = 12
+ FRAG_ATTRIB_VAR0 = 12, /**< shader varying */
+ FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
};
/**
#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
+#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0)
+
+#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U))
+#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V))
#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
FRAG_BIT_TEX1| \
/**
* Fragment program results
*/
-/*@{*/
-#define FRAG_RESULT_COLR 0
-#define FRAG_RESULT_COLH 1
-#define FRAG_RESULT_DEPR 2
-#define FRAG_RESULT_MAX 3
-/*@}*/
+enum
+{
+ FRAG_RESULT_COLR = 0,
+ FRAG_RESULT_COLH = 1,
+ FRAG_RESULT_DEPR = 2,
+ FRAG_RESULT_MAX = 3
+};
/**
/**
* Names of the various vertex/fragment program register files, etc.
+ *
* NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
* All values should fit in a 4-bit field.
+ *
+ * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM,
+ * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to
+ * be "uniform" variables since they can only be set outside glBegin/End.
+ * They're also all stored in the same Parameters array.
*/
enum register_file
{
- PROGRAM_TEMPORARY = 0,
- PROGRAM_LOCAL_PARAM = 1,
- PROGRAM_ENV_PARAM = 2,
- PROGRAM_STATE_VAR = 3,
- PROGRAM_INPUT = 4,
- PROGRAM_OUTPUT = 5,
- PROGRAM_NAMED_PARAM = 6,
- PROGRAM_CONSTANT = 7,
- PROGRAM_WRITE_ONLY = 8,
- PROGRAM_ADDRESS = 9,
- PROGRAM_UNDEFINED = 10, /* invalid value */
+ PROGRAM_TEMPORARY = 0, /**< machine->Temporary[] */
+ PROGRAM_LOCAL_PARAM = 1, /**< gl_program->LocalParams[] */
+ PROGRAM_ENV_PARAM = 2, /**< gl_program->Parameters[] */
+ PROGRAM_STATE_VAR = 3, /**< gl_program->Parameters[] */
+ PROGRAM_INPUT = 4, /**< machine->Inputs[] */
+ PROGRAM_OUTPUT = 5, /**< machine->Outputs[] */
+ PROGRAM_NAMED_PARAM = 6, /**< gl_program->Parameters[] */
+ PROGRAM_CONSTANT = 7, /**< gl_program->Parameters[] */
+ PROGRAM_UNIFORM = 8, /**< gl_program->Parameters[] */
+ PROGRAM_VARYING = 9, /**< machine->Inputs[]/Outputs[] */
+ PROGRAM_WRITE_ONLY = 10, /**< A dummy, write-only register */
+ PROGRAM_ADDRESS = 11, /**< machine->AddressReg */
+ PROGRAM_SAMPLER = 12, /**< for shader samplers, compile-time only */
+ PROGRAM_UNDEFINED = 13, /**< Invalid value */
PROGRAM_FILE_MAX
};
struct gl_program
{
GLuint Id;
- GLubyte *String; /**< Null-terminated program text */
+ GLubyte *String; /**< Null-terminated program text */
GLint RefCount;
- GLenum Target;
- GLenum Format; /**< String encoding format */
+ GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */
+ GLenum Format; /**< String encoding format */
GLboolean Resident;
struct prog_instruction *Instructions;
- GLbitfield InputsRead; /* Bitmask of which input regs are read */
- GLbitfield OutputsWritten; /* Bitmask of which output regs are written to */
+ GLbitfield InputsRead; /**< Bitmask of which input regs are read */
+ GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
+ GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
/** Named parameters, constants, etc. from program text */
struct gl_program_parameter_list *Parameters;
/** Numbered local parameters */
GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
+ /** Vertex/fragment shader varying vars */
+ struct gl_program_parameter_list *Varying;
+ /** Vertex program user-defined attributes */
+ struct gl_program_parameter_list *Attributes;
+
/** Logical counts */
/*@{*/
GLuint NumInstructions;
GLuint NumParameters;
GLuint NumAttributes;
GLuint NumAddressRegs;
+ GLuint NumAluInstructions;
+ GLuint NumTexInstructions;
+ GLuint NumTexIndirections;
/*@}*/
/** Native, actual h/w counts */
/*@{*/
GLuint NumNativeParameters;
GLuint NumNativeAttributes;
GLuint NumNativeAddressRegs;
+ GLuint NumNativeAluInstructions;
+ GLuint NumNativeTexInstructions;
+ GLuint NumNativeTexIndirections;
/*@}*/
};
struct gl_fragment_program
{
struct gl_program Base; /**< base class */
- GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
- GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
- GLuint NumTexInstructions;
- GLuint NumTexIndirections;
- GLuint NumNativeAluInstructions; /**< GL_ARB_fragment_program */
- GLuint NumNativeTexInstructions;
- GLuint NumNativeTexIndirections;
GLenum FogOption;
GLboolean UsesKill;
};
GLboolean _Enabled; /**< Enabled and valid program? */
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
- struct gl_vertex_program *Current; /**< ptr to currently bound program */
- const struct gl_vertex_program *_Current; /**< ptr to currently bound
- program, including internal
- (t_vp_build.c) programs */
+ struct gl_vertex_program *Current; /**< user-bound vertex program */
- GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /**< Env params */
+ /** Currently enabled and valid program (including internal programs
+ * and compiled shader programs).
+ */
+ struct gl_vertex_program *_Current;
+
+ GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
/* For GL_NV_vertex_program only: */
- GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
- GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
+ GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4];
+ GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4];
+
+ /** Should fixed-function T&L be implemented with a vertex prog? */
+ GLboolean _MaintainTnlProgram;
+
+ /** Program to emulate fixed-function T&L (see above) */
+ struct gl_vertex_program *_TnlProgram;
#if FEATURE_MESA_program_debug
GLprogramcallbackMESA Callback;
{
GLboolean Enabled; /**< User-set fragment program enable flag */
GLboolean _Enabled; /**< Fragment program enabled and valid? */
- GLboolean _Active; /**< Is a user program or internal program active? */
- struct gl_fragment_program *Current; /**< User-bound program */
- const struct gl_fragment_program *_Current; /**< currently active program
- (including internal programs) */
- GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /**< Env params */
+ struct gl_fragment_program *Current; /**< User-bound fragment program */
+
+ /** Currently enabled and valid program (including internal programs
+ * and compiled shader programs).
+ */
+ struct gl_fragment_program *_Current;
+
+ GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
+
+ /** Should fixed-function texturing be implemented with a fragment prog? */
+ GLboolean _MaintainTexEnvProgram;
+
+ /** Program to emulate fixed-function texture env/combine (see above) */
+ struct gl_fragment_program *_TexEnvProgram;
#if FEATURE_MESA_program_debug
GLprogramcallbackMESA Callback;
};
+
/**
- * Context state for vertex/fragment shaders.
+ * A GLSL shader object.
*/
-struct gl_shader_objects_state
+struct gl_shader
{
- struct gl2_program_intf **CurrentProgram;
- GLboolean _VertexShaderPresent;
- GLboolean _FragmentShaderPresent;
+ GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER (first field!) */
+ GLuint Name; /**< AKA the handle */
+ GLint RefCount; /**< Reference count */
+ GLboolean DeletePending;
+
+ const GLchar *Source; /**< Source code string */
+ GLboolean CompileStatus;
+ GLuint NumPrograms; /**< size of Programs[] array */
+ struct gl_program **Programs; /**< Post-compile assembly code */
+ GLchar *InfoLog;
+};
+
+
+/**
+ * A GLSL program object. Basically a linked collection of "shaders".
+ */
+struct gl_shader_program
+{
+ GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
+ GLuint Name; /**< aka handle or ID */
+ GLint RefCount; /**< Reference count */
+ GLboolean DeletePending;
+
+ GLuint NumShaders; /**< number of attached shaders */
+ struct gl_shader **Shaders; /**< List of attached the shaders */
+
+ /* post-link info: */
+ struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
+ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
+ struct gl_program_parameter_list *Uniforms; /**< Plus constants, etc */
+ struct gl_program_parameter_list *Varying;
+ struct gl_program_parameter_list *Attributes; /**< Vertex attributes */
+ GLboolean LinkStatus; /**< GL_LINK_STATUS */
+ GLboolean Validated;
+ GLchar *InfoLog;
+};
+
+
+/**
+ * Context state for GLSL vertex/fragment shaders.
+ */
+struct gl_shader_state
+{
+ struct gl_shader_program *CurrentProgram; /**< The user-bound program */
+ GLboolean EmitHighLevelInstructions; /**< Driver-selectable */
+ GLboolean EmitComments; /**< Driver-selectable */
};
#endif
#if FEATURE_ARB_shader_objects
- struct _mesa_HashTable *GL2Objects;
+ /** Table of both gl_shader and gl_shader_program objects */
+ struct _mesa_HashTable *ShaderObjects;
#endif
#if FEATURE_EXT_framebuffer_object
_glthread_Mutex Mutex; /**< for thread safety */
GLuint Name; /* if zero, this is a window system framebuffer */
GLint RefCount;
+ GLboolean DeletePending;
GLvisual Visual; /**< The framebuffer's visual.
Immutable if this is a window system buffer.
GLuint MaxRenderbufferSize;
/* GL_ARB_vertex_shader */
GLuint MaxVertexTextureImageUnits;
- GLuint MaxVaryingFloats;
+ GLuint MaxVarying;
};
/**
* A stack of matrices (projection, modelview, color, texture, etc).
*/
-struct matrix_stack
+struct gl_matrix_stack
{
GLmatrix *Top; /**< points into Stack */
GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
#define IMAGE_HISTOGRAM_BIT 0x200
#define IMAGE_MIN_MAX_BIT 0x400
#define IMAGE_CLAMP_BIT 0x800 /* extra */
+ #define IMAGE_RED_TO_LUMINANCE 0x1000
/** Pixel Transfer ops up to convolution */
/**
* State used during display list compilation and execution.
*/
-struct mesa_list_state
+struct gl_dlist_state
{
struct mesa_display_list *CallStack[MAX_LIST_NESTING];
GLuint CallDepth; /**< Current recursion calling depth */
struct dd_function_table Driver;
void *DriverCtx; /**< Points to device driver context/state */
- void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
/** Core/Driver constants */
struct gl_constants Const;
/** \name The various 4x4 matrix stacks */
/*@{*/
- struct matrix_stack ModelviewMatrixStack;
- struct matrix_stack ProjectionMatrixStack;
- struct matrix_stack ColorMatrixStack;
- struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
- struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
- struct matrix_stack *CurrentStack; /**< Points to one of the above stacks */
+ struct gl_matrix_stack ModelviewMatrixStack;
+ struct gl_matrix_stack ProjectionMatrixStack;
+ struct gl_matrix_stack ColorMatrixStack;
+ struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
+ struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
+ struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
/*@}*/
/** Combined modelview and projection matrix */
GLmatrix _ModelProjectMatrix;
/** \name Display lists */
- struct mesa_list_state ListState;
+ struct gl_dlist_state ListState;
GLboolean ExecuteFlag; /**< Execute GL commands? */
GLboolean CompileFlag; /**< Compile GL commands into display list? */
struct gl_fragment_program_state FragmentProgram; /**< GL_ARB/NV_vertex_program */
struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */
- struct gl_fragment_program *_TexEnvProgram; /**< Texture state as fragment program */
- struct gl_vertex_program *_TnlProgram; /**< Fixed func TNL state as vertex program */
-
- GLboolean _MaintainTnlProgram;
- GLboolean _MaintainTexEnvProgram;
- GLboolean _UseTexEnvProgram;
-
struct gl_query_state Query; /**< GL_ARB_occlusion_query */
- struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
+ struct gl_shader_state Shader; /**< GLSL shader object state */
/*@}*/
#if FEATURE_EXT_framebuffer_object
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "arbprogparse.h"
#include "grammar_mesa.h"
#include "program.h"
+#include "prog_parameter.h"
+#include "prog_statevars.h"
#include "context.h"
#include "macros.h"
#include "mtypes.h"
-#include "program_instruction.h"
+#include "prog_instruction.h"
/* For ARB programs, use the NV instruction limits */
switch (mat) {
case MATRIX_MODELVIEW:
- *matrix = STATE_MODELVIEW;
+ *matrix = STATE_MODELVIEW_MATRIX;
*matrix_idx = parse_integer (inst, Program);
if (*matrix_idx > 0) {
program_error(ctx, Program->Position,
break;
case MATRIX_PROJECTION:
- *matrix = STATE_PROJECTION;
+ *matrix = STATE_PROJECTION_MATRIX;
break;
case MATRIX_MVP:
- *matrix = STATE_MVP;
+ *matrix = STATE_MVP_MATRIX;
break;
case MATRIX_TEXTURE:
- *matrix = STATE_TEXTURE;
+ *matrix = STATE_TEXTURE_MATRIX;
*matrix_idx = parse_integer (inst, Program);
if (*matrix_idx >= (GLint) ctx->Const.MaxTextureUnits) {
program_error(ctx, Program->Position, "Invalid Texture Unit");
break;
case MATRIX_PROGRAM:
- *matrix = STATE_PROGRAM;
+ *matrix = STATE_PROGRAM_MATRIX;
*matrix_idx = parse_integer (inst, Program);
if (*matrix_idx >= (GLint) ctx->Const.MaxProgramMatrices) {
program_error(ctx, Program->Position, "Invalid Program Matrix");
*/
static GLuint
parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
- struct arb_program *Program, GLint * state_tokens)
+ struct arb_program *Program,
+ gl_state_index state_tokens[STATE_LENGTH])
{
switch (*(*inst)++) {
case STATE_MATERIAL_PARSER:
state_tokens[2] = STATE_ATTENUATION;
break;
case LIGHT_HALF:
- state_tokens[2] = STATE_HALF;
+ state_tokens[2] = STATE_HALF_VECTOR;
break;
case LIGHT_SPOT_DIRECTION:
state_tokens[2] = STATE_SPOT_DIRECTION;
case STATE_CLIP_PLANE:
state_tokens[0] = STATE_CLIPPLANE;
state_tokens[1] = parse_integer (inst, Program);
- if (parse_clipplane_num (ctx, inst, Program, &state_tokens[1]))
+ if (parse_clipplane_num (ctx, inst, Program,
+ (GLint *) &state_tokens[1]))
return 1;
break;
/* XXX: I think this is the correct format for a matrix row */
case STATE_MATRIX_ROWS:
- state_tokens[0] = STATE_MATRIX;
- if (parse_matrix
- (ctx, inst, Program, &state_tokens[1], &state_tokens[2],
- &state_tokens[5]))
+ if (parse_matrix(ctx, inst, Program,
+ (GLint *) &state_tokens[0],
+ (GLint *) &state_tokens[1],
+ (GLint *) &state_tokens[4]))
return 1;
- state_tokens[3] = parse_integer (inst, Program); /* The first row to grab */
+ state_tokens[2] = parse_integer (inst, Program); /* The first row to grab */
if ((**inst) != 0) { /* Either the last row, 0 */
- state_tokens[4] = parse_integer (inst, Program);
- if (state_tokens[4] < state_tokens[3]) {
+ state_tokens[3] = parse_integer (inst, Program);
+ if (state_tokens[3] < state_tokens[2]) {
program_error(ctx, Program->Position,
"Second matrix index less than the first");
/* state_tokens[4] vs. state_tokens[3] */
}
}
else {
- state_tokens[4] = state_tokens[3];
+ state_tokens[3] = state_tokens[2];
(*inst)++;
}
break;
*/
static GLuint
parse_program_single_item (GLcontext * ctx, const GLubyte ** inst,
- struct arb_program *Program, GLint * state_tokens)
+ struct arb_program *Program,
+ gl_state_index state_tokens[STATE_LENGTH])
{
if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB)
state_tokens[0] = STATE_FRAGMENT_PROGRAM;
break;
case FRAGMENT_ATTRIB_TEXCOORD:
{
- GLuint texcoord;
+ GLuint texcoord = 0;
err = parse_texcoord_num (ctx, inst, Program, &texcoord);
*inputReg = FRAG_ATTRIB_TEX0 + texcoord;
}
case VERTEX_ATTRIB_TEXCOORD:
{
- GLuint unit;
+ GLuint unit = 0;
err = parse_texcoord_num (ctx, inst, Program, &unit);
*inputReg = VERT_ATTRIB_TEX0 + unit;
}
{
GLint idx;
GLuint err = 0;
- GLint state_tokens[6];
+ gl_state_index state_tokens[STATE_LENGTH];
GLfloat const_values[4];
switch (*(*inst)++) {
/* If we adding STATE_MATRIX that has multiple rows, we need to
* unroll it and call _mesa_add_state_reference() for each row
*/
- if ((state_tokens[0] == STATE_MATRIX)
- && (state_tokens[3] != state_tokens[4])) {
+ if ((state_tokens[0] == STATE_MODELVIEW_MATRIX ||
+ state_tokens[0] == STATE_PROJECTION_MATRIX ||
+ state_tokens[0] == STATE_MVP_MATRIX ||
+ state_tokens[0] == STATE_TEXTURE_MATRIX ||
+ state_tokens[0] == STATE_PROGRAM_MATRIX)
+ && (state_tokens[2] != state_tokens[3])) {
GLint row;
- GLint first_row = state_tokens[3];
- GLint last_row = state_tokens[4];
+ const GLint first_row = state_tokens[2];
+ const GLint last_row = state_tokens[3];
for (row = first_row; row <= last_row; row++) {
- state_tokens[3] = state_tokens[4] = row;
+ state_tokens[2] = state_tokens[3] = row;
idx = _mesa_add_state_reference(Program->Base.Parameters,
state_tokens);
#if DEBUG_PARSING
-static GLvoid
-print_state_token (GLint token)
-{
- switch (token) {
- case STATE_MATERIAL:
- fprintf (stderr, "STATE_MATERIAL ");
- break;
- case STATE_LIGHT:
- fprintf (stderr, "STATE_LIGHT ");
- break;
-
- case STATE_LIGHTMODEL_AMBIENT:
- fprintf (stderr, "STATE_AMBIENT ");
- break;
-
- case STATE_LIGHTMODEL_SCENECOLOR:
- fprintf (stderr, "STATE_SCENECOLOR ");
- break;
-
- case STATE_LIGHTPROD:
- fprintf (stderr, "STATE_LIGHTPROD ");
- break;
-
- case STATE_TEXGEN:
- fprintf (stderr, "STATE_TEXGEN ");
- break;
-
- case STATE_FOG_COLOR:
- fprintf (stderr, "STATE_FOG_COLOR ");
- break;
-
- case STATE_FOG_PARAMS:
- fprintf (stderr, "STATE_FOG_PARAMS ");
- break;
-
- case STATE_CLIPPLANE:
- fprintf (stderr, "STATE_CLIPPLANE ");
- break;
-
- case STATE_POINT_SIZE:
- fprintf (stderr, "STATE_POINT_SIZE ");
- break;
-
- case STATE_POINT_ATTENUATION:
- fprintf (stderr, "STATE_ATTENUATION ");
- break;
-
- case STATE_MATRIX:
- fprintf (stderr, "STATE_MATRIX ");
- break;
-
- case STATE_MODELVIEW:
- fprintf (stderr, "STATE_MODELVIEW ");
- break;
-
- case STATE_PROJECTION:
- fprintf (stderr, "STATE_PROJECTION ");
- break;
-
- case STATE_MVP:
- fprintf (stderr, "STATE_MVP ");
- break;
-
- case STATE_TEXTURE:
- fprintf (stderr, "STATE_TEXTURE ");
- break;
-
- case STATE_PROGRAM:
- fprintf (stderr, "STATE_PROGRAM ");
- break;
-
- case STATE_MATRIX_INVERSE:
- fprintf (stderr, "STATE_INVERSE ");
- break;
-
- case STATE_MATRIX_TRANSPOSE:
- fprintf (stderr, "STATE_TRANSPOSE ");
- break;
-
- case STATE_MATRIX_INVTRANS:
- fprintf (stderr, "STATE_INVTRANS ");
- break;
-
- case STATE_AMBIENT:
- fprintf (stderr, "STATE_AMBIENT ");
- break;
-
- case STATE_DIFFUSE:
- fprintf (stderr, "STATE_DIFFUSE ");
- break;
-
- case STATE_SPECULAR:
- fprintf (stderr, "STATE_SPECULAR ");
- break;
-
- case STATE_EMISSION:
- fprintf (stderr, "STATE_EMISSION ");
- break;
-
- case STATE_SHININESS:
- fprintf (stderr, "STATE_SHININESS ");
- break;
-
- case STATE_HALF:
- fprintf (stderr, "STATE_HALF ");
- break;
-
- case STATE_POSITION:
- fprintf (stderr, "STATE_POSITION ");
- break;
-
- case STATE_ATTENUATION:
- fprintf (stderr, "STATE_ATTENUATION ");
- break;
-
- case STATE_SPOT_DIRECTION:
- fprintf (stderr, "STATE_DIRECTION ");
- break;
-
- case STATE_TEXGEN_EYE_S:
- fprintf (stderr, "STATE_TEXGEN_EYE_S ");
- break;
-
- case STATE_TEXGEN_EYE_T:
- fprintf (stderr, "STATE_TEXGEN_EYE_T ");
- break;
-
- case STATE_TEXGEN_EYE_R:
- fprintf (stderr, "STATE_TEXGEN_EYE_R ");
- break;
-
- case STATE_TEXGEN_EYE_Q:
- fprintf (stderr, "STATE_TEXGEN_EYE_Q ");
- break;
-
- case STATE_TEXGEN_OBJECT_S:
- fprintf (stderr, "STATE_TEXGEN_EYE_S ");
- break;
-
- case STATE_TEXGEN_OBJECT_T:
- fprintf (stderr, "STATE_TEXGEN_OBJECT_T ");
- break;
-
- case STATE_TEXGEN_OBJECT_R:
- fprintf (stderr, "STATE_TEXGEN_OBJECT_R ");
- break;
-
- case STATE_TEXGEN_OBJECT_Q:
- fprintf (stderr, "STATE_TEXGEN_OBJECT_Q ");
- break;
-
- case STATE_TEXENV_COLOR:
- fprintf (stderr, "STATE_TEXENV_COLOR ");
- break;
-
- case STATE_DEPTH_RANGE:
- fprintf (stderr, "STATE_DEPTH_RANGE ");
- break;
-
- case STATE_VERTEX_PROGRAM:
- fprintf (stderr, "STATE_VERTEX_PROGRAM ");
- break;
-
- case STATE_FRAGMENT_PROGRAM:
- fprintf (stderr, "STATE_FRAGMENT_PROGRAM ");
- break;
-
- case STATE_ENV:
- fprintf (stderr, "STATE_ENV ");
- break;
-
- case STATE_LOCAL:
- fprintf (stderr, "STATE_LOCAL ");
- break;
-
- }
- fprintf (stderr, "[%d] ", token);
-}
-
-
static GLvoid
debug_variables (GLcontext * ctx, struct var_cache *vc_head,
struct arb_program *Program)
struct var_cache *vc;
GLint a, b;
- fprintf (stderr, "debug_variables, vc_head: %x\n", vc_head);
+ fprintf (stderr, "debug_variables, vc_head: %p\n", (void*) vc_head);
/* First of all, print out the contents of the var_cache */
vc = vc_head;
while (vc) {
- fprintf (stderr, "[%x]\n", vc);
+ fprintf (stderr, "[%p]\n", (void*) vc);
switch (vc->type) {
case vt_none:
fprintf (stderr, "UNDEFINED %s\n", vc->name);
b = vc->param_binding_begin;
for (a = 0; a < vc->param_binding_length; a++) {
fprintf (stderr, "%s\n",
- Program->Parameters->Parameters[a + b].Name);
- if (Program->Parameters->Parameters[a + b].Type == STATE) {
- print_state_token (Program->Parameters->Parameters[a + b].
- StateIndexes[0]);
- print_state_token (Program->Parameters->Parameters[a + b].
- StateIndexes[1]);
- print_state_token (Program->Parameters->Parameters[a + b].
- StateIndexes[2]);
- print_state_token (Program->Parameters->Parameters[a + b].
- StateIndexes[3]);
- print_state_token (Program->Parameters->Parameters[a + b].
- StateIndexes[4]);
- print_state_token (Program->Parameters->Parameters[a + b].
- StateIndexes[5]);
+ Program->Base.Parameters->Parameters[a + b].Name);
+ if (Program->Base.Parameters->Parameters[a + b].Type == PROGRAM_STATE_VAR) {
+ const char *s;
+ s = _mesa_program_state_string(Program->Base.Parameters->Parameters
+ [a + b].StateIndexes);
+ fprintf(stderr, "%s\n", s);
+ _mesa_free((char *) s);
}
else
fprintf (stderr, "%f %f %f %f\n",
- Program->Parameters->Parameters[a + b].Values[0],
- Program->Parameters->Parameters[a + b].Values[1],
- Program->Parameters->Parameters[a + b].Values[2],
- Program->Parameters->Parameters[a + b].Values[3]);
+ Program->Base.Parameters->ParameterValues[a + b][0],
+ Program->Base.Parameters->ParameterValues[a + b][1],
+ Program->Base.Parameters->ParameterValues[a + b][2],
+ Program->Base.Parameters->ParameterValues[a + b][3]);
}
break;
case vt_temp:
break;
case vt_alias:
fprintf (stderr, "ALIAS %s\n", vc->name);
- fprintf (stderr, " binding: 0x%x (%s)\n",
- vc->alias_binding, vc->alias_binding->name);
+ fprintf (stderr, " binding: 0x%p (%s)\n",
+ (void*) vc->alias_binding, vc->alias_binding->name);
break;
+ default:
+ /* nothing */
+ ;
}
vc = vc->next;
}
program->Base.NumNativeParameters = ap.Base.NumNativeParameters;
program->Base.NumNativeAttributes = ap.Base.NumNativeAttributes;
program->Base.NumNativeAddressRegs = ap.Base.NumNativeAddressRegs;
- program->NumAluInstructions = ap.NumAluInstructions;
- program->NumTexInstructions = ap.NumTexInstructions;
- program->NumTexIndirections = ap.NumTexIndirections;
- program->NumNativeAluInstructions = ap.NumAluInstructions;
- program->NumNativeTexInstructions = ap.NumTexInstructions;
- program->NumNativeTexIndirections = ap.NumTexIndirections;
+ program->Base.NumAluInstructions = ap.Base.NumAluInstructions;
+ program->Base.NumTexInstructions = ap.Base.NumTexInstructions;
+ program->Base.NumTexIndirections = ap.Base.NumTexIndirections;
+ program->Base.NumNativeAluInstructions = ap.Base.NumAluInstructions;
+ program->Base.NumNativeTexInstructions = ap.Base.NumTexInstructions;
+ program->Base.NumNativeTexIndirections = ap.Base.NumTexIndirections;
program->Base.InputsRead = ap.Base.InputsRead;
program->Base.OutputsWritten = ap.Base.OutputsWritten;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
- program->TexturesUsed[i] = ap.TexturesUsed[i];
+ program->Base.TexturesUsed[i] = ap.TexturesUsed[i];
program->FogOption = ap.FogOption;
+ program->UsesKill = ap.UsesKill;
if (program->Base.Instructions)
_mesa_free(program->Base.Instructions);
/*
* Mesa 3-D graphics library
- * Version: 6.5.2
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
GLint i;
- ASSERT(rb);
+ if (!rb)
+ return;
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
const GLboolean biasOrScale
= ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
+ if (!rb)
+ return;
+
/* clipping should have been done already */
ASSERT(x >= 0);
ASSERT(y >= 0);
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
- ASSERT(rb);
-
if (type == GL_UNSIGNED_SHORT && fb->Visual.depthBits == 16
&& !biasOrScale && !packing->SwapBytes) {
/* Special case: directly read 16-bit unsigned depth values. */
struct gl_renderbuffer *rb = fb->_StencilBuffer;
GLint j;
- ASSERT(rb);
+ if (!rb)
+ return;
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
/**
* Optimized glReadPixels for particular pixel formats when pixel
* scaling, biasing, mapping, etc. are disabled.
+ * \return GL_TRUE if success, GL_FALSE if unable to do the readpixels
*/
static GLboolean
fast_read_rgba_pixels( GLcontext *ctx,
{
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ if (!rb)
+ return GL_FALSE;
+
ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
/* clipping should have already been done */
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
- ASSERT(rb);
+ if (!rb)
+ return;
if (type == GL_FLOAT && ((ctx->Color.ClampReadColor == GL_TRUE) ||
(ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB &&
/* no convolution */
const GLint dstStride
= _mesa_image_row_stride(packing, width, format, type);
- GLfloat (*rgba)[4] = swrast->SpanArrays->color.sz4.rgba;
+ GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
GLint row;
GLubyte *dst
= (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
depthRb = ctx->ReadBuffer->_DepthBuffer;
stencilRb = ctx->ReadBuffer->_StencilBuffer;
- ASSERT(depthRb);
- ASSERT(stencilRb);
+ if (!depthRb || !stencilRb)
+ return;
depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
if (ctx->NewState)
_mesa_update_state( ctx );
+ /* XXX also need to check if shader enabled, but invalid */
if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
(ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
node->prim_count,
NULL,
0, /* Node is a VBO, so this is ok */
- node->count );
+ node->count - 1);
}
/* Copy to current?