r300-gallium: Flat/smooth shading state.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 6 Mar 2009 19:17:55 +0000 (11:17 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 6 Mar 2009 19:17:55 +0000 (11:17 -0800)
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_reg.h
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_surface.c
src/gallium/drivers/r300/r300_surface.h

index c2329b4..95b3b14 100644 (file)
@@ -74,6 +74,7 @@ struct r300_rs_state {
     uint32_t cull_mode;             /* R300_SU_CULL_MODE: 0x42b8 */
     uint32_t line_stipple_config;   /* R300_GA_LINE_STIPPLE_CONFIG: 0x4328 */
     uint32_t line_stipple_value;    /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */
+    uint32_t color_control;         /* R300_GA_COLOR_CONTROL: 0x4278 */
 };
 
 struct r300_rs_block {
index 6c84b56..86325f6 100644 (file)
@@ -196,7 +196,7 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     CS_LOCALS(r300);
 
-    BEGIN_CS(18);
+    BEGIN_CS(20);
     OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status);
     OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size);
     OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2);
@@ -211,6 +211,7 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
     OUT_CS(rs->cull_mode);
     OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, rs->line_stipple_config);
     OUT_CS_REG(R300_GA_LINE_STIPPLE_VALUE, rs->line_stipple_value);
+    OUT_CS_REG(R300_GA_COLOR_CONTROL, rs->color_control);
     END_CS;
 }
 
index e10d237..b0394f8 100644 (file)
@@ -1023,20 +1023,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_THIRD  (2 << 16)
 #      define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST   (3 << 16)
 
-/** TODO: might be candidate for removal */
-#      define R300_RE_SHADE_MODEL_SMOOTH     ( \
-       R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD | \
-       R300_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
-       R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
-       R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
-       R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
-/** TODO: might be candidate for removal, the GOURAUD stuff also looks buggy to me */
-#      define R300_RE_SHADE_MODEL_FLAT     ( \
-       R300_GA_COLOR_CONTROL_RGB0_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT | \
-       R300_GA_COLOR_CONTROL_RGB1_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
-       R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
-       R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
-       R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+#       define R300_SHADE_MODEL_FLAT ( \
+        R300_GA_COLOR_CONTROL_RGB0_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_RGB1_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_ALPHA1_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_ALPHA3_SHADING_FLAT | \
+        R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+
+#       define R300_SHADE_MODEL_SMOOTH ( \
+        R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
+        R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
 
 /* Specifies red & green components of fill color -- S312 format -- Backwards comp. */
 #define R300_GA_SOLID_RG                         0x427c
index a909ad0..04cbf71 100644 (file)
@@ -389,6 +389,12 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
         rs->line_stipple_value = state->line_stipple_pattern;
     }
 
+    if (state->flatshade) {
+        rs->color_control = R300_SHADE_MODEL_FLAT;
+    } else {
+        rs->color_control = R300_SHADE_MODEL_SMOOTH;
+    }
+
     rs->rs = *state;
 
     return (void*)rs;
index eafcc12..635309e 100644 (file)
@@ -72,7 +72,7 @@ static void r300_surface_fill(struct pipe_context* pipe,
         r300_emit_rs_block_state(r300, &r300_rs_block_clear_state);
     }
 
-    BEGIN_CS(126 + (caps->has_tcl ? 2 : 0));
+    BEGIN_CS(124 + (caps->has_tcl ? 2 : 0));
     /* Flush PVS. */
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
 
@@ -112,7 +112,6 @@ static void r300_surface_fill(struct pipe_context* pipe,
     OUT_CS_REG(R300_GA_LINE_S0, 0x00000000);
     OUT_CS_REG(R300_GA_LINE_S1, 0x3F800000);
     OUT_CS_REG(R300_GA_ENHANCE, 0x00000002);
-    OUT_CS_REG(R300_GA_COLOR_CONTROL, 0x0003AAAA);
     OUT_CS_REG(R300_GA_SOLID_RG, 0x00000000);
     OUT_CS_REG(R300_GA_SOLID_BA, 0x00000000);
     OUT_CS_REG(R300_GA_POLY_MODE, 0x00000000);
index be3105f..b75b3ab 100644 (file)
@@ -68,6 +68,7 @@ const struct r300_rs_state rs_clear_state = {
     .cull_mode = 0x0,
     .line_stipple_config = 0x3BAAAAAB,
     .line_stipple_value = 0x0,
+    .color_control = R300_SHADE_MODEL_FLAT,
 };
 
 const struct r300_rs_block r300_rs_block_clear_state = {