r600g: fix depth hw resource copies.
[mesa.git] / src / gallium / drivers / r600 / r600_texture.c
index 7b38337eda567da9c69f0e2a8b93a642ab731f0d..c773c4b84a6d6967b7c9198c61b1857050041ab6 100644 (file)
@@ -278,6 +278,36 @@ 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;
+
+       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 +331,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 +354,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)
 {