Mesa (gallium-fb-dimensions): gallium: remove width, height fields from pipe_framebuffer_state

Keith Whitwell keithw at kemper.freedesktop.org
Thu Jan 7 15:58:59 UTC 2010


Module: Mesa
Branch: gallium-fb-dimensions
Commit: 94d4989e06bd0c0a66b55ebf94b3a472ec5e258e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=94d4989e06bd0c0a66b55ebf94b3a472ec5e258e

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Jan  7 15:34:50 2010 +0000

gallium: remove width, height fields from pipe_framebuffer_state

These won't be meaningful for drivers which support mixed size
rendertargets.

Add utility functions to retreive the equivalent data from the new
framebuffer struct.

Update drivers and state-trackers accordingly.

---

 src/gallium/auxiliary/cso_cache/cso_context.c     |    2 -
 src/gallium/auxiliary/util/u_blit.c               |    4 -
 src/gallium/auxiliary/util/u_blitter.c            |    5 -
 src/gallium/auxiliary/util/u_gen_mipmap.c         |    2 -
 src/gallium/auxiliary/util/u_surface.c            |  112 +++++++++++++++++++--
 src/gallium/auxiliary/util/u_surface.h            |   15 +++
 src/gallium/auxiliary/vl/vl_compositor.c          |   10 +-
 src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c  |    4 -
 src/gallium/drivers/i915/i915_state.c             |   14 +--
 src/gallium/drivers/i965/brw_context.h            |    8 ++
 src/gallium/drivers/i965/brw_misc_state.c         |    4 +-
 src/gallium/drivers/i965/brw_pipe_fb.c            |   15 ++-
 src/gallium/drivers/r300/r300_blit.c              |    4 +-
 src/gallium/drivers/r300/r300_state.c             |   18 +++-
 src/gallium/drivers/softpipe/sp_state_derived.c   |   11 ++-
 src/gallium/drivers/softpipe/sp_state_surface.c   |    2 +
 src/gallium/drivers/svga/svga_context.h           |    6 +
 src/gallium/drivers/svga/svga_pipe_misc.c         |   20 ++--
 src/gallium/drivers/svga/svga_state_framebuffer.c |    8 +-
 src/gallium/drivers/trace/tr_dump_state.c         |    2 -
 src/gallium/include/pipe/p_state.h                |    7 +-
 src/mesa/state_tracker/st_atom_framebuffer.c      |    5 -
 22 files changed, 198 insertions(+), 80 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 2b16332..3099446 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -945,8 +945,6 @@ copy_framebuffer_state(struct pipe_framebuffer_state *dst,
 {
    uint i;
 
-   dst->width = src->width;
-   dst->height = src->height;
    dst->nr_cbufs = src->nr_cbufs;
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]);
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 3f74e2a..cff5d2b 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -432,8 +432,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
 
    /* drawing dest */
    memset(&fb, 0, sizeof(fb));
-   fb.width = dst->width;
-   fb.height = dst->height;
    fb.nr_cbufs = 1;
    fb.cbufs[0] = dst;
    cso_set_framebuffer(ctx->cso, &fb);
@@ -564,8 +562,6 @@ util_blit_pixels_tex(struct blit_state *ctx,
 
    /* drawing dest */
    memset(&fb, 0, sizeof(fb));
-   fb.width = dst->width;
-   fb.height = dst->height;
    fb.nr_cbufs = 1;
    fb.cbufs[0] = dst;
    cso_set_framebuffer(ctx->cso, &fb);
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index cef3b69..84ab771 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -612,9 +612,6 @@ void util_blitter_copy(struct blitter_context *blitter,
    assert(src->texture->target < PIPE_MAX_TEXTURE_TYPES);
 
    /* bind CSOs */
-   fb_state.width = dst->width;
-   fb_state.height = dst->height;
-
    if (is_depth) {
       pipe->bind_blend_state(pipe, ctx->blend_keep_color);
       pipe->bind_depth_stencil_alpha_state(pipe,
@@ -712,8 +709,6 @@ void util_blitter_fill(struct blitter_context *blitter,
    pipe->bind_vs_state(pipe, ctx->vs_col);
 
    /* set a framebuffer state */
-   fb_state.width = dst->width;
-   fb_state.height = dst->height;
    fb_state.nr_cbufs = 1;
    fb_state.cbufs[0] = dst;
    fb_state.zsbuf = 0;
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 7602379..2023720 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1531,8 +1531,6 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
        * Setup framebuffer / dest surface
        */
       fb.cbufs[0] = surf;
-      fb.width = u_minify(pt->width0, dstLevel);
-      fb.height = u_minify(pt->height0, dstLevel);
       cso_set_framebuffer(ctx->cso, &fb);
 
       /*
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index bcc8529..c089396 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -39,6 +39,7 @@
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_surface.h"
+#include "util/u_math.h"
 
 
 /**
@@ -113,6 +114,109 @@ util_destroy_rgba_surface(struct pipe_texture *texture,
 }
 
 
+/**
+ * Where framebuffer surfaces are required to have the same size, find
+ * that size.
+ *
+ * \return TRUE if same, FALSE if different
+ */
+boolean
+util_framebuffer_uniform_size(const struct pipe_framebuffer_state *fb,
+                              unsigned *width,
+                              unsigned *height)
+{
+   int i;
+
+   if (fb->cbufs[0]) {
+      *width = fb->cbufs[0]->width;
+      *height = fb->cbufs[0]->height;
+      goto found;
+   }
+
+   if (fb->zsbuf) {
+      *width = fb->zsbuf->width;
+      *height = fb->zsbuf->height;
+      goto found;
+   }
+
+   *width = 0;
+   *height = 0;
+   return FALSE;
+
+found:
+   /* On debug builds, check that all surfaces match in size:
+    */
+   for (i = 0; i < fb->nr_cbufs; i++) {
+      assert(*width == fb->cbufs[i]->width);
+      assert(*height == fb->cbufs[i]->height);
+   }
+
+   if (fb->zsbuf) {
+      assert(*width == fb->zsbuf->width);
+      assert(*height == fb->zsbuf->height);
+   }
+
+   return TRUE;
+}
+
+/* Where multiple sizes are allowed for framebuffer surfaces, find the
+ * minimum width and height of all bound surfaces.
+ */
+boolean
+util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
+                              unsigned *width,
+                              unsigned *height)
+{
+   unsigned w = ~0;
+   unsigned h = ~0;
+   unsigned i;
+
+   for (i = 0; i < fb->nr_cbufs; i++) {
+      w = MIN2(w, fb->cbufs[i]->width);
+      h = MIN2(h, fb->cbufs[i]->height);
+   }
+
+   if (fb->zsbuf) {
+      w = MIN2(w, fb->zsbuf->width);
+      h = MIN2(h, fb->zsbuf->height);
+   }
+
+   *width = w;
+   *height = h;
+
+   return w != ~0;
+}
+
+/* Where multiple sizes are allowed for framebuffer surfaces, find the
+ * maximum width and height of all bound surfaces.
+ */
+boolean
+util_framebuffer_max_size(const struct pipe_framebuffer_state *fb,
+                              unsigned *width,
+                              unsigned *height)
+{
+   unsigned w = 0;
+   unsigned h = 0;
+   unsigned i;
+
+   for (i = 0; i < fb->nr_cbufs; i++) {
+      w = MAX2(w, fb->cbufs[i]->width);
+      h = MAX2(h, fb->cbufs[i]->height);
+   }
+
+   if (fb->zsbuf) {
+      w = MAX2(w, fb->zsbuf->width);
+      h = MAX2(h, fb->zsbuf->height);
+   }
+
+   *width = w;
+   *height = h;
+
+   return w != 0;
+}
+
+
+
 
 /**
  * Compare pipe_framebuffer_state objects.
@@ -124,10 +228,6 @@ util_framebuffer_state_equal(const struct pipe_framebuffer_state *dst,
 {
    unsigned i;
 
-   if (dst->width != src->width ||
-       dst->height != src->height)
-      return FALSE;
-
    for (i = 0; i < Elements(src->cbufs); i++) {
       if (dst->cbufs[i] != src->cbufs[i]) {
          return FALSE;
@@ -155,9 +255,6 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst,
 {
    unsigned i;
 
-   dst->width = src->width;
-   dst->height = src->height;
-
    for (i = 0; i < Elements(src->cbufs); i++) {
       pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]);
    }
@@ -179,6 +276,5 @@ util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb)
 
    pipe_surface_reference(&fb->zsbuf, NULL);
 
-   fb->width = fb->height = 0;
    fb->nr_cbufs = 0;
 }
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index 3c60df2..48e182d 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -71,6 +71,21 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst,
                             const struct pipe_framebuffer_state *src);
 
 
+extern boolean
+util_framebuffer_max_size(const struct pipe_framebuffer_state *fb,
+                          unsigned *width,
+                          unsigned *height);
+
+extern boolean
+util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
+                          unsigned *width,
+                          unsigned *height);
+
+extern boolean
+util_framebuffer_uniform_size(const struct pipe_framebuffer_state *fb,
+                              unsigned *width,
+                              unsigned *height);
+
 extern void
 util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb);
 
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index fc2a1c5..0ee712b 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -453,8 +453,6 @@ void vl_compositor_render(struct vl_compositor          *compositor,
    assert(dst_area);
    assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
 
-   compositor->fb_state.width = dst_surface->width0;
-   compositor->fb_state.height = dst_surface->height0;
    compositor->fb_state.cbufs[0] = compositor->pipe->screen->get_tex_surface
    (
       compositor->pipe->screen,
@@ -462,8 +460,8 @@ void vl_compositor_render(struct vl_compositor          *compositor,
       0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE
    );
 
-   compositor->viewport.scale[0] = compositor->fb_state.width;
-   compositor->viewport.scale[1] = compositor->fb_state.height;
+   compositor->viewport.scale[0] = dst_surface->width0;
+   compositor->viewport.scale[1] = dst_surface->height0;
    compositor->viewport.scale[2] = 1;
    compositor->viewport.scale[3] = 1;
    compositor->viewport.translate[0] = 0;
@@ -471,8 +469,8 @@ void vl_compositor_render(struct vl_compositor          *compositor,
    compositor->viewport.translate[2] = 0;
    compositor->viewport.translate[3] = 0;
 
-   compositor->scissor.maxx = compositor->fb_state.width;
-   compositor->scissor.maxy = compositor->fb_state.height;
+   compositor->scissor.maxx = dst_surface->width0;
+   compositor->scissor.maxy = dst_surface->height0;
 
    compositor->pipe->set_framebuffer_state(compositor->pipe, &compositor->fb_state);
    compositor->pipe->set_viewport_state(compositor->pipe, &compositor->viewport);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index caf581a..a88ae9a 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -729,10 +729,6 @@ init_pipe_state(struct vl_mpeg12_mc_renderer *r)
    r->scissor.maxy = r->pot_buffers ?
       util_next_power_of_two(r->picture_height) : r->picture_height;
 
-   r->fb_state.width = r->pot_buffers ?
-      util_next_power_of_two(r->picture_width) : r->picture_width;
-   r->fb_state.height = r->pot_buffers ?
-      util_next_power_of_two(r->picture_height) : r->picture_height;
    r->fb_state.nr_cbufs = 1;
    r->fb_state.zsbuf = NULL;
 
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 5f5b6f8..9bb7536 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -34,6 +34,7 @@
 #include "pipe/p_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_surface.h"
 #include "tgsi/tgsi_parse.h"
 
 #include "i915_context.h"
@@ -591,18 +592,13 @@ static void i915_set_framebuffer_state(struct pipe_context *pipe,
 				       const struct pipe_framebuffer_state *fb)
 {
    struct i915_context *i915 = i915_context(pipe);
-   int i;
 
+   if (util_framebuffer_state_equal( &i915->framebuffer, fb ))
+      return;
+      
    draw_flush(i915->draw);
 
-   i915->framebuffer.width = fb->width;
-   i915->framebuffer.height = fb->height;
-   i915->framebuffer.nr_cbufs = fb->nr_cbufs;
-   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
-      pipe_surface_reference(&i915->framebuffer.cbufs[i], fb->cbufs[i]);
-   }
-   pipe_surface_reference(&i915->framebuffer.zsbuf, fb->zsbuf);
-
+   util_copy_framebuffer_state( &i915->framebuffer, fb );
    i915->dirty |= I915_NEW_FRAMEBUFFER;
 }
 
diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h
index 8c006bb..ccdd1a6 100644
--- a/src/gallium/drivers/i965/brw_context.h
+++ b/src/gallium/drivers/i965/brw_context.h
@@ -568,7 +568,15 @@ struct brw_context
       struct brw_blend_constant_color bcc;
       struct brw_polygon_stipple bps;
       struct brw_cc_viewport ccv;
+      
+      /* Framebuffer dimensions.
+       *
+       * Updates are signaled by PIPE_NEW_FRAMEBUFFER_DIMENSIONS
+       */
+      unsigned fb_width;
+      unsigned fb_height;
 
+      
       /**
        * Index buffer for this draw_prims call.
        *
diff --git a/src/gallium/drivers/i965/brw_misc_state.c b/src/gallium/drivers/i965/brw_misc_state.c
index e4b2422..83641c6 100644
--- a/src/gallium/drivers/i965/brw_misc_state.c
+++ b/src/gallium/drivers/i965/brw_misc_state.c
@@ -71,8 +71,8 @@ static int upload_drawing_rect(struct brw_context *brw)
    BEGIN_BATCH(4, NO_LOOP_CLIPRECTS);
    OUT_BATCH(_3DSTATE_DRAWRECT_INFO_I965);
    OUT_BATCH(0);
-   OUT_BATCH(((brw->curr.fb.width - 1) & 0xffff) |
-	    ((brw->curr.fb.height - 1) << 16));
+   OUT_BATCH(((brw->curr.fb_width - 1) & 0xffff) |
+             ((brw->curr.fb_height - 1) << 16));
    OUT_BATCH(0);
    ADVANCE_BATCH();
    return 0;
diff --git a/src/gallium/drivers/i965/brw_pipe_fb.c b/src/gallium/drivers/i965/brw_pipe_fb.c
index 5d4e502..19cd2d2 100644
--- a/src/gallium/drivers/i965/brw_pipe_fb.c
+++ b/src/gallium/drivers/i965/brw_pipe_fb.c
@@ -1,4 +1,5 @@
 #include "util/u_math.h"
+#include "util/u_surface.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 
@@ -12,14 +13,20 @@ static void brw_set_framebuffer_state( struct pipe_context *pipe,
 				       const struct pipe_framebuffer_state *fb )
 {
    struct brw_context *brw = brw_context(pipe);
+   unsigned fb_width, fb_height;
    unsigned i;
 
+   if (util_framebuffer_state_equal( &brw->curr.fb, fb ))
+      return;
+
+   util_framebuffer_uniform_size( fb, &fb_width, &fb_height );
+
    /* Dimensions:
     */
-   if (brw->curr.fb.width != fb->width ||
-       brw->curr.fb.height != fb->height) {
-      brw->curr.fb.width = fb->width;
-      brw->curr.fb.height = fb->height;
+   if (brw->curr.fb_width != fb_width ||
+       brw->curr.fb_height != fb_height) {
+      brw->curr.fb_width = fb_width;
+      brw->curr.fb_height = fb_height;
       brw->state.dirty.mesa |= PIPE_NEW_FRAMEBUFFER_DIMENSIONS;
    }
    
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index ffe066d..53f0839 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -79,8 +79,8 @@ void r300_clear(struct pipe_context* pipe,
     r300_blitter_save_states(r300);
 
     util_blitter_clear(r300->blitter,
-                       r300->framebuffer_state.width,
-                       r300->framebuffer_state.height,
+                       r300->framebuffer_width,
+                       r300->framebuffer_height,
                        r300->framebuffer_state.nr_cbufs,
                        buffers, rgba, depth, stencil);
 }
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index a145a7f..4060e46 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -508,11 +508,21 @@ static void
         draw_flush(r300->draw);
     }
 
-    r300->framebuffer_state = *state;
-
+    /* Copy state and adjust surface refcounts:
+     */
+    util_copy_framebuffer_state( &r300->framebuffer_state, state );
+
+    /* r300 supports only matching MRT sizes:
+     */
+    util_framebuffer_uniform_size( state, 
+                                   &r300->framebuffer_width,
+                                   &r300->framebuffer_height );
+
+    /* Set up scissor state.
+     */
     scissor.minx = scissor.miny = 0;
-    scissor.maxx = state->width;
-    scissor.maxy = state->height;
+    scissor.maxx = r300->framebuffer_width;
+    scissor.maxy = r300->framebuffer_height;
     r300_set_scissor_regs(&scissor, &r300->scissor_state->framebuffer,
                           r300_screen(r300->context.screen)->caps->is_r500);
 
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index f6856a5..1c931b9 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -165,10 +165,15 @@ softpipe_get_vbuf_vertex_info(struct softpipe_context *softpipe)
 static void
 compute_cliprect(struct softpipe_context *sp)
 {
-   /* SP_NEW_FRAMEBUFFER
+   /* This used to track framebuffer width/height, but that's a fairly
+    * meaningless concept for once we allow multiple rendertargets of
+    * differing sizes.  It will be down to the handling of individual
+    * rendertarget read/writes to ensure that no stray pixels exceed
+    * rendertarget bounds.  Possibly there could be one of these
+    * cliprects computed per rendertarget.
     */
-   uint surfWidth = sp->framebuffer.width;
-   uint surfHeight = sp->framebuffer.height;
+   uint surfWidth = 100000;
+   uint surfHeight = 100000;
 
    /* SP_NEW_RASTERIZER
     */
diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index f615410..c0c5382 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -97,8 +97,10 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
       }
    }
 
+   /*
    sp->framebuffer.width = fb->width;
    sp->framebuffer.height = fb->height;
+   */
 
    sp->dirty |= SP_NEW_FRAMEBUFFER;
 }
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index 66259fd..a5e5faf 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -203,6 +203,12 @@ struct svga_state
    struct pipe_clip_state clip;
    struct pipe_viewport_state viewport;
 
+   /* We support only matched-size framebuffer surfaces, so can
+    * calculate a single width/height for the current fb:
+    */
+   unsigned fb_width;
+   unsigned fb_height;
+
    unsigned num_samplers;
    unsigned num_textures;
    unsigned num_vertex_elements;
diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c
index 58cb1e6..6f353f9 100644
--- a/src/gallium/drivers/svga/svga_pipe_misc.c
+++ b/src/gallium/drivers/svga/svga_pipe_misc.c
@@ -81,8 +81,6 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe,
    boolean propagate = FALSE;
    int i;
 
-   dst->width = fb->width;
-   dst->height = fb->height;
    dst->nr_cbufs = fb->nr_cbufs;
 
    /* check if we need to propaget any of the target surfaces */
@@ -101,14 +99,16 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe,
             svga_propagate_surface(pipe, dst->cbufs[i]);
    }
 
-   /* XXX: Actually the virtual hardware may support rendertargets with
-    * different size, depending on the host API and driver, but since we cannot
-    * know that make no such assumption here. */
-   for(i = 0; i < fb->nr_cbufs; ++i) {
-      if (fb->zsbuf && fb->cbufs[i]) {
-         assert(fb->zsbuf->width == fb->cbufs[i]->width); 
-         assert(fb->zsbuf->height == fb->cbufs[i]->height); 
-      }
+   /* XXX: Actually the virtual hardware may support rendertargets
+    * with different size, depending on the host API and driver, but
+    * since we cannot know that make no such assumption here.  Hence
+    * we do not advertise the ALLOW_FB_MIXED_SIZES capability.
+    */
+   if (!util_get_framebuffer_size( fb,
+                                   &svga->curr.fb_width,
+                                   &svga->curr.fb_height ))
+   {
+      assert(0);
    }
 
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c
index cfdcae4..e78ce9a 100644
--- a/src/gallium/drivers/svga/svga_state_framebuffer.c
+++ b/src/gallium/drivers/svga/svga_state_framebuffer.c
@@ -119,8 +119,8 @@ static int emit_viewport( struct svga_context *svga,
    boolean degenerate = FALSE;
    enum pipe_error ret;
 
-   float fb_width = svga->curr.framebuffer.width;
-   float fb_height = svga->curr.framebuffer.height;
+   float fb_width = svga->curr.fb_width;
+   float fb_height = svga->curr.fb_height;
 
    memset( &prescale, 0, sizeof(prescale) );
 
@@ -131,8 +131,8 @@ static int emit_viewport( struct svga_context *svga,
        */
       rect.x = 0;
       rect.y = 0;
-      rect.w = svga->curr.framebuffer.width;
-      rect.h = svga->curr.framebuffer.height;
+      rect.w = svga->curr.fb_width;
+      rect.h = svga->curr.fb_height;
 
       prescale.scale[0] = 2.0 / (float)rect.w;
       prescale.scale[1] = - 2.0 / (float)rect.h;
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index 86237e0..8355e92 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -381,8 +381,6 @@ void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
 
    trace_dump_struct_begin("pipe_framebuffer_state");
 
-   trace_dump_member(uint, state, width);
-   trace_dump_member(uint, state, height);
    trace_dump_member(uint, state, nr_cbufs);
    trace_dump_member_array(ptr, state, cbufs);
    trace_dump_member(ptr, state, zsbuf);
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 60e96b9..e6ad684 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -258,13 +258,12 @@ struct pipe_blend_color
 
 struct pipe_framebuffer_state
 {
-   unsigned width, height;
-
+   /** Z/stencil buffer */
+   struct pipe_surface *zsbuf;
+ 
    /** multiple colorbuffers for multiple render targets */
    unsigned nr_cbufs;
    struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS];
-
-   struct pipe_surface *zsbuf;      /**< Z/stencil buffer */
 };
 
 
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 8ca4335..e90bc5e 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -100,11 +100,6 @@ update_framebuffer_state( struct st_context *st )
    struct st_renderbuffer *strb;
    GLuint i;
 
-   framebuffer->width = fb->Width;
-   framebuffer->height = fb->Height;
-
-   /*printf("------ fb size %d x %d\n", fb->Width, fb->Height);*/
-
    /* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state
     * to determine which surfaces to draw to
     */




More information about the mesa-commit mailing list