r300g: enable clamping controls
authorMarek Olšák <maraeo@gmail.com>
Tue, 15 Feb 2011 23:50:25 +0000 (00:50 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 29 Mar 2011 10:50:28 +0000 (12:50 +0200)
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_fs.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c

index e395f41290e63c8e57bce5a431424e9ee5623fba..3b6cb8f7a11abeecabd61080c00d49024fa77bc1 100644 (file)
@@ -580,6 +580,8 @@ struct r300_context {
     int sprite_coord_enable;
     /* Whether two-sided color selection is enabled (AKA light_twoside). */
     boolean two_sided_color;
+    /* Whether fragment color clamping is enabled. */
+    boolean frag_clamp;
     /* Whether fast color clear is enabled. */
     boolean cbzb_clear;
     /* Whether ZMASK is enabled. */
index 4c502fefb3fce365c3c50b0a668ff45074e4def9..37fe6622cd75a288155e387f68f37cdd2cb554ce 100644 (file)
@@ -146,10 +146,11 @@ static void get_external_state(
     struct r300_fragment_program_external_state* state)
 {
     struct r300_textures_state *texstate = r300->textures_state.state;
+    struct r300_rs_state *rs = r300->rs_state.state;
     unsigned i;
     unsigned char *swizzle;
 
-    state->frag_clamp = 0;
+    state->frag_clamp = rs ? rs->rs.clamp_fragment_color : 0;
 
     for (i = 0; i < texstate->sampler_state_count; i++) {
         struct r300_sampler_state *s = texstate->sampler_states[i];
index 8a69628c53e2866ddab293855943594b63df21cf..deaeb77429f8608e7fca268427deb9c68e29d660 100644 (file)
@@ -114,6 +114,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
         case PIPE_CAP_BLEND_EQUATION_SEPARATE:
         case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
+        case PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL:
             return 1;
         case PIPE_CAP_TEXTURE_SWIZZLE:
             return util_format_s3tc_enabled ? r300screen->caps.dxtc_swizzle : 1;
index ecb4fc691cc8ff0355f20d2c54c87e0d283e8c42..890e3961b1887a2fa012e2a97a287c99578057fa 100644 (file)
@@ -398,10 +398,6 @@ static void r300_bind_blend_state(struct pipe_context* pipe,
     struct r300_context* r300 = r300_context(pipe);
 
     UPDATE_STATE(state, r300->blend_state);
-
-    if (r300->fs.state && r300_pick_fragment_shader(r300)) {
-        r300_mark_fs_code_dirty(r300);
-    }
 }
 
 /* Free blend state. */
@@ -1047,7 +1043,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
     float point_texcoord_bottom = 0;/* R300_GA_POINT_T0: 0x4204 */
     float point_texcoord_right = 1; /* R300_GA_POINT_S1: 0x4208 */
     float point_texcoord_top = 0;   /* R300_GA_POINT_T1: 0x420c */
-    boolean vclamp = TRUE;
+    boolean vclamp = state->clamp_vertex_color;
     CB_LOCALS;
 
     /* Copy rasterizer state. */
@@ -1233,6 +1229,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     struct r300_rs_state* rs = (struct r300_rs_state*)state;
     int last_sprite_coord_enable = r300->sprite_coord_enable;
     boolean last_two_sided_color = r300->two_sided_color;
+    boolean last_frag_clamp = r300->frag_clamp;
 
     if (r300->draw && rs) {
         draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state);
@@ -1242,10 +1239,12 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
         r300->polygon_offset_enabled = rs->polygon_offset_enable;
         r300->sprite_coord_enable = rs->rs.sprite_coord_enable;
         r300->two_sided_color = rs->rs.light_twoside;
+        r300->frag_clamp = rs->rs.clamp_fragment_color;
     } else {
         r300->polygon_offset_enabled = FALSE;
         r300->sprite_coord_enable = 0;
         r300->two_sided_color = FALSE;
+        r300->frag_clamp = FALSE;
     }
 
     UPDATE_STATE(state, r300->rs_state);
@@ -1255,6 +1254,11 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
         last_two_sided_color != r300->two_sided_color) {
         r300_mark_atom_dirty(r300, &r300->rs_block_state);
     }
+
+    if (last_frag_clamp != r300->frag_clamp &&
+        r300->fs.state && r300_pick_fragment_shader(r300)) {
+        r300_mark_fs_code_dirty(r300);
+    }
 }
 
 /* Free rasterizer state. */