diff options
author | Vladimir Dergachev <[email protected]> | 2005-02-03 03:43:01 +0000 |
---|---|---|
committer | Vladimir Dergachev <[email protected]> | 2005-02-03 03:43:01 +0000 |
commit | f46de6f23b93cdcae5c33a5c107a3c1578cb9ed1 (patch) | |
tree | 81a97f70bc34d1696677624c9883c91bf070eaec /src/mesa/drivers | |
parent | 94a20cbadfb5266d1acbb0597dba16aacfa1fe32 (diff) |
Get Polygon offset fill to work.
Make WARN_ONCE message more informative.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_cmdbuf.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 12 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_reg.h | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_render.c | 14 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 54 |
5 files changed, 68 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 7505f7ba33d..a478b37ecdb 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -301,6 +301,8 @@ void r300InitCmdBuf(r300ContextPtr r300) /* Initialize state atoms */ ALLOC_STATE( vpt, always, R300_VPT_CMDSIZE, "vpt", 0 ); r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmducs(R300_SE_VPORT_XSCALE, 6); + ALLOC_STATE( zbs, always, R300_ZBS_CMDSIZE, "zbs", 0 ); + r300->hw.zbs.cmd[R300_ZBS_CMD_0] = cmducs(R300_SE_ZBIAS_FACTOR, 2); ALLOC_STATE( unk2080, always, 2, "unk2080", 0 ); r300->hw.unk2080.cmd[0] = cmducs(0x2080, 1); ALLOC_STATE( vte, always, 3, "vte", 0 ); @@ -460,6 +462,7 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.atomlist.name = "atom-list"; insert_at_tail(&r300->hw.atomlist, &r300->hw.vpt); + insert_at_tail(&r300->hw.atomlist, &r300->hw.zbs); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2080); insert_at_tail(&r300->hw.atomlist, &r300->hw.vte); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2134); diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 14f06fba4cc..a5d034e0cd4 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -57,11 +57,11 @@ typedef struct r300_context *r300ContextPtr; /* Checkpoint.. for convenience */ #define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); } #define WARN_ONCE(a) { \ - static int warn=1; \ - if(warn){ \ + static int warn##__LINE__=1; \ + if(warn##__LINE__){ \ fprintf(stderr, "%s:%s line %d ***WARN_ONCE*** " a, \ __FILE__, __FUNCTION__, __LINE__); \ - warn=0;\ + warn##__LINE__=0;\ } \ } @@ -209,6 +209,11 @@ struct r300_state_atom { #define R300_VPT_ZOFFSET 6 #define R300_VPT_CMDSIZE 7 +#define R300_ZBS_CMD_0 0 +#define R300_ZBS_FACTOR 1 +#define R300_ZBS_CONSTANT 2 +#define R300_ZBS_CMDSIZE 3 + #define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */ #define R300_VIR_CNTL_0 1 #define R300_VIR_CNTL_1 2 @@ -371,6 +376,7 @@ struct r300_hw_state { int max_state_size; /* in dwords */ struct r300_state_atom vpt; /* viewport (1D98) */ + struct r300_state_atom zbs; /* zbias (1DB0) */ struct r300_state_atom unk2080; /* (2080) */ struct r300_state_atom vof; /* VAP output format register 0x2090 */ struct r300_state_atom vte; /* (20B0) */ diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index b7e2cca63b3..526bb114878 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -16,6 +16,8 @@ I am fairly certain that they are correct unless stated otherwise in comments. #define R300_SE_VPORT_ZSCALE 0x1DA8 #define R300_SE_VPORT_ZOFFSET 0x1DAC +#define R300_SE_ZBIAS_FACTOR 0x1DB0 +#define R300_SE_ZBIAS_CONSTANT 0x1DB4 /* This register is written directly and also starts data section in many 3d CP_PACKET3's */ #define R300_VAP_VF_CNTL 0x2084 @@ -634,9 +636,9 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_TX_FORMAT_DXT3 0x10 # define R300_TX_FORMAT_DXT5 0x11 # define R300_TX_FORMAT_D3DMFT_CxV8U8 0x12 /* no swizzle */ -# define R300_TX_FORMA_A8R8G8B8 0x13 /* no swizzle */ -# define R300_TX_FORMA_B8G8_B8G8 0x14 /* no swizzle */ -# define R300_TX_FORMA_G8R8_G8B8 0x15 /* no swizzle */ +# define R300_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */ +# define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */ +# define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */ /* 0x16 - some 16 bit green format.. ?? */ /* gap */ /* Floating point formats */ diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index dac7006e575..16b7258481b 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -208,18 +208,22 @@ static void r300_render_immediate_primitive(r300ContextPtr rmesa, if(type<0)return; if(!VB->ObjPtr){ - fprintf(stderr, "FIXME: Dont know how to handle GL_ARB_vertex_buffer_object " - "correctly\n"); + WARN_ONCE("FIXME: Don't know how to handle GL_ARB_vertex_buffer_object correctly\n"); return; } /* A packet cannot have more than 16383 data words.. */ if(((end-start)*4*rmesa->state.aos_count)>16380){ - fprintf(stderr, "%s:%s: Too many vertices to paint. Fix me !\n"); + WARN_ONCE("Too many vertices to paint. Fix me !\n"); return; } //fprintf(stderr, "aos_count=%d start=%d end=%d\n", rmesa->state.aos_count, start, end); - + + if(rmesa->state.aos_count==0){ + WARN_ONCE("Aeiee ! aos_count==0, while it shouldn't. Skipping rendering\n"); + return; + } + start_immediate_packet(end-start, type, 4*rmesa->state.aos_count); for(i=start;i<end;i++){ @@ -622,7 +626,7 @@ static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage) FALLBACK_IF(ctx->Polygon.OffsetPoint); // GL_POLYGON_OFFSET_POINT FALLBACK_IF(ctx->Polygon.OffsetLine); // GL_POLYGON_OFFSET_LINE //FALLBACK_IF(ctx->Polygon.OffsetFill); // GL_POLYGON_OFFSET_FILL - if(ctx->Polygon.OffsetFill)WARN_ONCE("Polygon.OffsetFill not implemented, ignoring\n"); + //if(ctx->Polygon.OffsetFill)WARN_ONCE("Polygon.OffsetFill not implemented, ignoring\n"); FALLBACK_IF(ctx->Polygon.SmoothFlag); // GL_POLYGON_SMOOTH FALLBACK_IF(ctx->Polygon.StippleFlag); // GL_POLYGON_STIPPLE //FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 306a921b9b2..72dfe7a3b6f 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -417,9 +417,8 @@ static void r300UpdateCulling(GLcontext* ctx) if (ctx->Polygon.FrontFace == GL_CW) val |= R300_FRONT_FACE_CW; else - val |= R300_FRONT_FACE_CCW; + val |= R300_FRONT_FACE_CCW; } - r300->hw.cul.cmd[R300_CUL_CULL] = val; } @@ -479,15 +478,8 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) case GL_STENCIL_TEST: - { - static int stencil=1; - if(stencil){ - fprintf(stderr, "%s:%s - do not know how to enable stencil. Help me !\n", - __FILE__, __FUNCTION__); - stencil=0; - } - } - + WARN_ONCE("Do not know how to enable stencil. Help me !\n"); + if (r300->state.hw_stencil) { //fprintf(stderr, "Stencil %s\n", state ? "enabled" : "disabled"); R300_STATECHANGE(r300, zs); @@ -506,6 +498,14 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) case GL_CULL_FACE: r300UpdateCulling(ctx); break; + case GL_POLYGON_OFFSET_FILL: + R300_STATECHANGE(r300, unk42B4); + if (state) { + r300->hw.unk42B4.cmd[1] = (1<<1); + } else { + r300->hw.unk42B4.cmd[1] = 0; + } + break; case GL_VERTEX_PROGRAM_ARB: //TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, state); break; @@ -684,6 +684,9 @@ static void r300PointSize(GLcontext * ctx, GLfloat size) return R300_ZS_DECR_WRAP; case GL_INVERT: return R300_ZS_INVERT; + default: + WARN_ONCE("Do not know how to translate stencil op"); + return R300_ZS_KEEP; } } @@ -804,6 +807,28 @@ static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval) r300UpdateWindow(ctx); } +/* ============================================================= + * Polygon state + */ + +static void r300PolygonOffset(GLcontext * ctx, GLfloat factor, GLfloat units) +{ + r300ContextPtr rmesa = R300_CONTEXT(ctx); + GLfloat constant = units * rmesa->state.depth.scale; + +/* factor *= 2; */ +/* constant *= 2; */ + +/* fprintf(stderr, "%s f:%f u:%f\n", __FUNCTION__, factor, constant); */ + + WARN_ONCE("ZBIAS registers locations might not be correct\n"); + + R200_STATECHANGE(rmesa, zbs); + rmesa->hw.zbs.cmd[R300_ZBS_FACTOR] = r300PackFloat32(factor); + rmesa->hw.zbs.cmd[R300_ZBS_CONSTANT] = r300PackFloat32(constant); +} + + /* Routing and texture-related */ void r300_setup_routing(GLcontext *ctx, GLboolean immediate) @@ -1637,8 +1662,10 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.unk42A0.cmd[1] = 0x00000000; + #if 0 r300->hw.unk42B4.cmd[1] = 0x00000000; - + #endif + r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF; r300->hw.unk42C0.cmd[2] = 0x00000000; @@ -1836,4 +1863,7 @@ void r300InitStateFuncs(struct dd_function_table* functions) functions->Viewport = r300Viewport; functions->DepthRange = r300DepthRange; functions->PointSize = r300PointSize; + + + functions->PolygonOffset = r300PolygonOffset; } |