r600g,radeonsi: consolidate create_surface and surface_destroy
authorMarek Olšák <marek.olsak@amd.com>
Sun, 9 Feb 2014 22:25:06 +0000 (23:25 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 25 Feb 2014 15:08:26 +0000 (16:08 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeonsi/si_blit.c
src/gallium/drivers/radeonsi/si_state.c

index 5f9e8b7af9869d579cbb43c528b160a9bb1f0069..1ca2c90794aa9e3a6670e3c5eb59ea05749f3b70 100644 (file)
@@ -1727,48 +1727,6 @@ void r600_emit_shader(struct r600_context *rctx, struct r600_atom *a)
        radeon_emit(cs, r600_context_bo_reloc(&rctx->b, &rctx->b.rings.gfx, shader->bo, RADEON_USAGE_READ));
 }
 
-struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
-                                               struct pipe_resource *texture,
-                                               const struct pipe_surface *templ,
-                                               unsigned width, unsigned height)
-{
-       struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
-
-        assert(templ->u.tex.first_layer <= util_max_layer(texture, templ->u.tex.level));
-        assert(templ->u.tex.last_layer <= util_max_layer(texture, templ->u.tex.level));
-       if (surface == NULL)
-               return NULL;
-       pipe_reference_init(&surface->base.reference, 1);
-       pipe_resource_reference(&surface->base.texture, texture);
-       surface->base.context = pipe;
-       surface->base.format = templ->format;
-       surface->base.width = width;
-       surface->base.height = height;
-       surface->base.u = templ->u;
-       return &surface->base;
-}
-
-static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,
-                                               struct pipe_resource *tex,
-                                               const struct pipe_surface *templ)
-{
-       unsigned level = templ->u.tex.level;
-
-       return r600_create_surface_custom(pipe, tex, templ,
-                                          u_minify(tex->width0, level),
-                                         u_minify(tex->height0, level));
-}
-
-static void r600_surface_destroy(struct pipe_context *pipe,
-                                struct pipe_surface *surface)
-{
-       struct r600_surface *surf = (struct r600_surface*)surface;
-       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_fmask, NULL);
-       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_cmask, NULL);
-       pipe_resource_reference(&surface->texture, NULL);
-       FREE(surface);
-}
-
 unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format,
                                   const unsigned char *swizzle_view,
                                   boolean vtx)
@@ -2280,8 +2238,6 @@ void r600_init_common_state_functions(struct r600_context *rctx)
        rctx->b.b.sampler_view_destroy = r600_sampler_view_destroy;
        rctx->b.b.texture_barrier = r600_texture_barrier;
        rctx->b.b.set_stream_output_targets = r600_set_streamout_targets;
-       rctx->b.b.create_surface = r600_create_surface;
-       rctx->b.b.surface_destroy = r600_surface_destroy;
        rctx->b.b.draw_vbo = r600_draw_vbo;
        rctx->b.invalidate_buffer = r600_invalidate_buffer;
        rctx->b.set_occlusion_query_state = r600_set_occlusion_query_state;
index f38e333ebd34ce1889c8feb87c43898167a1655c..3aa718d905f5dcb37d4838f8d5dc167bd307336c 100644 (file)
@@ -62,6 +62,7 @@ bool r600_common_context_init(struct r600_common_context *rctx,
        rctx->b.transfer_inline_write = u_default_transfer_inline_write;
         rctx->b.memory_barrier = r600_memory_barrier;
 
+       r600_init_context_texture_functions(rctx);
        r600_streamout_init(rctx);
        r600_query_init(rctx);
 
@@ -613,7 +614,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
                rscreen->b.is_video_format_supported = vl_video_buffer_is_format_supported;
        }
 
-       r600_init_texture_functions(rscreen);
+       r600_init_screen_texture_functions(rscreen);
 
        rscreen->ws = ws;
        rscreen->family = rscreen->info.family;
index 3edffbed8eeb16e9dc6c9854a1b1e1d1fc9fe658..692de5ee6a475323bc803663715f56055c21926e 100644 (file)
@@ -416,7 +416,12 @@ bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
                                     struct r600_texture **staging);
 struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
                                        const struct pipe_resource *templ);
-void r600_init_texture_functions(struct r600_common_screen *rscreen);
+struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
+                                               struct pipe_resource *texture,
+                                               const struct pipe_surface *templ,
+                                               unsigned width, unsigned height);
+void r600_init_screen_texture_functions(struct r600_common_screen *rscreen);
+void r600_init_context_texture_functions(struct r600_common_context *rctx);
 
 
 /* Inline helpers. */
index 2cfab512357944a954657d449cc08702bb795072..35ad97bd14163e74b5d22cd394b06cfa175493c3 100644 (file)
@@ -1076,8 +1076,58 @@ static const struct u_resource_vtbl r600_texture_vtbl =
        NULL                            /* transfer_inline_write */
 };
 
-void r600_init_texture_functions(struct r600_common_screen *rscreen)
+struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
+                                               struct pipe_resource *texture,
+                                               const struct pipe_surface *templ,
+                                               unsigned width, unsigned height)
+{
+       struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
+
+       if (surface == NULL)
+               return NULL;
+
+       assert(templ->u.tex.first_layer <= util_max_layer(texture, templ->u.tex.level));
+       assert(templ->u.tex.last_layer <= util_max_layer(texture, templ->u.tex.level));
+
+       pipe_reference_init(&surface->base.reference, 1);
+       pipe_resource_reference(&surface->base.texture, texture);
+       surface->base.context = pipe;
+       surface->base.format = templ->format;
+       surface->base.width = width;
+       surface->base.height = height;
+       surface->base.u = templ->u;
+       return &surface->base;
+}
+
+static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,
+                                               struct pipe_resource *tex,
+                                               const struct pipe_surface *templ)
+{
+       unsigned level = templ->u.tex.level;
+
+       return r600_create_surface_custom(pipe, tex, templ,
+                                         u_minify(tex->width0, level),
+                                         u_minify(tex->height0, level));
+}
+
+static void r600_surface_destroy(struct pipe_context *pipe,
+                                struct pipe_surface *surface)
+{
+       struct r600_surface *surf = (struct r600_surface*)surface;
+       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_fmask, NULL);
+       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_cmask, NULL);
+       pipe_resource_reference(&surface->texture, NULL);
+       FREE(surface);
+}
+
+void r600_init_screen_texture_functions(struct r600_common_screen *rscreen)
 {
        rscreen->b.resource_from_handle = r600_texture_from_handle;
        rscreen->b.resource_get_handle = r600_texture_get_handle;
 }
+
+void r600_init_context_texture_functions(struct r600_common_context *rctx)
+{
+       rctx->b.create_surface = r600_create_surface;
+       rctx->b.surface_destroy = r600_surface_destroy;
+}
index 07396e79a1e82dda2a7d91c1d76b579381546c3f..9975b4417f23a6b4f638016acee67372f8190559 100644 (file)
@@ -483,6 +483,7 @@ static void si_resource_copy_region(struct pipe_context *ctx,
                                    const struct pipe_box *src_box)
 {
        struct si_context *sctx = (struct si_context *)ctx;
+       struct r600_texture *rdst = (struct r600_texture*)dst;
        struct pipe_surface *dst_view, dst_templ;
        struct pipe_sampler_view src_templ, *src_view;
        struct texture_orig_info orig_info[2];
@@ -566,7 +567,9 @@ static void si_resource_copy_region(struct pipe_context *ctx,
 
        /* Initialize the surface. */
        util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
-       dst_view = ctx->create_surface(ctx, dst, &dst_templ);
+       dst_view = r600_create_surface_custom(ctx, dst, &dst_templ,
+                                             rdst->surface.level[dst_level].npix_x,
+                                             rdst->surface.level[dst_level].npix_y);
 
        /* Initialize the sampler view. */
        util_blitter_default_src_texture(&src_templ, src, src_level);
index 6642c7be9c6112a2163e1af398165669c23f207f..00b0e64e33d7bedfef72004d4f555c832a713815 100644 (file)
@@ -3100,41 +3100,6 @@ static void *si_create_blend_custom(struct si_context *sctx, unsigned mode)
        return si_create_blend_state_mode(&sctx->b.b, &blend, mode);
 }
 
-static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,
-                                               struct pipe_resource *texture,
-                                               const struct pipe_surface *surf_tmpl)
-{
-       struct r600_texture *rtex = (struct r600_texture*)texture;
-       struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
-       unsigned level = surf_tmpl->u.tex.level;
-
-       if (surface == NULL)
-               return NULL;
-
-       assert(surf_tmpl->u.tex.first_layer <= util_max_layer(texture, surf_tmpl->u.tex.level));
-       assert(surf_tmpl->u.tex.last_layer <= util_max_layer(texture, surf_tmpl->u.tex.level));
-
-       pipe_reference_init(&surface->base.reference, 1);
-       pipe_resource_reference(&surface->base.texture, texture);
-       surface->base.context = pipe;
-       surface->base.format = surf_tmpl->format;
-       surface->base.width = rtex->surface.level[level].npix_x;
-       surface->base.height = rtex->surface.level[level].npix_y;
-       surface->base.texture = texture;
-       surface->base.u.tex.first_layer = surf_tmpl->u.tex.first_layer;
-       surface->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer;
-       surface->base.u.tex.level = level;
-
-       return &surface->base;
-}
-
-static void r600_surface_destroy(struct pipe_context *pipe,
-                                struct pipe_surface *surface)
-{
-       pipe_resource_reference(&surface->texture, NULL);
-       FREE(surface);
-}
-
 static boolean si_dma_copy(struct pipe_context *ctx,
                           struct pipe_resource *dst,
                           unsigned dst_level,
@@ -3224,8 +3189,6 @@ void si_init_state_functions(struct si_context *sctx)
 
        sctx->b.b.texture_barrier = si_texture_barrier;
        sctx->b.b.set_polygon_stipple = si_set_polygon_stipple;
-       sctx->b.b.create_surface = r600_create_surface;
-       sctx->b.b.surface_destroy = r600_surface_destroy;
        sctx->b.dma_copy = si_dma_copy;
        sctx->b.set_occlusion_query_state = si_set_occlusion_query_state;
        sctx->b.need_gfx_cs_space = si_need_gfx_cs_space;