r600g: work around ddx over alignment
[mesa.git] / src / gallium / drivers / r600 / r600_texture.c
index d6d1b3daff621cebe6435dd7cf6ffd5ef6ddff40..937345156c3a76ed86ff5bbeac136ab9c3d0a19e 100644 (file)
@@ -89,7 +89,8 @@ static int r600_init_surface(struct r600_screen *rscreen,
                             struct radeon_surface *surface,
                             const struct pipe_resource *ptex,
                             unsigned array_mode,
-                            bool is_flushed_depth)
+                            bool is_flushed_depth,
+                            bool from_ddx)
 {
        const struct util_format_description *desc =
                util_format_description(ptex->format);
@@ -107,6 +108,10 @@ static int r600_init_surface(struct r600_screen *rscreen,
        surface->array_size = 1;
        surface->last_level = ptex->last_level;
 
+       if (from_ddx) {
+               surface->npix_y = align(surface->npix_y, 8);
+       }
+
        if (rscreen->chip_class >= EVERGREEN && !is_flushed_depth &&
            ptex->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
                surface->bpe = 4; /* stencil is allocated separately on evergreen */
@@ -443,7 +448,7 @@ r600_texture_create_object(struct pipe_screen *screen,
                unsigned base_align = rtex->surface.bo_alignment;
                unsigned usage = R600_TEX_IS_TILED(rtex, 0) ? PIPE_USAGE_STATIC : base->usage;
 
-               if (!r600_init_resource(rscreen, resource, rtex->size, base_align, base->bind, usage)) {
+               if (!r600_init_resource(rscreen, resource, rtex->size, base_align, FALSE, usage)) {
                        FREE(rtex);
                        return NULL;
                }
@@ -539,7 +544,8 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
        }
 
        r = r600_init_surface(rscreen, &surface, templ, array_mode,
-                             templ->flags & R600_RESOURCE_FLAG_FLUSHED_DEPTH);
+                             templ->flags & R600_RESOURCE_FLAG_FLUSHED_DEPTH,
+                             false);
        if (r) {
                return NULL;
        }
@@ -567,7 +573,6 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
        surface->base.format = templ->format;
        surface->base.width = width;
        surface->base.height = height;
-       surface->base.usage = templ->usage;
        surface->base.u = templ->u;
        return &surface->base;
 }
@@ -628,7 +633,7 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
        else
                array_mode = V_038000_ARRAY_LINEAR_ALIGNED;
 
-       r = r600_init_surface(rscreen, &surface, templ, array_mode, false);
+       r = r600_init_surface(rscreen, &surface, templ, array_mode, false, true);
        if (r) {
                return NULL;
        }