[Mesa-dev] [PATCH 5/7] i965: use _mesa_geometry_width/height/layers/samples for programming geometry of framebuffer to GEN

Pohjolainen, Topi topi.pohjolainen at intel.com
Fri Apr 24 06:19:17 PDT 2015


On Fri, Apr 24, 2015 at 09:59:08AM +0300, kevin.rogovin at intel.com wrote:
> From: Kevin Rogovin <kevin.rogovin at intel.com>
> 
> To prepare for i965 to support ARB_framebuffer_no_attachment, use
> the convenience functions mesa_geometry_width/height/layers/samples
> to specify the geometry of the render target surfaces to the GPU.
> 
> 
> ---
>  src/mesa/drivers/dri/i965/brw_clip_state.c         |  9 ++++-
>  src/mesa/drivers/dri/i965/brw_misc_state.c         | 12 ++++--
>  src/mesa/drivers/dri/i965/brw_sf_state.c           | 46 ++++++++++++++++------
>  src/mesa/drivers/dri/i965/brw_state_upload.c       |  7 +++-
>  src/mesa/drivers/dri/i965/brw_wm.c                 |  7 ++--
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c   | 13 ++++--
>  src/mesa/drivers/dri/i965/gen6_clip_state.c        | 11 ++++--
>  src/mesa/drivers/dri/i965/gen6_multisample_state.c |  3 +-
>  src/mesa/drivers/dri/i965/gen6_scissor_state.c     | 14 +++++--
>  src/mesa/drivers/dri/i965/gen6_sf_state.c          |  3 +-
>  src/mesa/drivers/dri/i965/gen6_viewport_state.c    |  3 +-
>  src/mesa/drivers/dri/i965/gen6_wm_state.c          |  3 +-
>  src/mesa/drivers/dri/i965/gen7_sf_state.c          |  3 +-
>  src/mesa/drivers/dri/i965/gen7_viewport_state.c    |  3 +-
>  src/mesa/drivers/dri/i965/gen7_wm_state.c          |  3 +-
>  src/mesa/drivers/dri/i965/gen8_viewport_state.c    |  9 +++--
>  16 files changed, 108 insertions(+), 41 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c
> index 3223834..3aa679f 100644
> --- a/src/mesa/drivers/dri/i965/brw_clip_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
> @@ -32,6 +32,7 @@
>  #include "brw_context.h"
>  #include "brw_state.h"
>  #include "brw_defines.h"
> +#include "main/framebuffer.h"
>  
>  static void
>  upload_clip_vp(struct brw_context *brw)
> @@ -60,6 +61,10 @@ brw_upload_clip_unit(struct brw_context *brw)
>  
>     /* _NEW_BUFFERS */
>     struct gl_framebuffer *fb = ctx->DrawBuffer;
> +   GLint fb_width, fb_height;
> +
> +   fb_width = _mesa_geometric_width(fb);
> +   fb_height = _mesa_geometric_height(fb);

You defined _mesa_geometric_width() and _mesa_geometric_height() to return
unsigned, in principle we should use unsigned here also. But you actually
need them converted to floats so why not convert already the returned
value. Internally in the driver we also try to avoid using gl-types. There
is also no need to separate the declaration and definition of the
variables. I would write this as follows dropping the cast when using them.

      const float fb_width = (float)_mesa_geometric_width(fb);
      const float fb_height = (float)_mesa_geometric_height(fb);

Same applies to the rest of the patch.

>  
>     upload_clip_vp(brw);
>  
> @@ -127,8 +132,8 @@ brw_upload_clip_unit(struct brw_context *brw)
>     /* enable guardband clipping if we can */
>     if (ctx->ViewportArray[0].X == 0 &&
>         ctx->ViewportArray[0].Y == 0 &&
> -       ctx->ViewportArray[0].Width == (float) fb->Width &&
> -       ctx->ViewportArray[0].Height == (float) fb->Height)
> +       ctx->ViewportArray[0].Width == (float) fb_width &&
> +       ctx->ViewportArray[0].Height == (float) fb_height)
>     {
>        clip->clip5.guard_band_enable = 1;
>        clip->clip6.clipper_viewport_state_ptr =
> diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c
> index 78a46cb..ef94a6e 100644
> --- a/src/mesa/drivers/dri/i965/brw_misc_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
> @@ -39,6 +39,7 @@
>  #include "brw_state.h"
>  #include "brw_defines.h"
>  
> +#include "main/framebuffer.h"
>  #include "main/fbobject.h"
>  #include "main/glformats.h"
>  
> @@ -46,12 +47,17 @@
>  static void upload_drawing_rect(struct brw_context *brw)
>  {
>     struct gl_context *ctx = &brw->ctx;
> +   GLint fb_width, fb_height;
> +   struct gl_framebuffer *fb = ctx->DrawBuffer;

Use 'const', you are only reading.

> +
> +   fb_width = _mesa_geometric_width(fb);
> +   fb_height = _mesa_geometric_height(fb);
>  
>     BEGIN_BATCH(4);
>     OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2));
>     OUT_BATCH(0); /* xmin, ymin */
> -   OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0xffff) |
> -	    ((ctx->DrawBuffer->Height - 1) << 16));
> +   OUT_BATCH(((fb_width - 1) & 0xffff) |
> +	    ((fb_height - 1) << 16));
>     OUT_BATCH(0);
>     ADVANCE_BATCH();
>  }
> @@ -767,7 +773,7 @@ static void upload_polygon_stipple_offset(struct brw_context *brw)
>      * works just fine, and there's no window system to worry about.
>      */
>     if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
> -      OUT_BATCH((32 - (ctx->DrawBuffer->Height & 31)) & 31);
> +      OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31);
>     else
>        OUT_BATCH(0);
>     ADVANCE_BATCH();
> diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
> index 014b434..1fa3d44 100644
> --- a/src/mesa/drivers/dri/i965/brw_sf_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
> @@ -35,6 +35,7 @@
>  #include "main/macros.h"
>  #include "main/fbobject.h"
>  #include "main/viewport.h"
> +#include "main/framebuffer.h"
>  #include "brw_context.h"
>  #include "brw_state.h"
>  #include "brw_defines.h"
> @@ -47,18 +48,42 @@ static void upload_sf_vp(struct brw_context *brw)
>     GLfloat y_scale, y_bias;
>     double scale[3], translate[3];
>     const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
> +   GLint fb_width, fb_height, xmin, xmax, ymin, ymax;

I know the original code uses gl-types but we are trying to move away from
them internally - just use int.

>  
>     sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
>  			 sizeof(*sfv), 32, &brw->sf.vp_offset);
>     memset(sfv, 0, sizeof(*sfv));
>  
> +   if (ctx->DrawBuffer->_HasAttachments) {
> +      fb_width = ctx->DrawBuffer->Width;
> +      fb_height = ctx->DrawBuffer->Height;
> +      xmin = ctx->DrawBuffer->_Xmin;
> +      xmax = ctx->DrawBuffer->_Xmax;
> +      ymin = ctx->DrawBuffer->_Ymin;
> +      ymax = ctx->DrawBuffer->_Ymax;
> +   }
> +   else {
> +      int bbox[4];
> +      fb_width = ctx->DrawBuffer->DefaultGeometry.Width;
> +      fb_height = ctx->DrawBuffer->DefaultGeometry.Height;
> +      bbox[0] = 0;
> +      bbox[1] = fb_width;
> +      bbox[2] = 0;
> +      bbox[3] = fb_height;
> +      _mesa_intersect_scissor_bounding_box(ctx, 0, bbox);
> +      xmin = bbox[0];
> +      xmax = bbox[1];
> +      ymin = bbox[2];
> +      ymax = bbox[3];
> +   }
> +
>     if (render_to_fbo) {
>        y_scale = 1.0;
>        y_bias = 0;
>     }
>     else {
>        y_scale = -1.0;
> -      y_bias = ctx->DrawBuffer->Height;
> +      y_bias = fb_height;
>     }
>  
>     /* _NEW_VIEWPORT */
> @@ -83,8 +108,7 @@ static void upload_sf_vp(struct brw_context *brw)
>      * inclusive but max is exclusive.
>      */
>  
> -   if (ctx->DrawBuffer->_Xmin == ctx->DrawBuffer->_Xmax ||
> -       ctx->DrawBuffer->_Ymin == ctx->DrawBuffer->_Ymax) {
> +   if (xmin == xmax || ymin == ymax) {
>        /* If the scissor was out of bounds and got clamped to 0
>         * width/height at the bounds, the subtraction of 1 from
>         * maximums could produce a negative number and thus not clip
> @@ -97,17 +121,17 @@ static void upload_sf_vp(struct brw_context *brw)
>        sfv->scissor.ymax = 0;
>     } else if (render_to_fbo) {
>        /* texmemory: Y=0=bottom */
> -      sfv->scissor.xmin = ctx->DrawBuffer->_Xmin;
> -      sfv->scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
> -      sfv->scissor.ymin = ctx->DrawBuffer->_Ymin;
> -      sfv->scissor.ymax = ctx->DrawBuffer->_Ymax - 1;
> +      sfv->scissor.xmin = xmin;
> +      sfv->scissor.xmax = xmax - 1;
> +      sfv->scissor.ymin = ymin;
> +      sfv->scissor.ymax = ymax - 1;
>     }
>     else {
>        /* memory: Y=0=top */
> -      sfv->scissor.xmin = ctx->DrawBuffer->_Xmin;
> -      sfv->scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
> -      sfv->scissor.ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax;
> -      sfv->scissor.ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1;
> +      sfv->scissor.xmin = xmin;
> +      sfv->scissor.xmax = xmax - 1;
> +      sfv->scissor.ymin = fb_height - ymax;
> +      sfv->scissor.ymax = fb_height - ymin - 1;
>     }
>  
>     brw->ctx.NewDriverState |= BRW_NEW_SF_VP;
> diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
> index ab316bf..5de2f4b 100644
> --- a/src/mesa/drivers/dri/i965/brw_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
> @@ -40,6 +40,7 @@
>  #include "brw_ff_gs.h"
>  #include "brw_gs.h"
>  #include "brw_wm.h"
> +#include "main/framebuffer.h"
>  
>  static const struct brw_tracked_state *gen4_atoms[] =
>  {
> @@ -646,6 +647,7 @@ brw_upload_pipeline_state(struct brw_context *brw,
>     int i;
>     static int dirty_count = 0;
>     struct brw_state_flags state = brw->state.pipelines[pipeline];
> +   GLint fb_samples;
>  
>     if (0) {
>        /* Always re-emit all state. */
> @@ -675,8 +677,9 @@ brw_upload_pipeline_state(struct brw_context *brw,
>        brw->ctx.NewDriverState |= BRW_NEW_META_IN_PROGRESS;
>     }
>  
> -   if (brw->num_samples != ctx->DrawBuffer->Visual.samples) {
> -      brw->num_samples = ctx->DrawBuffer->Visual.samples;
> +   fb_samples = _mesa_geometric_samples(ctx->DrawBuffer);
> +   if (brw->num_samples != fb_samples) {
> +      brw->num_samples = fb_samples;
>        brw->ctx.NewDriverState |= BRW_NEW_NUM_SAMPLES;
>     }
>  
> diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
> index 959f346..52c6e49 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm.c
> @@ -36,6 +36,7 @@
>  #include "main/formats.h"
>  #include "main/fbobject.h"
>  #include "main/samplerobj.h"
> +#include "main/framebuffer.h"
>  #include "program/prog_parameter.h"
>  #include "program/program.h"
>  #include "intel_mipmap_tree.h"
> @@ -454,7 +455,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
>     GLuint lookup = 0;
>     GLuint line_aa;
>     bool program_uses_dfdy = fp->program.UsesDFdy;
> -   bool multisample_fbo = ctx->DrawBuffer->Visual.samples > 1;
> +   bool multisample_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;

You can change this to 'const' as well while you are at it. Makes it easier
to read when you don't need to check if the value got altered before it
is used.

>  
>     memset(key, 0, sizeof(*key));
>  
> @@ -553,7 +554,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
>      * drawable height in order to invert the Y axis.
>      */
>     if (fp->program.Base.InputsRead & VARYING_BIT_POS) {
> -      key->drawable_height = ctx->DrawBuffer->Height;
> +      key->drawable_height = _mesa_geometric_height(ctx->DrawBuffer);
>     }
>  
>     if ((fp->program.Base.InputsRead & VARYING_BIT_POS) || program_uses_dfdy) {
> @@ -572,7 +573,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
>     key->persample_shading =
>        _mesa_get_min_invocations_per_fragment(ctx, &fp->program, true) > 1;
>     if (key->persample_shading)
> -      key->persample_2x = ctx->DrawBuffer->Visual.samples == 2;
> +      key->persample_2x = _mesa_geometric_samples(ctx->DrawBuffer) == 2;
>  
>     key->compute_pos_offset =
>        _mesa_get_min_invocations_per_fragment(ctx, &fp->program, false) > 1 &&
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index 161d140..a1e845b 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -35,6 +35,7 @@
>  #include "main/mtypes.h"
>  #include "main/samplerobj.h"
>  #include "program/prog_parameter.h"
> +#include "main/framebuffer.h"
>  
>  #include "intel_mipmap_tree.h"
>  #include "intel_batchbuffer.h"
> @@ -738,6 +739,11 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw)
>     /* _NEW_BUFFERS */
>     const struct gl_framebuffer *fb = ctx->DrawBuffer;
>     GLuint i;
> +   GLint w, h, s;
> +
> +   w = _mesa_geometric_width(fb);
> +   h = _mesa_geometric_height(fb);
> +   s = _mesa_geometric_samples(fb);
>  
>     /* _NEW_BUFFERS | _NEW_COLOR */
>     /* Update surfaces for drawing buffers */
> @@ -745,13 +751,13 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw)
>        for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
>  	 if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
>  	    brw->vtbl.update_renderbuffer_surface(brw, ctx->DrawBuffer->_ColorDrawBuffers[i],
> -                                                  ctx->DrawBuffer->MaxNumLayers > 0, i);
> +                                                  _mesa_geometric_layers(ctx->DrawBuffer) > 0, i);
>  	 } else {
>              const uint32_t surf_index =
>                 brw->wm.prog_data->binding_table.render_target_start + i;
>  
>              brw->vtbl.emit_null_surface_state(
> -               brw, fb->Width, fb->Height, fb->Visual.samples,
> +               brw, w, h, s,
>                 &brw->wm.base.surf_offset[surf_index]);
>  	 }
>        }
> @@ -759,8 +765,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw)
>        const uint32_t surf_index =
>           brw->wm.prog_data->binding_table.render_target_start;
>  
> -      brw->vtbl.emit_null_surface_state(
> -         brw, fb->Width, fb->Height, fb->Visual.samples,
> +      brw->vtbl.emit_null_surface_state(brw, w, h, s,
>           &brw->wm.base.surf_offset[surf_index]);
>     }
>     brw->ctx.NewDriverState |= BRW_NEW_SURFACES;
> diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c
> index aaf90df..4d23ba5 100644
> --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c
> @@ -31,6 +31,7 @@
>  #include "brw_util.h"
>  #include "intel_batchbuffer.h"
>  #include "main/fbobject.h"
> +#include "main/framebuffer.h"
>  
>  static void
>  upload_clip_state(struct brw_context *brw)
> @@ -145,11 +146,15 @@ upload_clip_state(struct brw_context *brw)
>      * the viewport, so we can ignore this restriction.
>      */
>     if (brw->gen < 8) {
> +      GLint fb_height, fb_width;
> +
> +      fb_width = _mesa_geometric_width(fb);
> +      fb_height = _mesa_geometric_height(fb);
>        for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
>           if (ctx->ViewportArray[i].X != 0 ||
>               ctx->ViewportArray[i].Y != 0 ||
> -             ctx->ViewportArray[i].Width != (float) fb->Width ||
> -             ctx->ViewportArray[i].Height != (float) fb->Height) {
> +             ctx->ViewportArray[i].Width != (float) fb_width ||
> +             ctx->ViewportArray[i].Height != (float) fb_height) {
>              dw2 &= ~GEN6_CLIP_GB_TEST;
>              break;
>           }
> @@ -179,7 +184,7 @@ upload_clip_state(struct brw_context *brw)
>  	     dw2);
>     OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
>               U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
> -             (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX) |
> +             (_mesa_geometric_layers(fb) > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX) |
>               ((ctx->Const.MaxViewports - 1) & GEN6_CLIP_MAX_VP_INDEX_MASK));
>     ADVANCE_BATCH();
>  }
> diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> index ec46479..36734f5 100644
> --- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
> @@ -26,6 +26,7 @@
>  #include "brw_context.h"
>  #include "brw_defines.h"
>  #include "brw_multisample_state.h"
> +#include "main/framebuffer.h"
>  
>  void
>  gen6_get_sample_position(struct gl_context *ctx,
> @@ -34,7 +35,7 @@ gen6_get_sample_position(struct gl_context *ctx,
>  {
>     uint8_t bits;
>  
> -   switch (fb->Visual.samples) {
> +   switch (_mesa_geometric_samples(fb)) {
>     case 1:
>        result[0] = result[1] = 0.5f;
>        return;
> diff --git a/src/mesa/drivers/dri/i965/gen6_scissor_state.c b/src/mesa/drivers/dri/i965/gen6_scissor_state.c
> index 0111f15..106c23b 100644
> --- a/src/mesa/drivers/dri/i965/gen6_scissor_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_scissor_state.c
> @@ -39,11 +39,15 @@ gen6_upload_scissor_state(struct brw_context *brw)
>     const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
>     struct gen6_scissor_rect *scissor;
>     uint32_t scissor_state_offset;
> +   GLint fb_width, fb_height;
>  
> +   fb_width = _mesa_geometric_width(ctx->DrawBuffer);
> +   fb_height = _mesa_geometric_height(ctx->DrawBuffer);
>     scissor = brw_state_batch(brw, AUB_TRACE_SCISSOR_STATE,
>  			     sizeof(*scissor) * ctx->Const.MaxViewports, 32,
>                               &scissor_state_offset);
>  
> +
>     /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT */
>  
>     /* The scissor only needs to handle the intersection of drawable and
> @@ -56,7 +60,11 @@ gen6_upload_scissor_state(struct brw_context *brw)
>     for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
>        int bbox[4];
>  
> -      _mesa_scissor_bounding_box(ctx, ctx->DrawBuffer, i, bbox);
> +      bbox[0] = 0;
> +      bbox[1] = fb_width;
> +      bbox[2] = 0;
> +      bbox[3] = fb_height;
> +      _mesa_intersect_scissor_bounding_box(ctx, i, bbox);
>  
>        if (bbox[0] == bbox[1] || bbox[2] == bbox[3]) {
>           /* If the scissor was out of bounds and got clamped to 0 width/height
> @@ -80,8 +88,8 @@ gen6_upload_scissor_state(struct brw_context *brw)
>           /* memory: Y=0=top */
>           scissor[i].xmin = bbox[0];
>           scissor[i].xmax = bbox[1] - 1;
> -         scissor[i].ymin = ctx->DrawBuffer->Height - bbox[3];
> -         scissor[i].ymax = ctx->DrawBuffer->Height - bbox[2] - 1;
> +         scissor[i].ymin = fb_height - bbox[3];
> +         scissor[i].ymax = fb_height - bbox[2] - 1;
>        }
>     }
>     BEGIN_BATCH(2);
> diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c b/src/mesa/drivers/dri/i965/gen6_sf_state.c
> index ea5c47a..dba20ed 100644
> --- a/src/mesa/drivers/dri/i965/gen6_sf_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c
> @@ -31,6 +31,7 @@
>  #include "brw_util.h"
>  #include "main/macros.h"
>  #include "main/fbobject.h"
> +#include "main/framebuffer.h"
>  #include "intel_batchbuffer.h"
>  
>  /**
> @@ -273,7 +274,7 @@ upload_sf_state(struct brw_context *brw)
>     int i;
>     /* _NEW_BUFFER */
>     bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
> -   bool multisampled_fbo = ctx->DrawBuffer->Visual.samples > 1;
> +   bool multisampled_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
>  
>     const int urb_entry_read_offset = BRW_SF_URB_ENTRY_READ_OFFSET;
>     float point_size;
> diff --git a/src/mesa/drivers/dri/i965/gen6_viewport_state.c b/src/mesa/drivers/dri/i965/gen6_viewport_state.c
> index 0c63283..8125477 100644
> --- a/src/mesa/drivers/dri/i965/gen6_viewport_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_viewport_state.c
> @@ -30,6 +30,7 @@
>  #include "brw_defines.h"
>  #include "intel_batchbuffer.h"
>  #include "main/fbobject.h"
> +#include "main/framebuffer.h"
>  #include "main/viewport.h"
>  
>  /* The clip VP defines the guardband region where expensive clipping is skipped
> @@ -94,7 +95,7 @@ gen6_upload_sf_vp(struct brw_context *brw)
>        y_bias = 0;
>     } else {
>        y_scale = -1.0;
> -      y_bias = ctx->DrawBuffer->Height;
> +      y_bias = _mesa_geometric_height(ctx->DrawBuffer);
>     }
>  
>     /* _NEW_VIEWPORT */
> diff --git a/src/mesa/drivers/dri/i965/gen6_wm_state.c b/src/mesa/drivers/dri/i965/gen6_wm_state.c
> index 8e673a4..2a2abc7 100644
> --- a/src/mesa/drivers/dri/i965/gen6_wm_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_wm_state.c
> @@ -33,6 +33,7 @@
>  #include "program/program.h"
>  #include "program/prog_parameter.h"
>  #include "program/prog_statevars.h"
> +#include "main/framebuffer.h"
>  #include "intel_batchbuffer.h"
>  
>  static void
> @@ -77,7 +78,7 @@ upload_wm_state(struct brw_context *brw)
>     uint32_t dw2, dw4, dw5, dw6, ksp0, ksp2;
>  
>     /* _NEW_BUFFERS */
> -   bool multisampled_fbo = ctx->DrawBuffer->Visual.samples > 1;
> +   bool multisampled_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
>  
>     /* We can't fold this into gen6_upload_wm_push_constants(), because
>      * according to the SNB PRM, vol 2 part 1 section 7.2.2
> diff --git a/src/mesa/drivers/dri/i965/gen7_sf_state.c b/src/mesa/drivers/dri/i965/gen7_sf_state.c
> index 69853e6..99cb43f 100644
> --- a/src/mesa/drivers/dri/i965/gen7_sf_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_sf_state.c
> @@ -27,6 +27,7 @@
>  #include "brw_util.h"
>  #include "main/macros.h"
>  #include "main/fbobject.h"
> +#include "main/framebuffer.h"
>  #include "intel_batchbuffer.h"
>  
>  static void
> @@ -109,7 +110,7 @@ upload_sf_state(struct brw_context *brw)
>     float point_size;
>     /* _NEW_BUFFERS */
>     bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
> -   bool multisampled_fbo = ctx->DrawBuffer->Visual.samples > 1;
> +   bool multisampled_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
>  
>     dw1 = GEN6_SF_STATISTICS_ENABLE;
>  
> diff --git a/src/mesa/drivers/dri/i965/gen7_viewport_state.c b/src/mesa/drivers/dri/i965/gen7_viewport_state.c
> index eb59684..7f0b4f5 100644
> --- a/src/mesa/drivers/dri/i965/gen7_viewport_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_viewport_state.c
> @@ -26,6 +26,7 @@
>  #include "brw_defines.h"
>  #include "intel_batchbuffer.h"
>  #include "main/fbobject.h"
> +#include "main/framebuffer.h"
>  #include "main/viewport.h"
>  
>  static void
> @@ -48,7 +49,7 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw)
>        y_bias = 0;
>     } else {
>        y_scale = -1.0;
> -      y_bias = ctx->DrawBuffer->Height;
> +      y_bias = _mesa_geometric_height(ctx->DrawBuffer);
>     }
>  
>     for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
> diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c
> index 923414e..82e116c 100644
> --- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
> @@ -30,6 +30,7 @@
>  #include "program/program.h"
>  #include "program/prog_parameter.h"
>  #include "program/prog_statevars.h"
> +#include "main/framebuffer.h"
>  #include "intel_batchbuffer.h"
>  
>  static void
> @@ -45,7 +46,7 @@ upload_wm_state(struct brw_context *brw)
>     uint32_t dw1, dw2;
>  
>     /* _NEW_BUFFERS */
> -   bool multisampled_fbo = ctx->DrawBuffer->Visual.samples > 1;
> +   bool multisampled_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
>  
>     dw1 = dw2 = 0;
>     dw1 |= GEN7_WM_STATISTICS_ENABLE;
> diff --git a/src/mesa/drivers/dri/i965/gen8_viewport_state.c b/src/mesa/drivers/dri/i965/gen8_viewport_state.c
> index 322e466..b312859 100644
> --- a/src/mesa/drivers/dri/i965/gen8_viewport_state.c
> +++ b/src/mesa/drivers/dri/i965/gen8_viewport_state.c
> @@ -26,6 +26,7 @@
>  #include "brw_defines.h"
>  #include "intel_batchbuffer.h"
>  #include "main/fbobject.h"
> +#include "main/framebuffer.h"
>  #include "main/viewport.h"
>  
>  static void
> @@ -33,6 +34,7 @@ gen8_upload_sf_clip_viewport(struct brw_context *brw)
>  {
>     struct gl_context *ctx = &brw->ctx;
>     float y_scale, y_bias;
> +   GLint fb_height;
>     const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
>  
>     float *vp = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
> @@ -40,6 +42,7 @@ gen8_upload_sf_clip_viewport(struct brw_context *brw)
>                                 64, &brw->sf.vp_offset);
>     /* Also assign to clip.vp_offset in case something uses it. */
>     brw->clip.vp_offset = brw->sf.vp_offset;
> +   fb_height = _mesa_geometric_height(ctx->DrawBuffer);
>  
>     /* _NEW_BUFFERS */
>     if (render_to_fbo) {
> @@ -47,7 +50,7 @@ gen8_upload_sf_clip_viewport(struct brw_context *brw)
>        y_bias = 0;
>     } else {
>        y_scale = -1.0;
> -      y_bias = ctx->DrawBuffer->Height;
> +      y_bias = fb_height;
>     }
>  
>     for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
> @@ -116,8 +119,8 @@ gen8_upload_sf_clip_viewport(struct brw_context *brw)
>        } else {
>           vp[12] = ctx->ViewportArray[i].X;
>           vp[13] = viewport_Xmax - 1;
> -         vp[14] = ctx->DrawBuffer->Height - viewport_Ymax;
> -         vp[15] = ctx->DrawBuffer->Height - ctx->ViewportArray[i].Y - 1;
> +         vp[14] = fb_height - viewport_Ymax;
> +         vp[15] = fb_height - ctx->ViewportArray[i].Y - 1;
>        }
>  
>        vp += 16;
> -- 
> 1.9.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list