intel: use intel_rb_format() to get renderbuffer format
authorBrian Paul <brianp@vmware.com>
Mon, 16 Jan 2012 19:29:11 +0000 (12:29 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 24 Jan 2012 21:12:29 +0000 (14:12 -0700)
This will make future changes cleaner and less invasive.

src/mesa/drivers/dri/i915/i830_vtbl.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_blit.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h
src/mesa/drivers/dri/intel/intel_pixel_copy.c
src/mesa/drivers/dri/intel/intel_tex_copy.c

index 513acb938f1cf0e2cde6a55038ce53c83a6e553f..082372e2c5d4817c2165c2f07ed1b40c16e20226 100644 (file)
@@ -642,7 +642,7 @@ i830_set_draw_region(struct intel_context *intel,
             DSTORG_VERT_BIAS(0x8) | DEPTH_IS_Z);    /* .5 */
 
    if (irb != NULL) {
-      value |= i830_render_target_format_for_mesa_format[irb->Base.Format];
+      value |= i830_render_target_format_for_mesa_format[intel_rb_format(irb)];
    }
 
    if (depth_region && depth_region->cpp == 4) {
@@ -803,7 +803,7 @@ i830_update_draw_buffer(struct intel_context *intel)
 
    /* Check for stencil fallback. */
    if (irbStencil && irbStencil->mt) {
-      assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+      assert(intel_rb_format(irbStencil) == MESA_FORMAT_S8_Z24);
       FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, false);
    } else if (irbStencil && !irbStencil->mt) {
       FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, true);
@@ -816,7 +816,7 @@ i830_update_draw_buffer(struct intel_context *intel)
     * we still need to set up the shared depth/stencil state so we can use it.
     */
    if (depthRegion == NULL && irbStencil && irbStencil->mt
-       && irbStencil->Base.Format == MESA_FORMAT_S8_Z24) {
+       && intel_rb_format(irbStencil) == MESA_FORMAT_S8_Z24) {
       depthRegion = irbStencil->mt->region;
    }
 
index e938af84bf56bc55fd3c672ee36eca4d9c3e946b..62bfa0abf49687d7e7f3671a9409043d0e2dd5c0 100644 (file)
@@ -607,7 +607,7 @@ i915_set_draw_region(struct intel_context *intel,
             DSTORG_VERT_BIAS(0x8) |     /* .5 */
             LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL);
    if (irb != NULL) {
-      value |= i915_render_target_format_for_mesa_format[irb->Base.Format];
+      value |= i915_render_target_format_for_mesa_format[intel_rb_format(irb)];
    } else {
       value |= DV_PF_8888;
    }
@@ -775,7 +775,7 @@ i915_update_draw_buffer(struct intel_context *intel)
 
    /* Check for stencil fallback. */
    if (irbStencil && irbStencil->mt) {
-      assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+      assert(intel_rb_format(irbStencil) == MESA_FORMAT_S8_Z24);
       FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, false);
    } else if (irbStencil && !irbStencil->mt) {
       FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, true);
@@ -788,7 +788,7 @@ i915_update_draw_buffer(struct intel_context *intel)
     * we still need to set up the shared depth/stencil state so we can use it.
     */
    if (depthRegion == NULL && irbStencil && irbStencil->mt
-       && irbStencil->Base.Format == MESA_FORMAT_S8_Z24) {
+       && intel_rb_format(irbStencil) == MESA_FORMAT_S8_Z24) {
       depthRegion = irbStencil->mt->region;
    }
 
index 1a7d32824729a5d2b8d8ee1cff577ec34849d896..68e1e80d3b38199832719b66b238874df347d141 100644 (file)
@@ -209,8 +209,8 @@ brw_depthbuffer_format(struct brw_context *brw)
    if (!drb &&
        (srb = intel_get_renderbuffer(fb, BUFFER_STENCIL)) &&
        !srb->mt->stencil_mt &&
-       (srb->Base.Format == MESA_FORMAT_S8_Z24 ||
-       srb->Base.Format == MESA_FORMAT_Z32_FLOAT_X24S8)) {
+       (intel_rb_format(srb) == MESA_FORMAT_S8_Z24 ||
+       intel_rb_format(srb) == MESA_FORMAT_Z32_FLOAT_X24S8)) {
       drb = srb;
    }
 
@@ -246,7 +246,7 @@ brw_depthbuffer_format(struct brw_context *brw)
       return BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT;
    default:
       _mesa_problem(ctx, "Unexpected depth format %s\n",
-                   _mesa_get_format_name(drb->Base.Format));
+                   _mesa_get_format_name(intel_rb_format(drb)));
       return BRW_DEPTHFORMAT_D16_UNORM;
    }
 }
index ef270e78b25fd3209351b9a398827babbabed046..7fd83ea984c399961ac2fbacc362a1efb1a52b4e 100644 (file)
@@ -906,24 +906,25 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
    uint32_t *surf;
    uint32_t tile_x, tile_y;
    uint32_t format = 0;
+   gl_format rb_format = intel_rb_format(irb);
 
    surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
                          6 * 4, 32, &brw->bind.surf_offset[unit]);
 
-   switch (irb->Base.Format) {
+   switch (rb_format) {
    case MESA_FORMAT_SARGB8:
       /* without GL_EXT_framebuffer_sRGB we shouldn't bind sRGB
         surfaces to the blend/update as sRGB */
       if (ctx->Color.sRGBEnabled)
-        format = brw_format_for_mesa_format(irb->Base.Format);
+        format = brw_format_for_mesa_format(rb_format);
       else
         format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
       break;
    default:
-      format = brw->render_target_format[irb->Base.Format];
-      if (unlikely(!brw->format_supported_as_render_target[irb->Base.Format])) {
+      format = brw->render_target_format[rb_format];
+      if (unlikely(!brw->format_supported_as_render_target[rb_format])) {
         _mesa_problem(ctx, "%s: renderbuffer format %s unsupported\n",
-                      __FUNCTION__, _mesa_get_format_name(irb->Base.Format));
+                      __FUNCTION__, _mesa_get_format_name(rb_format));
       }
       break;
    }
index 70a0bc986e26c60795ddd933aa4374d448c33d4b..d429adcfd60a5238f43d833d179ac433ddc6fc34 100644 (file)
@@ -200,6 +200,7 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
    struct intel_region *region = irb->mt->region;
    struct gen7_surface_state *surf;
    uint32_t tile_x, tile_y;
+   gl_format rb_format = intel_rb_format(irb);
 
    surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
                          sizeof(*surf), 32, &brw->bind.surf_offset[unit]);
@@ -210,21 +211,21 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
    if (irb->mt->align_w == 8)
       surf->ss0.horizontal_alignment = 1;
 
-   switch (irb->Base.Format) {
+   switch (rb_format) {
    case MESA_FORMAT_SARGB8:
       /* without GL_EXT_framebuffer_sRGB we shouldn't bind sRGB
         surfaces to the blend/update as sRGB */
       if (ctx->Color.sRGBEnabled)
-        surf->ss0.surface_format = brw_format_for_mesa_format(irb->Base.Format);
+        surf->ss0.surface_format = brw_format_for_mesa_format(rb_format);
       else
         surf->ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
       break;
    default:
-      assert(brw_render_target_supported(intel, irb->Base.Format));
-      surf->ss0.surface_format = brw->render_target_format[irb->Base.Format];
-      if (unlikely(!brw->format_supported_as_render_target[irb->Base.Format])) {
+      assert(brw_render_target_supported(intel, rb_format));
+      surf->ss0.surface_format = brw->render_target_format[rb_format];
+      if (unlikely(!brw->format_supported_as_render_target[rb_format])) {
         _mesa_problem(ctx, "%s: renderbuffer format %s unsupported\n",
-                      __FUNCTION__, _mesa_get_format_name(irb->Base.Format));
+                      __FUNCTION__, _mesa_get_format_name(rb_format));
       }
        break;
    }
index e484fd34bfd14b0373357bab1f9903efe8688602..9eacadd213cb5f2a6d208f096f0d38aa15f603c1 100644 (file)
@@ -328,7 +328,7 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask)
 
         _mesa_unclamped_float_rgba_to_ubyte(clear, color);
 
-        switch (irb->Base.Format) {
+        switch (intel_rb_format(irb)) {
         case MESA_FORMAT_ARGB8888:
         case MESA_FORMAT_XRGB8888:
            clear_val = PACK_COLOR_8888(clear[3], clear[0],
index ecc03a21be5b541f14e19ce5f10669fd3de3c362..30a01bb48f4fa612e91806a4b2a20bf1478fca00 100644 (file)
@@ -225,7 +225,7 @@ intel_flush_front(struct gl_context *ctx)
 static unsigned
 intel_bits_per_pixel(const struct intel_renderbuffer *rb)
 {
-   return _mesa_get_format_bytes(rb->Base.Format) * 8;
+   return _mesa_get_format_bytes(intel_rb_format(rb)) * 8;
 }
 
 static void
@@ -1066,7 +1066,7 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
 
       rb->mt = intel_miptree_create_for_region(intel,
                                                GL_TEXTURE_2D,
-                                               rb->Base.Format,
+                                               intel_rb_format(rb),
                                                region);
       intel_region_release(&region);
       if (!rb->mt)
@@ -1163,7 +1163,7 @@ intel_query_dri2_buffers_with_separate_stencil(struct intel_context *intel,
       (*attachments)[i++] = __DRI_BUFFER_DEPTH;
       (*attachments)[i++] = intel_bits_per_pixel(depth_rb);
 
-      if (intel->vtbl.is_hiz_depth_format(intel, depth_rb->Base.Format)) {
+      if (intel->vtbl.is_hiz_depth_format(intel, intel_rb_format(depth_rb))) {
         /* Depth and hiz buffer have same bpp. */
         (*attachments)[i++] = __DRI_BUFFER_HIZ;
         (*attachments)[i++] = intel_bits_per_pixel(depth_rb);
@@ -1171,7 +1171,7 @@ intel_query_dri2_buffers_with_separate_stencil(struct intel_context *intel,
    }
 
    if (stencil_rb) {
-      assert(stencil_rb->Base.Format == MESA_FORMAT_S8);
+      assert(intel_rb_format(stencil_rb) == MESA_FORMAT_S8);
       (*attachments)[i++] = __DRI_BUFFER_STENCIL;
       (*attachments)[i++] = intel_bits_per_pixel(stencil_rb);
    }
@@ -1283,7 +1283,7 @@ intel_process_dri2_buffer_with_separate_stencil(struct intel_context *intel,
    struct intel_mipmap_tree *mt =
       intel_miptree_create_for_region(intel,
                                      GL_TEXTURE_2D,
-                                     rb->Base.Format,
+                                     intel_rb_format(rb),
                                      region);
    intel_region_release(&region);
 
@@ -1366,8 +1366,8 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
        */
       struct intel_renderbuffer *depth_rb =
         intel_get_renderbuffer(fb, BUFFER_DEPTH);
-      assert(stencil_rb->Base.Format == MESA_FORMAT_S8);
-      assert(depth_rb && depth_rb->Base.Format == MESA_FORMAT_X8_Z24);
+      assert(intel_rb_format(stencil_rb) == MESA_FORMAT_S8);
+      assert(depth_rb && intel_rb_format(depth_rb) == MESA_FORMAT_X8_Z24);
 
       if (stencil_rb->mt->region->tiling == I915_TILING_NONE) {
         /*
@@ -1456,7 +1456,7 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
         struct intel_mipmap_tree *mt =
               intel_miptree_create_for_region(intel,
                                               GL_TEXTURE_2D,
-                                              depth_stencil_rb->Base.Format,
+                                              intel_rb_format(depth_stencil_rb),
                                               region);
         intel_region_release(&region);
         if (!mt)
index 5463776aeb6746a4f0620cea71724820da3946e9..2e400e7d5c58be79363fcee8b34658a1f3b32367 100644 (file)
@@ -822,16 +822,16 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
         continue;
       }
 
-      if (!intel->vtbl.render_target_supported(intel, irb->Base.Format)) {
+      if (!intel->vtbl.render_target_supported(intel, intel_rb_format(irb))) {
         DBG("Unsupported HW texture/renderbuffer format attached: %s\n",
-            _mesa_get_format_name(irb->Base.Format));
+            _mesa_get_format_name(intel_rb_format(irb)));
         fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
       }
 
 #ifdef I915
-      if (!intel_span_supports_format(irb->Base.Format)) {
+      if (!intel_span_supports_format(intel_rb_format(irb))) {
         DBG("Unsupported swrast texture/renderbuffer format attached: %s\n",
-            _mesa_get_format_name(irb->Base.Format));
+            _mesa_get_format_name(intel_rb_format(irb)));
         fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
       }
 #endif
index edba8e66226af61cc3943a5bc3604a2223288ecd..5a0d865739b4bf8d3111fbcd379dcdef319f3ae8 100644 (file)
@@ -115,6 +115,14 @@ intel_get_renderbuffer(struct gl_framebuffer *fb, gl_buffer_index attIndex)
    return intel_renderbuffer(rb);
 }
 
+
+static INLINE gl_format
+intel_rb_format(const struct intel_renderbuffer *rb)
+{
+   return rb->Base.Format;
+}
+
+
 bool
 intel_framebuffer_has_hiz(struct gl_framebuffer *fb);
 
index 2682e152abc5d5c7d0948048cb5956c7eb9da76f..18a807508b3e4496ce43fed06b3389c80565f136 100644 (file)
@@ -88,6 +88,7 @@ do_blit_copypixels(struct gl_context * ctx,
    bool flip = false;
    struct intel_renderbuffer *draw_irb = NULL;
    struct intel_renderbuffer *read_irb = NULL;
+   gl_format read_format, draw_format;
 
    /* Update draw buffer bounds */
    _mesa_update_state(ctx);
@@ -128,12 +129,15 @@ do_blit_copypixels(struct gl_context * ctx,
       return false;
    }
 
-   if (draw_irb->Base.Format != read_irb->Base.Format &&
-       !(draw_irb->Base.Format == MESA_FORMAT_XRGB8888 &&
-        read_irb->Base.Format == MESA_FORMAT_ARGB8888)) {
+   read_format = intel_rb_format(read_irb);
+   draw_format = intel_rb_format(draw_irb);
+
+   if (draw_format != read_format &&
+       !(draw_format == MESA_FORMAT_XRGB8888 &&
+        read_format == MESA_FORMAT_ARGB8888)) {
       fallback_debug("glCopyPixels() fallback: mismatched formats (%s -> %s\n",
-                    _mesa_get_format_name(read_irb->Base.Format),
-                    _mesa_get_format_name(draw_irb->Base.Format));
+                    _mesa_get_format_name(read_format),
+                     _mesa_get_format_name(draw_format));
       return false;
    }
 
index b6e29f78de6ef79321e630af9efd2237a2a3350a..8617302856d00fe10c86d5d74fbef5e7a4758e04 100644 (file)
@@ -69,16 +69,16 @@ intel_copy_texsubimage(struct intel_context *intel,
       assert(region);
    }
 
-   copy_supported = intelImage->base.Base.TexFormat == irb->Base.Format;
+   copy_supported = intelImage->base.Base.TexFormat == intel_rb_format(irb);
 
    /* Converting ARGB8888 to XRGB8888 is trivial: ignore the alpha bits */
-   if (irb->Base.Format == MESA_FORMAT_ARGB8888 &&
+   if (intel_rb_format(irb) == MESA_FORMAT_ARGB8888 &&
        intelImage->base.Base.TexFormat == MESA_FORMAT_XRGB8888) {
       copy_supported = true;
    }
 
    /* Converting XRGB8888 to ARGB8888 requires setting the alpha bits to 1.0 */
-   if (irb->Base.Format == MESA_FORMAT_XRGB8888 &&
+   if (intel_rb_format(irb) == MESA_FORMAT_XRGB8888 &&
        intelImage->base.Base.TexFormat == MESA_FORMAT_ARGB8888) {
       copy_supported_with_alpha_override = true;
    }
@@ -88,7 +88,7 @@ intel_copy_texsubimage(struct intel_context *intel,
         fprintf(stderr, "%s mismatched formats %s, %s\n",
                 __FUNCTION__,
                 _mesa_get_format_name(intelImage->base.Base.TexFormat),
-                _mesa_get_format_name(irb->Base.Format));
+                _mesa_get_format_name(intel_rb_format(irb)));
       return false;
    }