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 c2329b430c547ae6eb75f12dcb8083294220eb4f..95b3b14a1a1acde6288f9c6781e322a19a33c596 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 6c84b562d03fe8f0ba516aaa9d0f711a0f65e211..86325f675be180a1e6e72510c3cf5e32e062e37c 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 e10d2373bb67193f6068dd9569c8aa0c5c76e8bc..b0394f80c8884dd6e0f9ebe9f2baaf3ab17b6e71 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 a909ad0341bb370149266e3bbffbc27a8989c63f..04cbf71ce5033c9c30500b1ee3be8bbe0c2282d0 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 eafcc12b7d650e0ea0d954fb68a5759ac50d716f..635309ee01cc1caaabd9732f527a7a8b7490f424 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 be3105f8ce40d4904fa8a462333f6391a19fb4dc..b75b3ab84cf6ea33ec9b0dd4248c3f5bd0f3e619 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 = {