[Mesa-dev] [PATCH 08/10] i965: Respect the VERTEX_PROGRAM_TWO_SIDE flag for shaders.

Paul Berry stereotype441 at gmail.com
Fri Sep 9 09:18:49 PDT 2011


On 8 September 2011 23:32, Eric Anholt <eric at anholt.net> wrote:

> Fixes piglit:
> vertex-program-two-side
> vertex-program-two-side primary
> vertex-program-two-side secondary
> ---
>  src/mesa/drivers/dri/i965/brw_vs_constval.c |    6 +++---
>  src/mesa/drivers/dri/i965/gen6_sf_state.c   |    5 +++--
>  src/mesa/drivers/dri/i965/gen7_sf_state.c   |    6 ++----
>  3 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c
> b/src/mesa/drivers/dri/i965/brw_vs_constval.c
> index 67af23e..4d1c4e0 100644
> --- a/src/mesa/drivers/dri/i965/brw_vs_constval.c
> +++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c
> @@ -197,8 +197,8 @@ static void calc_wm_input_sizes( struct brw_context
> *brw )
>
>    memset(&t, 0, sizeof(t));
>
> -   /* _NEW_LIGHT */
> -   if (ctx->Light.Model.TwoSide)
> +   /* _NEW_LIGHT | _NEW_PROGRAM */
> +   if (ctx->VertexProgram._TwoSideEnabled)
>       t.twoside = 1;
>
>    for (i = 0; i < VERT_ATTRIB_MAX; i++)
> @@ -233,7 +233,7 @@ static void calc_wm_input_sizes( struct brw_context
> *brw )
>
>  const struct brw_tracked_state brw_wm_input_sizes = {
>    .dirty = {
> -      .mesa  = _NEW_LIGHT,
> +      .mesa  = _NEW_LIGHT | _NEW_PROGRAM,
>       .brw   = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_INPUT_DIMENSIONS,
>       .cache = 0
>    },
> diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c
> b/src/mesa/drivers/dri/i965/gen6_sf_state.c
> index 4a9c094..bb8bc83 100644
> --- a/src/mesa/drivers/dri/i965/gen6_sf_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c
> @@ -115,7 +115,6 @@ upload_sf_state(struct brw_context *brw)
>    GLboolean render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
>    int attr = 0, input_index = 0;
>    int urb_entry_read_offset;
> -   int two_side_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
>    float point_size;
>    uint16_t attr_overrides[FRAG_ATTRIB_MAX];
>    int nr_userclip;
> @@ -285,9 +284,10 @@ upload_sf_state(struct brw_context *brw)
>        */
>       assert(input_index < 16 || attr == input_index);
>
> +      /* _NEW_LIGHT | _NEW_PROGRAM */
>       attr_overrides[input_index++] =
>          get_attr_override(&vue_map, urb_entry_read_offset, attr,
> -                           two_side_color);
> +                           ctx->VertexProgram._TwoSideEnabled);
>    }
>
>    for (; input_index < FRAG_ATTRIB_MAX; input_index++)
> @@ -315,6 +315,7 @@ upload_sf_state(struct brw_context *brw)
>  const struct brw_tracked_state gen6_sf_state = {
>    .dirty = {
>       .mesa  = (_NEW_LIGHT |
> +               _NEW_PROGRAM |
>                _NEW_POLYGON |
>                _NEW_LINE |
>                _NEW_SCISSOR |
> diff --git a/src/mesa/drivers/dri/i965/gen7_sf_state.c
> b/src/mesa/drivers/dri/i965/gen7_sf_state.c
> index af98041..85d2d87 100644
> --- a/src/mesa/drivers/dri/i965/gen7_sf_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_sf_state.c
> @@ -45,9 +45,6 @@ upload_sbe_state(struct brw_context *brw)
>    /* _NEW_TRANSFORM */
>    int urb_entry_read_offset = ctx->Transform.ClipPlanesEnabled ? 2 : 1;
>    int nr_userclip = brw_count_bits(ctx->Transform.ClipPlanesEnabled);
> -
> -   /* _NEW_LIGHT */
> -   int two_side_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
>    uint16_t attr_overrides[FRAG_ATTRIB_MAX];
>
>    brw_compute_vue_map(&vue_map, intel, nr_userclip, vs_outputs_written);
> @@ -104,7 +101,7 @@ upload_sbe_state(struct brw_context *brw)
>
>       attr_overrides[input_index++] =
>          get_attr_override(&vue_map, urb_entry_read_offset, attr,
> -                           two_side_color);
> +                           ctx->VertexProgram._TwoSideEnabled);
>    }
>
>    for (; attr < FRAG_ATTRIB_MAX; attr++)
> @@ -276,6 +273,7 @@ upload_sf_state(struct brw_context *brw)
>  const struct brw_tracked_state gen7_sf_state = {
>    .dirty = {
>       .mesa  = (_NEW_LIGHT |
> +               _NEW_PROGRAM |
>                _NEW_POLYGON |
>                _NEW_LINE |
>                _NEW_SCISSOR |
> --
> 1.7.5.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>

For Gen4 and Gen5, similar changes will have to be made to brw_clip.c:

        switch (ctx->Polygon.FrontFace) {
        case GL_CCW:
           key.fill_ccw = fill_front;
           key.fill_cw = fill_back;
           key.offset_ccw = offset_front;
           key.offset_cw = offset_back;
           if (ctx->Light.Model.TwoSide &&
           key.fill_cw != CLIP_CULL)
          key.copy_bfc_cw = 1;
           break;
        case GL_CW:
           key.fill_cw = fill_front;
           key.fill_ccw = fill_back;
           key.offset_cw = offset_front;
           key.offset_ccw = offset_back;
           if (ctx->Light.Model.TwoSide &&
           key.fill_ccw != CLIP_CULL)
          key.copy_bfc_ccw = 1;
           break;
        }

and to brw_sf.c:

   key.do_twoside_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110909/38a44361/attachment.html>


More information about the mesa-dev mailing list