intel: Add support for ARB_color_buffer_float.
authorEric Anholt <eric@anholt.net>
Fri, 15 Apr 2011 21:40:09 +0000 (14:40 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 20 Apr 2011 17:35:42 +0000 (10:35 -0700)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs.h
src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/gen6_cc.c
src/mesa/drivers/dri/intel/intel_extensions.c

index 412d82ab3ca90cbfb46311efab8518fcaeb67e8a..74a66af31a5579b9209dca506721c16fa676b359 100644 (file)
@@ -238,10 +238,10 @@ static void upload_blend_constant_color(struct brw_context *brw)
 
    BEGIN_BATCH(5);
    OUT_BATCH(_3DSTATE_BLEND_CONSTANT_COLOR << 16 | (5-2));
-   OUT_BATCH_F(ctx->Color.BlendColor[0]);
-   OUT_BATCH_F(ctx->Color.BlendColor[1]);
-   OUT_BATCH_F(ctx->Color.BlendColor[2]);
-   OUT_BATCH_F(ctx->Color.BlendColor[3]);
+   OUT_BATCH_F(ctx->Color.BlendColorUnclamped[0]);
+   OUT_BATCH_F(ctx->Color.BlendColorUnclamped[1]);
+   OUT_BATCH_F(ctx->Color.BlendColorUnclamped[2]);
+   OUT_BATCH_F(ctx->Color.BlendColorUnclamped[3]);
    CACHED_BATCH();
 }
 
index 6ae75d22c149e6dc2e92c3afe3ef0fa9c1cc34ff..63ae13191f991d4be9901c46fffefe74624cae58 100644 (file)
@@ -132,6 +132,9 @@ static void brw_upload_vs_prog(struct brw_context *brw)
                        ctx->Polygon.BackMode != GL_FILL);
    key.two_side_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
 
+   /* _NEW_LIGHT | _NEW_BUFFERS */
+   key.clamp_vertex_color = ctx->Light._ClampVertexColor;
+
    /* _NEW_POINT */
    if (ctx->Point.PointSprite) {
       for (i = 0; i < 8; i++) {
@@ -158,7 +161,8 @@ static void brw_upload_vs_prog(struct brw_context *brw)
  */
 const struct brw_tracked_state brw_vs_prog = {
    .dirty = {
-      .mesa  = _NEW_TRANSFORM | _NEW_POLYGON | _NEW_POINT | _NEW_LIGHT,
+      .mesa  = (_NEW_TRANSFORM | _NEW_POLYGON | _NEW_POINT | _NEW_LIGHT |
+               _NEW_BUFFERS),
       .brw   = BRW_NEW_VERTEX_PROGRAM,
       .cache = 0
    },
index 0b88cc1ec76453fb512243f75941c7edc12182b4..7ca84a54b01b1fd0d5ffad69bb1484a12b8aaa2a 100644 (file)
@@ -45,6 +45,7 @@ struct brw_vs_prog_key {
    GLuint copy_edgeflag:1;
    GLuint point_coord_replace:8;
    GLuint two_side_color: 1;
+   GLuint clamp_vertex_color:1;
 };
 
 
index 96150ecc377d4125431793bdc88eee79aa4adf9d..dd4e1e6c6ad93c3287e0a2ca430ab3efeccbff61 100644 (file)
@@ -2221,7 +2221,8 @@ void brw_vs_emit(struct brw_vs_compile *c )
        * instructions. Instead, we directly modify the header
        * of the last (already stored) instruction.
        */
-      if (inst->DstReg.File == PROGRAM_OUTPUT) {
+      if (inst->DstReg.File == PROGRAM_OUTPUT &&
+         c->key.clamp_vertex_color) {
          if ((inst->DstReg.Index == VERT_RESULT_COL0)
              || (inst->DstReg.Index == VERT_RESULT_COL1)
              || (inst->DstReg.Index == VERT_RESULT_BFC0)
index ab731a807a7e2f5ccad8af046bf79e8060e88ca2..65af227d83178d81b3b36769cddb434fd4d85dc2 100644 (file)
@@ -363,6 +363,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
    /* _NEW_HINT */
    key->linear_color = (ctx->Hint.PerspectiveCorrection == GL_FASTEST);
 
+   /* _NEW_FRAG_CLAMP | _NEW_BUFFERS */
+   key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
+
    /* _NEW_TEXTURE */
    for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
       const struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
@@ -486,6 +489,7 @@ const struct brw_tracked_state brw_wm_prog = {
                _NEW_POLYGON |
                _NEW_LINE |
                _NEW_LIGHT |
+               _NEW_FRAG_CLAMP |
                _NEW_BUFFERS |
                _NEW_TEXTURE),
       .brw   = (BRW_NEW_FRAGMENT_PROGRAM |
index c40d7bfae0ace73cc1e1cf8c970a150468212065..40659f2602532905f2176f6bbb209f7a29bb6a00 100644 (file)
@@ -65,6 +65,7 @@ struct brw_wm_prog_key {
    GLuint nr_color_regions:5;
    GLuint render_to_fbo:1;
    GLuint alpha_test:1;
+   GLuint clamp_fragment_color:1;
 
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
    GLuint shadowtex_mask:16;
index ecfd21d439961440478747cf2849a9ed4a01fe1a..cdc1f367e5c3aab092c9a064c5d2e48f78cf8a7d 100644 (file)
@@ -1408,6 +1408,9 @@ void emit_fb_write(struct brw_wm_compile *c,
     */
    brw_push_insn_state(p);
 
+   if (c->key.clamp_fragment_color)
+      brw_set_saturate(p, 1);
+
    for (channel = 0; channel < 4; channel++) {
       if (intel->gen >= 6) {
         /* gen6 SIMD16 single source DP write looks like:
@@ -1459,6 +1462,9 @@ void emit_fb_write(struct brw_wm_compile *c,
         }
       }
    }
+
+   brw_set_saturate(p, 0);
+
    /* skip over the regs populated above:
     */
    if (c->dispatch_width == 16)
index d1648a102d4690f63f2f63dd191159db67699c24..1b935fb5e700a42c89a6f8378f003df7a97e8de1 100644 (file)
@@ -210,10 +210,10 @@ color_calc_state_populate_key(struct brw_context *brw,
    if (ctx->Color.AlphaEnabled)
       key->alpha_ref = ctx->Color.AlphaRef;
 
-   key->blend_constant_color[0] = ctx->Color.BlendColor[0];
-   key->blend_constant_color[1] = ctx->Color.BlendColor[1];
-   key->blend_constant_color[2] = ctx->Color.BlendColor[2];
-   key->blend_constant_color[3] = ctx->Color.BlendColor[3];
+   key->blend_constant_color[0] = ctx->Color.BlendColorUnclamped[0];
+   key->blend_constant_color[1] = ctx->Color.BlendColorUnclamped[1];
+   key->blend_constant_color[2] = ctx->Color.BlendColorUnclamped[2];
+   key->blend_constant_color[3] = ctx->Color.BlendColorUnclamped[3];
 }
 
 /**
index ad37a985cc46b41e9f1f2ee0c15cc09cc8fb8820..e107534a4dae3b7eb54bd838e0fa4685e66afd39 100644 (file)
@@ -160,6 +160,7 @@ static const struct dri_extension i915_extensions[] = {
 
 /** i965-only extensions */
 static const struct dri_extension brw_extensions[] = {
+   { "GL_ARB_color_buffer_float",         NULL },
    { "GL_ARB_depth_clamp",                NULL },
    { "GL_ARB_depth_texture",              NULL },
    { "GL_ARB_fragment_coord_conventions", NULL },