Make WARN_ONCE message more informative.
/* 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 );
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);
/* 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;\
} \
}
#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
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) */
#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
# 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 */
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++){
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
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;
}
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);
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;
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;
}
}
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)
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;
functions->Viewport = r300Viewport;
functions->DepthRange = r300DepthRange;
functions->PointSize = r300PointSize;
+
+
+ functions->PolygonOffset = r300PolygonOffset;
}