r600/sfn: Reduce array limit for scratch usage
[mesa.git] / src / gallium / drivers / r600 / r600_texture.c
index 27565e0aa0c6d7c6a571c99b5cd62a7cd8f497ef..5c8b9dd4af997a0b2d4b9d369f682decefc43a63 100644 (file)
 #include "r600_pipe_common.h"
 #include "r600_cs.h"
 #include "r600_query.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 #include "util/u_log.h"
 #include "util/u_memory.h"
 #include "util/u_pack_color.h"
 #include "util/u_surface.h"
 #include "util/os_time.h"
+#include "state_tracker/winsys_handle.h"
 #include <errno.h>
 #include <inttypes.h>
 
@@ -366,7 +367,7 @@ static void r600_reallocate_texture_inplace(struct r600_common_context *rctx,
        templ.bind |= new_bind_flag;
 
        /* r600g doesn't react to dirty_tex_descriptor_counter */
-       if (rctx->chip_class < SI)
+       if (rctx->chip_class < GFX6)
                return;
 
        if (rtex->resource.b.is_shared)
@@ -468,11 +469,11 @@ static void r600_texture_get_info(struct pipe_screen* screen,
                *poffset = offset;
 }
 
-static boolean r600_texture_get_handle(struct pipe_screen* screen,
-                                      struct pipe_context *ctx,
-                                      struct pipe_resource *resource,
-                                      struct winsys_handle *whandle,
-                                       unsigned usage)
+static bool r600_texture_get_handle(struct pipe_screen* screen,
+                                   struct pipe_context *ctx,
+                                   struct pipe_resource *resource,
+                                   struct winsys_handle *whandle,
+                                   unsigned usage)
 {
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct r600_common_context *rctx;
@@ -519,9 +520,6 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
                /* Set metadata. */
                if (!res->b.is_shared || update_metadata) {
                        r600_texture_init_metadata(rscreen, rtex, &metadata);
-                       if (rscreen->query_opaque_metadata)
-                               rscreen->query_opaque_metadata(rscreen, rtex,
-                                                              &metadata);
 
                        rscreen->ws->buffer_set_metadata(res->buf, &metadata);
                }
@@ -572,8 +570,10 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
                res->external_usage = usage;
        }
 
-       return rscreen->ws->buffer_get_handle(res->buf, stride, offset,
-                                             slice_size, whandle);
+       whandle->stride = stride;
+       whandle->offset = offset + slice_size * whandle->layer;
+
+       return rscreen->ws->buffer_get_handle(rscreen->ws, res->buf, whandle);
 }
 
 static void r600_texture_destroy(struct pipe_screen *screen,
@@ -762,7 +762,7 @@ static void r600_texture_get_htile_size(struct r600_common_screen *rscreen,
        rtex->surface.htile_size = 0;
 
        if (rscreen->chip_class <= EVERGREEN &&
-           rscreen->info.drm_major == 2 && rscreen->info.drm_minor < 26)
+           rscreen->info.drm_minor < 26)
                return;
 
        /* HW bug on R6xx. */
@@ -1118,7 +1118,6 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
 {
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct pb_buffer *buf = NULL;
-       unsigned stride = 0, offset = 0;
        enum radeon_surf_mode array_mode;
        struct radeon_surf surface = {};
        int r;
@@ -1132,8 +1131,7 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
                return NULL;
 
        buf = rscreen->ws->buffer_from_handle(rscreen->ws, whandle,
-                                             rscreen->info.max_alignment,
-                                             &stride, &offset);
+                                             rscreen->info.max_alignment);
        if (!buf)
                return NULL;
 
@@ -1141,8 +1139,9 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
        r600_surface_import_metadata(rscreen, &surface, &metadata,
                                     &array_mode, &is_scanout);
 
-       r = r600_init_surface(rscreen, &surface, templ, array_mode, stride,
-                             offset, true, is_scanout, false);
+       r = r600_init_surface(rscreen, &surface, templ, array_mode,
+                             whandle->stride, whandle->offset,
+                             true, is_scanout, false);
        if (r) {
                return NULL;
        }
@@ -1154,9 +1153,6 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
        rtex->resource.b.is_shared = true;
        rtex->resource.external_usage = usage;
 
-       if (rscreen->apply_opaque_metadata)
-               rscreen->apply_opaque_metadata(rscreen, rtex, &metadata);
-
        assert(rtex->surface.tile_swizzle == 0);
        return &rtex->resource.b.b;
 }
@@ -1264,7 +1260,7 @@ static bool r600_can_invalidate_texture(struct r600_common_screen *rscreen,
                                        const struct pipe_box *box)
 {
        /* r600g doesn't react to dirty_tex_descriptor_counter */
-       return rscreen->chip_class >= SI &&
+       return rscreen->chip_class >= GFX6 &&
                !rtex->resource.b.is_shared &&
                !(transfer_usage & PIPE_TRANSFER_READ) &&
                rtex->resource.b.b.last_level == 0 &&
@@ -1639,11 +1635,11 @@ static void r600_clear_texture(struct pipe_context *pipe,
 
                /* Depth is always present. */
                clear = PIPE_CLEAR_DEPTH;
-               desc->unpack_z_float(&depth, 0, data, 0, 1, 1);
+               util_format_unpack_z_float(tex->format, &depth, data, 1);
 
                if (rtex->surface.has_stencil) {
                        clear |= PIPE_CLEAR_STENCIL;
-                       desc->unpack_s_8uint(&stencil, 0, data, 0, 1, 1);
+                       util_format_unpack_s_8uint(tex->format, &stencil, data, 1);
                }
 
                pipe->clear_depth_stencil(pipe, sf, clear, depth, stencil,
@@ -1652,13 +1648,7 @@ static void r600_clear_texture(struct pipe_context *pipe,
        } else {
                union pipe_color_union color;
 
-               /* pipe_color_union requires the full vec4 representation. */
-               if (util_format_is_pure_uint(tex->format))
-                       desc->unpack_rgba_uint(color.ui, 0, data, 0, 1, 1);
-               else if (util_format_is_pure_sint(tex->format))
-                       desc->unpack_rgba_sint(color.i, 0, data, 0, 1, 1);
-               else
-                       desc->unpack_rgba_float(color.f, 0, data, 0, 1, 1);
+               util_format_unpack_rgba(tex->format, color.ui, data, 1);
 
                if (screen->is_format_supported(screen, tex->format,
                                                tex->target, 0, 0,
@@ -1755,12 +1745,8 @@ static void evergreen_set_clear_color(struct r600_texture *rtex,
                       color->ui[0] == color->ui[2]);
                uc.ui[0] = color->ui[0];
                uc.ui[1] = color->ui[3];
-       } else if (util_format_is_pure_uint(surface_format)) {
-               util_format_write_4ui(surface_format, color->ui, 0, &uc, 0, 0, 0, 1, 1);
-       } else if (util_format_is_pure_sint(surface_format)) {
-               util_format_write_4i(surface_format, color->i, 0, &uc, 0, 0, 0, 1, 1);
        } else {
-               util_pack_color(color->f, surface_format, &uc);
+               util_pack_color_union(surface_format, &uc, color);
        }
 
        memcpy(rtex->color_clear_value, &uc, 2 * sizeof(uint32_t));
@@ -1775,7 +1761,7 @@ void evergreen_do_fast_color_clear(struct r600_common_context *rctx,
        int i;
 
        /* This function is broken in BE, so just disable this path for now */
-#ifdef PIPE_ARCH_BIG_ENDIAN
+#if UTIL_ARCH_BIG_ENDIAN
        return;
 #endif
 
@@ -1871,14 +1857,12 @@ r600_memobj_from_handle(struct pipe_screen *screen,
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct r600_memory_object *memobj = CALLOC_STRUCT(r600_memory_object);
        struct pb_buffer *buf = NULL;
-       uint32_t stride, offset;
 
        if (!memobj)
                return NULL;
 
        buf = rscreen->ws->buffer_from_handle(rscreen->ws, whandle,
-                                             rscreen->info.max_alignment,
-                                             &stride, &offset);
+                                             rscreen->info.max_alignment);
        if (!buf) {
                free(memobj);
                return NULL;
@@ -1886,8 +1870,8 @@ r600_memobj_from_handle(struct pipe_screen *screen,
 
        memobj->b.dedicated = dedicated;
        memobj->buf = buf;
-       memobj->stride = stride;
-       memobj->offset = offset;
+       memobj->stride = whandle->stride;
+       memobj->offset = whandle->offset;
 
        return (struct pipe_memory_object *)memobj;
 
@@ -1970,9 +1954,6 @@ r600_texture_from_memobj(struct pipe_screen *screen,
        rtex->resource.b.is_shared = true;
        rtex->resource.external_usage = PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE;
 
-       if (rscreen->apply_opaque_metadata)
-               rscreen->apply_opaque_metadata(rscreen, rtex, &metadata);
-
        return &rtex->resource.b.b;
 }