From bc81885bb2b498449a1362997ca67dd53f97d2e7 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 14 Jun 2007 15:26:39 +1000 Subject: Initial r300 modes for swtcl it compiles!! --- src/mesa/drivers/dri/r300/r300_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa/drivers/dri/r300/r300_context.c') diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 9ea14ab4c7..311d003633 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -63,6 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_ioctl.h" #include "r300_tex.h" #include "r300_emit.h" +#include "r300_swtcl.h" #ifdef USER_BUFFERS #include "r300_mem.h" @@ -164,7 +165,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = { /* Else do them here. */ - &_r300_render_stage, + // &_r300_render_stage, &_tnl_render_stage, /* FALLBACK */ 0, }; @@ -363,6 +364,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, radeonInitSpanFuncs(ctx); r300InitCmdBuf(r300); r300InitState(r300); + r300InitSwtcl(ctx); TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; -- cgit v1.2.3 From b691d460465f992dc3febde06593341f192be970 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:40:26 +1000 Subject: r300: cleanup some of the swtcl code --- src/mesa/drivers/dri/r300/r300_context.c | 2 +- src/mesa/drivers/dri/r300/r300_emit.c | 10 +-- src/mesa/drivers/dri/r300/r300_emit.h | 7 +++ src/mesa/drivers/dri/r300/r300_render.c | 5 ++ src/mesa/drivers/dri/r300/r300_swtcl.c | 101 +------------------------------ 5 files changed, 19 insertions(+), 106 deletions(-) (limited to 'src/mesa/drivers/dri/r300/r300_context.c') diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 311d003633..04e3fffa5d 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -165,7 +165,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = { /* Else do them here. */ - // &_r300_render_stage, + &_r300_render_stage, &_tnl_render_stage, /* FALLBACK */ 0, }; diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index a7763bd76e..229439dfa8 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -239,7 +239,7 @@ static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]) (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); } -static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) +GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) { GLuint i; @@ -255,14 +255,14 @@ static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) return (nr + 1) >> 1; } -static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) +GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) { /* No idea what this value means. I have seen other values written to * this register... */ return 0x5555; } -static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) +GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) { r300ContextPtr rmesa = R300_CONTEXT(ctx); GLuint i, vic_1 = 0; @@ -286,7 +286,7 @@ static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) return vic_1; } -static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) +GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) { GLuint ret = 0; @@ -315,7 +315,7 @@ static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) return ret; } -static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) +GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) { GLuint i, ret = 0; diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h index 400e97f6f8..a6d69ec5ff 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.h +++ b/src/mesa/drivers/dri/r300/r300_emit.h @@ -229,4 +229,11 @@ extern int r300PrimitiveType(r300ContextPtr rmesa, int prim); extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim); extern void r300EmitCacheFlush(r300ContextPtr rmesa); + +extern GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr); +extern GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead); +extern GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead); +extern GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten); +extern GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten); + #endif diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index db935795c7..7d8defd1cd 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -371,12 +371,17 @@ static int r300Fallback(GLcontext * ctx) static GLboolean r300RunNonTCLRender(GLcontext * ctx, struct tnl_pipeline_stage *stage) { + r300ContextPtr rmesa = R300_CONTEXT(ctx); + if (RADEON_DEBUG & DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__); if (r300Fallback(ctx) >= R300_FALLBACK_RAST) return GL_TRUE; + if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) + return GL_TRUE; + return r300RunRender(ctx, stage); } diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index ef3f3b347c..3fc229807f 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -77,6 +77,7 @@ do { \ rmesa->swtcl.vertex_attr_count++; \ } while (0) +/* this differs from the VIR0 in emit.c - TODO merge them using another option */ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, int *inputs, GLint * tab, GLuint nr) { @@ -101,103 +102,6 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, return (nr + 1) >> 1; } -static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]) -{ - return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) | - (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) | - (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) | - (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); -} - -static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) -{ - GLuint i; - - for (i = 0; i + 1 < nr; i += 2) { - dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE; - dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16; - } - - if (nr & 1) { - dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE; - } - - return (nr + 1) >> 1; -} - -static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) -{ - /* No idea what this value means. I have seen other values written to - * this register... */ - return 0x5555; -} - -static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) -{ - r300ContextPtr rmesa = R300_CONTEXT(ctx); - GLuint i, vic_1 = 0; - - if (InputsRead & (1 << VERT_ATTRIB_POS)) - vic_1 |= R300_INPUT_CNTL_POS; - - if (InputsRead & (1 << VERT_ATTRIB_NORMAL)) - vic_1 |= R300_INPUT_CNTL_NORMAL; - - if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) - vic_1 |= R300_INPUT_CNTL_COLOR; - - rmesa->state.texture.tc_count = 0; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) { - rmesa->state.texture.tc_count++; - vic_1 |= R300_INPUT_CNTL_TC0 << i; - } - - return vic_1; -} - -static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) -{ - GLuint ret = 0; - - if (OutputsWritten & (1 << VERT_RESULT_HPOS)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_COL0)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_COL1)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; - -#if 0 - if (OutputsWritten & (1 << VERT_RESULT_BFC0)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_BFC1)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; -#endif - - if (OutputsWritten & (1 << VERT_RESULT_PSIZ)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; - - return ret; -} - -static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) -{ - GLuint i, ret = 0; - - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) { - ret |= (4 << (3 * i)); - } - } - - return ret; -} - static void r300SetVertexFormat( GLcontext *ctx ) { r300ContextPtr rmesa = R300_CONTEXT( ctx ); @@ -659,9 +563,6 @@ static void r300ChooseRenderState( GLcontext *ctx ) GLuint index = 0; GLuint flags = ctx->_TriangleCaps; - // if (!rmesa->TclFallback || rmesa->Fallback) -// return; - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT; if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT; -- cgit v1.2.3 From 5657fc5b4c6581166430f1a5144f1f8b7e4e78eb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 4 Jul 2007 15:29:31 +1000 Subject: r300: only init swtcl on tcl-less cards --- src/mesa/drivers/dri/r300/r300_context.c | 23 +++++++++++++---------- src/mesa/drivers/dri/r300/r300_swtcl.c | 5 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/mesa/drivers/dri/r300/r300_context.c') diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 04e3fffa5d..14e0f052fd 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -318,15 +318,17 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, _tnl_allow_vertex_fog(ctx, GL_TRUE); /* currently bogus data */ - ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4; - ctx->Const.VertexProgram.MaxNativeInstructions = - VSF_MAX_FRAGMENT_LENGTH / 4; - ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */ - ctx->Const.VertexProgram.MaxTemps = 32; - ctx->Const.VertexProgram.MaxNativeTemps = - /*VSF_MAX_FRAGMENT_TEMPS */ 32; - ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */ - ctx->Const.VertexProgram.MaxNativeAddressRegs = 1; + if (screen->chip_flags & RADEON_CHIPSET_TCL) { + ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4; + ctx->Const.VertexProgram.MaxNativeInstructions = + VSF_MAX_FRAGMENT_LENGTH / 4; + ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */ + ctx->Const.VertexProgram.MaxTemps = 32; + ctx->Const.VertexProgram.MaxNativeTemps = + /*VSF_MAX_FRAGMENT_TEMPS */ 32; + ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */ + ctx->Const.VertexProgram.MaxNativeAddressRegs = 1; + } ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS; ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* copy i915... */ @@ -364,7 +366,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, radeonInitSpanFuncs(ctx); r300InitCmdBuf(r300); r300InitState(r300); - r300InitSwtcl(ctx); + if (!(screen->chip_flags & RADEON_CHIPSET_TCL)) + r300InitSwtcl(ctx); TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 7aea063447..c949f33bf3 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -668,6 +668,11 @@ void r300InitSwtcl(GLcontext *ctx) _tnl_need_projected_coords( ctx, GL_FALSE ); r300ChooseRenderState(ctx); + + _mesa_validate_all_lighting_tables( ctx ); + + tnl->Driver.NotifyMaterialChange = + _mesa_validate_all_lighting_tables; } void r300DestroySwtcl(GLcontext *ctx) -- cgit v1.2.3