r600g: only set depth bit for hw accessible depth buffers.
authorDave Airlie <airlied@redhat.com>
Thu, 3 Feb 2011 03:19:30 +0000 (13:19 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 3 Feb 2011 04:18:01 +0000 (14:18 +1000)
If we get a sw accessible buffer like the S8 texture we end up
doing depth tracking on it when there is no need since we won't
ever bind it to the hardware. This leads to a sw fallback in the
transfer destruction which leads to and endless recusion loop
of fail in transfer destroy.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/r600_texture.c

index 7b38337eda567da9c69f0e2a8b93a642ab731f0d..1d0e482253e44e6756f68e688b5e2dc150111a1c 100644 (file)
@@ -278,6 +278,45 @@ static void r600_setup_miptree(struct pipe_screen *screen,
        rtex->size = offset;
 }
 
+/* Figure out whether u_blitter will fallback to a transfer operation.
+ * If so, don't use a staging resource.
+ */
+static boolean permit_hardware_blit(struct pipe_screen *screen,
+                                       const struct pipe_resource *res)
+{
+       unsigned bind;
+
+       if (util_format_is_depth_or_stencil(res->format))
+               bind = PIPE_BIND_DEPTH_STENCIL;
+       else
+               bind = PIPE_BIND_RENDER_TARGET;
+
+       /* See r600_resource_copy_region: there is something wrong
+        * with depth resource copies at the moment so avoid them for
+        * now.
+        */
+       if (util_format_get_component_bits(res->format,
+                               UTIL_FORMAT_COLORSPACE_ZS,
+                               0) != 0)
+               return FALSE;
+
+       if (!screen->is_format_supported(screen,
+                               res->format,
+                               res->target,
+                               res->nr_samples,
+                               bind, 0))
+               return FALSE;
+
+       if (!screen->is_format_supported(screen,
+                               res->format,
+                               res->target,
+                               res->nr_samples,
+                               PIPE_BIND_SAMPLER_VIEW, 0))
+               return FALSE;
+
+       return TRUE;
+}
+
 static struct r600_resource_texture *
 r600_texture_create_object(struct pipe_screen *screen,
                           const struct pipe_resource *base,
@@ -301,8 +340,8 @@ r600_texture_create_object(struct pipe_screen *screen,
        resource->base.b.screen = screen;
        resource->bo = bo;
        rtex->pitch_override = pitch_in_bytes_override;
-
-       if (util_format_is_depth_or_stencil(base->format))
+       /* only mark depth textures the HW can hit as depth textures */
+       if (util_format_is_depth_or_stencil(base->format) && permit_hardware_blit(screen, base))
                rtex->depth = 1;
 
        if (array_mode)
@@ -324,45 +363,6 @@ r600_texture_create_object(struct pipe_screen *screen,
        return rtex;
 }
 
-/* Figure out whether u_blitter will fallback to a transfer operation.
- * If so, don't use a staging resource.
- */
-static boolean permit_hardware_blit(struct pipe_screen *screen,
-                                       const struct pipe_resource *res)
-{
-       unsigned bind;
-
-       if (util_format_is_depth_or_stencil(res->format))
-               bind = PIPE_BIND_DEPTH_STENCIL;
-       else
-               bind = PIPE_BIND_RENDER_TARGET;
-
-       /* See r600_resource_copy_region: there is something wrong
-        * with depth resource copies at the moment so avoid them for
-        * now.
-        */
-       if (util_format_get_component_bits(res->format,
-                               UTIL_FORMAT_COLORSPACE_ZS,
-                               0) != 0)
-               return FALSE;
-
-       if (!screen->is_format_supported(screen,
-                               res->format,
-                               res->target,
-                               res->nr_samples,
-                               bind, 0))
-               return FALSE;
-
-       if (!screen->is_format_supported(screen,
-                               res->format,
-                               res->target,
-                               res->nr_samples,
-                               PIPE_BIND_SAMPLER_VIEW, 0))
-               return FALSE;
-
-       return TRUE;
-}
-
 struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
                                                const struct pipe_resource *templ)
 {