Flat shading and bunch of clarifications to r300_reg.h .
authorAapo Tahkola <aet@rasterburn.org>
Thu, 5 May 2005 03:40:47 +0000 (03:40 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Thu, 5 May 2005 03:40:47 +0000 (03:40 +0000)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_reg.h
src/mesa/drivers/dri/r300/r300_shader.c
src/mesa/drivers/dri/r300/r300_state.c

index df825ba3b435cf8107719a5ddee5b57bcd29d0e6..cd8b7228c6ad3a3eebc59a90e2e463ea8e8692da 100644 (file)
@@ -341,6 +341,8 @@ void r300InitCmdBuf(r300ContextPtr r300)
        ALLOC_STATE( lsf, always, 2, "lsf", 0 );
                r300->hw.lsf.cmd[0] = cmducs(R300_RE_LINE_STIPPLE_FACTOR, 1);
 #endif
+       ALLOC_STATE( sm, always, 2, "sm", 0 );
+               r300->hw.sm.cmd[0] = cmducs(R300_RE_SHADE_MODEL, 1);
        ALLOC_STATE( unk4260, always, 4, "unk4260", 0 );
                r300->hw.unk4260.cmd[0] = cmducs(0x4260, 3);
        ALLOC_STATE( unk4274, always, 5, "unk4274", 0 );
@@ -485,6 +487,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
 #endif
        insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4260);
        insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4274);
+       insert_at_tail(&r300->hw.atomlist, &r300->hw.sm);
        insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4288);
        insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42A0);
        insert_at_tail(&r300->hw.atomlist, &r300->hw.zbs);
index fa6dbbf8af1f07f1686563182d75648d8c66a79c..86f7cfaba64f87d1fc2cee9d7499d2d1d76cc932 100644 (file)
@@ -271,6 +271,9 @@ struct r300_state_atom {
 #define R300_PS_POINTSIZE      1
 #define R300_PS_CMDSIZE                2
 
+#define R300_SM_CMD_0          0
+#define R300_SM                        1
+
 #define R300_ZBS_CMD_0         0
 #define R300_ZBS_T_FACTOR      1
 #define R300_ZBS_T_CONSTANT    2
@@ -420,6 +423,7 @@ struct r300_hw_state {
 #endif
        struct r300_state_atom unk4260; /* (4260) */
        struct r300_state_atom unk4274; /* (4274) */
+       struct r300_state_atom sm;      /* shade model (4278) */
        struct r300_state_atom unk4288; /* (4288) */
        struct r300_state_atom unk42A0; /* (42A0) */
        struct r300_state_atom zbs;     /* zbias (42A4) */
index 6085ccf00048b3a069c5b7a01e1614d62655df42..781d39514f5694caf48ba74e765a22b8c196a497 100644 (file)
@@ -12,6 +12,7 @@
 
 #define RADEON_CP_PACKET3_NOP                       0xC0001000
 #define RADEON_CP_PACKET3_NEXT_CHAR                 0xC0001900
+#define RADEON_CP_PACKET3_UNK1B                     0xC0001B00
 #define RADEON_CP_PACKET3_PLY_NEXTSCAN              0xC0001D00
 #define RADEON_CP_PACKET3_SET_SCISSORS              0xC0001E00
 #define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM     0xC0002300
index 7242cbc892dfcd414f33a1d603d9a309ddb92c4b..32f4ebeea2591ea6bfc4c8a33f8f2858b8d58e2f 100644 (file)
@@ -440,6 +440,11 @@ I am fairly certain that they are correct unless stated otherwise in comments.
 /* Linestipple factor. 3a088889 == 1.0, 3baaaaa9 == 10.0 */
 #define R300_RE_LINE_STIPPLE_FACTOR           0x4238
 
+#define R300_RE_SHADE_MODEL                   0x4278
+#      define R300_RE_SHADE_MODEL_SMOOTH     0x3aaaa
+#      define R300_RE_SHADE_MODEL_FLAT       0x39595
+
+
 #define R300_RE_POLYGON_MODE                  0x4288
 
 /* Not sure why there are duplicate of factor and constant values. 
@@ -471,20 +476,19 @@ I am fairly certain that they are correct unless stated otherwise in comments.
 
 
 /* BEGIN: Rasterization / Interpolators - many guesses
-// So far, 0_UNKOWN_7 has always been set.
 // 0_UNKNOWN_18 has always been set except for clear operations.
 // TC_CNT is the number of incoming texture coordinate sets (i.e. it depends
 // on the vertex program, *not* the fragment program) */
 #define R300_RS_CNTL_0                      0x4300
 #       define R300_RS_CNTL_TC_CNT_SHIFT         2
 #       define R300_RS_CNTL_TC_CNT_MASK          (7 << 2)
-#       define R300_RS_CNTL_0_UNKNOWN_7          (1 << 7)
+#       define R300_RS_CNTL_0_UNKNOWN_7          (1 << 7) /* Number of color interpolators used (shifted by 7) */
 #       define R300_RS_CNTL_0_UNKNOWN_18         (1 << 18)
 /* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n register. */
 #define R300_RS_CNTL_1                      0x4304
 
 /* gap */
-/* Only used for texture coordinates (color seems to be always interpolated).
+/* Only used for texture coordinates.
 // Use the source field to route texture coordinate input from the vertex program
 // to the desired interpolator. Note that the source field is relative to the
 // outputs the vertex program *actually* writes. If a vertex program only writes
@@ -1200,14 +1204,15 @@ I am fairly certain that they are correct unless stated otherwise in comments.
 #define R300_VPI_OUT_OP_MIN                     (8 << 0)
 #define R300_VPI_OUT_OP_SGE                     (9 << 0)
 #define R300_VPI_OUT_OP_SLT                     (10 << 0)
-#define R300_VPI_OUT_OP_UNK1                    (12 << 0) /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB */
+#define R300_VPI_OUT_OP_UNK12                   (12 << 0) /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, vector(scalar, vector) */
 #define R300_VPI_OUT_OP_EXP                     (65 << 0)
 #define R300_VPI_OUT_OP_LOG                     (66 << 0)
+#define R300_VPI_OUT_OP_UNK67                   (67 << 0) /* Used in fog computations, scalar(scalar) */
 #define R300_VPI_OUT_OP_LIT                     (68 << 0)
 #define R300_VPI_OUT_OP_POW                     (69 << 0)
 #define R300_VPI_OUT_OP_RCP                     (70 << 0)
 #define R300_VPI_OUT_OP_RSQ                     (72 << 0)
-#define R300_VPI_OUT_OP_UNK2                    (73 << 0) /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB */
+#define R300_VPI_OUT_OP_UNK73                   (73 << 0) /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, scalar(scalar) */
 #define R300_VPI_OUT_OP_EX2                     (75 << 0)
 #define R300_VPI_OUT_OP_LG2                     (76 << 0)
 #define R300_VPI_OUT_OP_MAD_2                   (128 << 0)
index 0690b19a0cd122c77a84af104e21fd1fc7a52258..c3c89e0215d3fa18951e3b99ac8f24b28df94947 100644 (file)
@@ -74,6 +74,7 @@ void r300ProgramStringNotify(GLcontext *ctx, GLenum target,
        case GL_VERTEX_PROGRAM_ARB:
                vp->translated=GL_FALSE;
                translate_vertex_shader(vp);
+               //debug_vp(ctx, vp);
        break;
        
        case GL_FRAGMENT_PROGRAM_ARB:
index 922113c9206119bcd225a929feec3488ad6842da..3d9f6ee8fd85da1d5c1d07242c0f9c4513dbaa46 100644 (file)
@@ -886,6 +886,23 @@ static void r300PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
        }
 }
 
+static void r300ShadeModel(GLcontext * ctx, GLenum mode)
+{
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       
+       R300_STATECHANGE(rmesa, sm);
+       switch (mode) {
+       case GL_FLAT:
+               rmesa->hw.sm.cmd[R300_SM] = R300_RE_SHADE_MODEL_FLAT;
+               break;
+       case GL_SMOOTH:
+               rmesa->hw.sm.cmd[R300_SM] = R300_RE_SHADE_MODEL_SMOOTH;
+               break;
+       default:
+               return;
+       }
+}
+
 static void r300StencilFunc(GLcontext * ctx, GLenum func,
                            GLint ref, GLuint mask)
 {
@@ -2098,6 +2115,8 @@ void r300ResetHwState(r300ContextPtr r300)
        r300DepthMask(ctx, ctx->Depth.Mask);
        r300DepthFunc(ctx, ctx->Depth.Func);
        
+       r300ShadeModel(ctx, ctx->Light.ShadeModel);
+       
        /* stencil */
        r300Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
        r300StencilMask(ctx, ctx->Stencil.WriteMask[0]);
@@ -2441,6 +2460,7 @@ void r300InitStateFuncs(struct dd_function_table* functions)
        functions->DepthMask = r300DepthMask;
        functions->CullFace = r300CullFace;
        functions->FrontFace = r300FrontFace;
+       functions->ShadeModel = r300ShadeModel;
 
        /* Stencil related */
        functions->ClearStencil = r300ClearStencil;