dri: Support MESA_FORMAT_SARGB8 in driCreateConfigs
[mesa.git] / src / mesa / drivers / dri / i965 / brw_blorp.cpp
index 6acc59187d461e2ff6259ebc27723c65cb8e3b7f..77b9f8fb3c92e6f21e58c2e5d08a64e53324607a 100644 (file)
@@ -53,14 +53,7 @@ brw_blorp_mip_info::set(struct intel_mipmap_tree *mt,
    this->width = mt->level[level].width;
    this->height = mt->level[level].height;
 
-   /* Construct a dummy renderbuffer just to extract tile offsets. */
-   struct intel_renderbuffer rb;
-   rb.mt = mt;
-   rb.mt_level = level;
-   rb.mt_layer = layer;
-   intel_renderbuffer_set_draw_offset(&rb);
-   x_offset = rb.draw_x;
-   y_offset = rb.draw_y;
+   intel_miptree_get_image_offset(mt, level, 0, layer, &x_offset, &y_offset);
 }
 
 void
@@ -102,11 +95,10 @@ brw_blorp_surface_info::set(struct brw_context *brw,
       this->brw_surfaceformat = BRW_SURFACEFORMAT_R8G8_UNORM;
       break;
    default:
-      /* Blorp blits don't support any sort of format conversion, so we can
-       * safely assume that the same format is being used for the source and
-       * destination.  Therefore the format must be supported as a render
-       * target, even if this is the source image.  So we can convert to a
-       * surface format using brw->render_target_format.
+      /* Blorp blits don't support any sort of format conversion (except
+       * between sRGB and linear), so we can safely assume that the format is
+       * supported as a render target, even if this is the source image.  So
+       * we can convert to a surface format using brw->render_target_format.
        */
       assert(brw->format_supported_as_render_target[mt->format]);
       this->brw_surfaceformat = brw->render_target_format[mt->format];
@@ -114,6 +106,33 @@ brw_blorp_surface_info::set(struct brw_context *brw,
    }
 }
 
+
+/**
+ * Split x_offset and y_offset into a base offset (in bytes) and a remaining
+ * x/y offset (in pixels).  Note: we can't do this by calling
+ * intel_renderbuffer_tile_offsets(), because the offsets may have been
+ * adjusted to account for Y vs. W tiling differences.  So we compute it
+ * directly from the adjusted offsets.
+ */
+uint32_t
+brw_blorp_surface_info::compute_tile_offsets(uint32_t *tile_x,
+                                             uint32_t *tile_y) const
+{
+   struct intel_region *region = mt->region;
+   uint32_t mask_x, mask_y;
+
+   intel_region_get_tile_masks(region, &mask_x, &mask_y,
+                               map_stencil_as_y_tiled);
+
+   *tile_x = x_offset & mask_x;
+   *tile_y = y_offset & mask_y;
+
+   return intel_region_get_aligned_offset(region, x_offset & ~mask_x,
+                                          y_offset & ~mask_y,
+                                          map_stencil_as_y_tiled);
+}
+
+
 brw_blorp_params::brw_blorp_params()
    : x0(0),
      y0(0),