summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2006-04-11 11:41:11 +0000
committerMichal Krol <mjkrol@gmail.org>2006-04-11 11:41:11 +0000
commitbb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4d (patch)
tree8474881f1f529e1217d3442a98defb1a667b8403 /src/mesa/drivers/dri/r300
parentd90ad3fd876860b7a2ba763c031e46f76e4c47c6 (diff)
More GLSL code:
- use macros to access and modify render inputs bit-field; - un-alias generic vertex attributes for ARB vertex calls; - use MAX_VERTEX_PROGRAM_ATTRIBS (NV code) or MAX_VERTEX_ATTRIBS (ARB code) in place of VERT_ATTRIB_MAX; - define VERT_ATTRIB_GENERIC0..15 for un-aliased vertex attributes for ARB_vertex_shader; - fix generic attribute index range check in arbprogparse.c; - interface GLSL varyings between vertex and fragment shader; - use 64-bit optimised bitset (bitset.h) for render inputs;
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.c50
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c31
3 files changed, 49 insertions, 34 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index 449459b5b1..7504bd894a 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -776,7 +776,7 @@ struct r300_state {
GLuint *Elts;
struct r300_dma_region elt_dma;
- GLuint render_inputs; /* actual render inputs that R300 was configured for.
+ DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for.
They are the same as tnl->render_inputs for fixed pipeline */
struct {
diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c
index 1aa005c720..290ffb44ea 100644
--- a/src/mesa/drivers/dri/r300/r300_maos.c
+++ b/src/mesa/drivers/dri/r300/r300_maos.c
@@ -268,8 +268,10 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
GLuint vic_1 = 0; /* R300_VAP_INPUT_CNTL_1 */
GLuint aa_vap_reg = 0; /* VAP register assignment */
GLuint i;
- GLuint inputs = 0;
-
+ DECLARE_RENDERINPUTS(inputs_bitset);
+
+ RENDERINPUTS_ZERO( inputs_bitset );
+
#define CONFIGURE_AOS(r, f, v, sz, cn) { \
if (RADEON_DEBUG & DEBUG_STATE) \
fprintf(stderr, "Enabling "#v "\n"); \
@@ -300,23 +302,23 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->Base.InputsRead;
struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
if (InputsRead & (1<<VERT_ATTRIB_POS)) {
- inputs |= _TNL_BIT_POS;
+ RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_POS );
rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_POS];
}
if (InputsRead & (1<<VERT_ATTRIB_NORMAL)) {
- inputs |= _TNL_BIT_NORMAL;
+ RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_NORMAL );
rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_NORMAL];
}
if (InputsRead & (1<<VERT_ATTRIB_COLOR0)) {
- inputs |= _TNL_BIT_COLOR0;
+ RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_COLOR0 );
rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR0];
}
if (InputsRead & (1<<VERT_ATTRIB_COLOR1)) {
- inputs |= _TNL_BIT_COLOR1;
+ RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_COLOR1 );
rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR1];
}
if (InputsRead & (1<<VERT_ATTRIB_FOG)) {
- inputs |= _TNL_BIT_FOG;
+ RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_FOG );
rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_FOG];
}
if(ctx->Const.MaxTextureUnits > 8) { /* Not sure if this can even happen... */
@@ -325,17 +327,17 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
}
for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
if (InputsRead & (1<<(VERT_ATTRIB_TEX0+i))) {
- inputs |= _TNL_BIT_TEX0<<i;
+ RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_TEX(i) );
rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_TEX0+i];
}
}
nr = 0;
} else {
- inputs = TNL_CONTEXT(ctx)->render_inputs;
+ RENDERINPUTS_COPY( inputs_bitset, TNL_CONTEXT(ctx)->render_inputs_bitset );
}
- rmesa->state.render_inputs = inputs;
+ RENDERINPUTS_COPY( rmesa->state.render_inputs_bitset, inputs_bitset );
- if (inputs & _TNL_BIT_POS) {
+ if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_POS )) {
CONFIGURE_AOS(i_coords, AOS_FORMAT_FLOAT,
VB->AttribPtr[VERT_ATTRIB_POS],
immd ? 4 : VB->AttribPtr[VERT_ATTRIB_POS].size,
@@ -344,7 +346,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
vic_1 |= R300_INPUT_CNTL_POS;
}
- if (inputs & _TNL_BIT_NORMAL) {
+ if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_NORMAL )) {
CONFIGURE_AOS(i_normal, AOS_FORMAT_FLOAT,
VB->AttribPtr[VERT_ATTRIB_NORMAL],
immd ? 4 : VB->AttribPtr[VERT_ATTRIB_NORMAL].size,
@@ -353,7 +355,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
vic_1 |= R300_INPUT_CNTL_NORMAL;
}
- if (inputs & _TNL_BIT_COLOR0) {
+ if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR0 )) {
int emitsize=4;
if (!immd) {
@@ -376,7 +378,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
vic_1 |= R300_INPUT_CNTL_COLOR;
}
- if (inputs & _TNL_BIT_COLOR1) {
+ if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR1 )) {
int emitsize=4;
if (!immd) {
@@ -398,7 +400,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
}
#if 0
- if (inputs & _TNL_BIT_FOG) {
+ if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_FOG )) {
CONFIGURE_AOS( AOS_FORMAT_FLOAT,
VB->FogCoordPtr,
immd ? 4 : VB->FogCoordPtr->size,
@@ -408,7 +410,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
r300->state.texture.tc_count = 0;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- if (inputs & (_TNL_BIT_TEX0 << i)) {
+ if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_TEX(i) )) {
CONFIGURE_AOS(i_tex[i], AOS_FORMAT_FLOAT,
VB->AttribPtr[VERT_ATTRIB_TEX0+i],
immd ? 4 : VB->AttribPtr[VERT_ATTRIB_TEX0+i].size,
@@ -531,17 +533,17 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
#if 0
r300->hw.vic.cmd[R300_VIC_CNTL_1]=0;
- if(r300->state.render_inputs & _TNL_BIT_POS)
+ if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_POS ))
r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_POS;
- if(r300->state.render_inputs & _TNL_BIT_NORMAL)
+ if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_NORMAL ))
r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_NORMAL;
- if(r300->state.render_inputs & _TNL_BIT_COLOR0)
+ if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_COLOR0 ))
r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_COLOR;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
- if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i))
+ if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_TEX(i) ))
r300->hw.vic.cmd[R300_VIC_CNTL_1]|=(R300_INPUT_CNTL_TC0<<i);
#endif
@@ -573,15 +575,15 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
if(OutputsWritten & (1<<(VERT_RESULT_TEX0+i)))
r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4<<(3*i));
} else {
- if(inputs & _TNL_BIT_POS)
+ if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_POS ))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
- if(inputs & _TNL_BIT_COLOR0)
+ if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR0 ))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
- if(inputs & _TNL_BIT_COLOR1)
+ if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR1 ))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
- if(inputs & (_TNL_BIT_TEX0<<i))
+ if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_TEX(i) ))
r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i));
}
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 56052d64d2..bb0cb78382 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1270,6 +1270,19 @@ void r300_setup_textures(GLcontext *ctx)
fprintf(stderr, "TX_ENABLE: %08x last_hw_tmu=%d\n", r300->hw.txe.cmd[R300_TXE_ENABLE], last_hw_tmu);
}
+union r300_outputs_written {
+ GLuint vp_outputs; /* hw_tcl_on */
+ DECLARE_RENDERINPUTS(index_bitset); /* !hw_tcl_on */
+};
+
+static GLboolean r300_outputs_written_test (r300_outputs_written *ow, GLuint vp_result,
+ GLuint tnl_attrib)
+{
+ if (hw_tcl_on)
+ return ow->vp_outputs & (1 << vp_result);
+ return RENDERINPUTS_TEST( ow->index_bitset, tnl_attrib );
+}
+
void r300_setup_rs_unit(GLcontext *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -1284,16 +1297,16 @@ void r300_setup_rs_unit(GLcontext *ctx)
0x00,
0x00
};
- GLuint OutputsWritten;
+ union r300_outputs_written OutputsWritten;
GLuint InputsRead;
int fp_reg, high_rr;
int in_texcoords, col_interp_nr;
int i;
if(hw_tcl_on)
- OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
+ OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
else
- OutputsWritten = r300->state.render_inputs;
+ RENDERINPUTS_COPY( OutputsWritten.index_bitset, r300->state.render_inputs_bitset );
if (ctx->FragmentProgram._Current)
InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
@@ -1324,7 +1337,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
| (fp_reg << R300_RS_ROUTE_DEST_SHIFT);
high_rr = fp_reg;
- if (!(OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i)))) {
+ if (!r300_outputs_written_test( &OutputsWritten, VERT_RESULT_TEX0+i, _TNL_ATTRIB_TEX(i) )) {
/* Passing invalid data here can lock the GPU. */
WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i);
//_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base);
@@ -1334,12 +1347,12 @@ void r300_setup_rs_unit(GLcontext *ctx)
fp_reg++;
}
/* Need to count all coords enabled at vof */
- if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i)))
+ if (r300_outputs_written_test( &OutputsWritten, VERT_RESULT_TEX0+i, _TNL_ATTRIB_TEX(i) ))
in_texcoords++;
}
if (InputsRead & FRAG_BIT_COL0) {
- if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL0) : _TNL_BIT_COLOR0))) {
+ if (!r300_outputs_written_test( &OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0 )) {
WARN_ONCE("fragprog wants col0, vp doesn't provide it\n");
goto out; /* FIXME */
//_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base);
@@ -1355,7 +1368,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
out:
if (InputsRead & FRAG_BIT_COL1) {
- if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL1) : _TNL_BIT_COLOR1))) {
+ if (!r300_outputs_written_test( &OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1 )) {
WARN_ONCE("fragprog wants col1, vp doesn't provide it\n");
//exit(-1);
}
@@ -1515,7 +1528,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300)
)
o_reg += 2;
- if (r300->state.render_inputs & _TNL_BIT_COLOR1) {
+ if (RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_COLOR1 )) {
WRITE_OP(
EASY_VSF_OP(MUL, o_reg++, ALL, RESULT),
VSF_REG(r300->state.vap_reg.i_color[1]),
@@ -1526,7 +1539,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300)
/* Pass through texture coordinates, if any */
for(i=0;i < r300->radeon.glCtx->Const.MaxTextureUnits;i++)
- if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)){
+ if (RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_TEX(i) )){
// fprintf(stderr, "i_tex[%d]=%d\n", i, r300->state.vap_reg.i_tex[i]);
WRITE_OP(
EASY_VSF_OP(MUL, o_reg++ /* 2+i */, ALL, RESULT),