r600g,radeonsi: consolidate the contents of r600_resource.c
authorMarek Olšák <marek.olsak@amd.com>
Tue, 21 Jan 2014 23:58:12 +0000 (00:58 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 28 Jan 2014 00:39:25 +0000 (01:39 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
13 files changed:
src/gallium/drivers/r600/Makefile.sources
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_resource.c [deleted file]
src/gallium/drivers/r600/r600_resource.h
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/Makefile.sources
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_resource.c [deleted file]
src/gallium/drivers/radeonsi/si_resource.h

index f04e156d08609448ec82a8c07e663fd4c21ecbb3..82560fce423567b58aa023e724e5349f642da9c4 100644 (file)
@@ -4,7 +4,6 @@ C_SOURCES = \
        r600_hw_context.c \
        r600_isa.c \
        r600_pipe.c \
-       r600_resource.c \
        r600_shader.c \
        r600_state.c \
        r700_asm.c \
index e217be5abae228aba81da1c750a664d4374eb619..abc25b29efe94f91153273575e70fe74237e102b 100644 (file)
@@ -211,7 +211,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        rctx->keep_tiling_flags = rscreen->b.info.drm_minor >= 12;
 
        r600_init_blit_functions(rctx);
-       r600_init_context_resource_functions(rctx);
 
        if (rscreen->b.info.has_uvd) {
                rctx->b.b.create_video_codec = r600_uvd_create_decoder;
@@ -826,6 +825,16 @@ static int r600_get_driver_query_info(struct pipe_screen *screen,
        return 1;
 }
 
+static struct pipe_resource *r600_resource_create(struct pipe_screen *screen,
+                                                 const struct pipe_resource *templ)
+{
+       if (templ->target == PIPE_BUFFER &&
+           (templ->bind & PIPE_BIND_GLOBAL))
+               return r600_compute_global_buffer_create(screen, templ);
+
+       return r600_resource_create_common(screen, templ);
+}
+
 struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
 {
        struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen);
@@ -859,7 +868,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
                rscreen->b.b.get_video_param = r600_get_video_param;
                rscreen->b.b.is_video_format_supported = vl_video_buffer_is_format_supported;
        }
-       r600_init_screen_resource_functions(&rscreen->b.b);
+       rscreen->b.b.resource_create = r600_resource_create;
 
        if (!r600_common_screen_init(&rscreen->b, ws)) {
                FREE(rscreen);
index 85bebc3bbf8325fbf5ad6211312d20bc1279ca30..101d7405ee134c0e5ae74f548aa7d169467919e1 100644 (file)
@@ -535,9 +535,6 @@ void r600_decompress_color_textures(struct r600_context *rctx,
 /* r600_pipe.c */
 const char * r600_llvm_gpu_string(enum radeon_family family);
 
-/* r600_resource.c */
-void r600_init_context_resource_functions(struct r600_context *r600);
-
 /* r600_shader.c */
 int r600_pipe_shader_create(struct pipe_context *ctx,
                            struct r600_pipe_shader *shader,
diff --git a/src/gallium/drivers/r600/r600_resource.c b/src/gallium/drivers/r600/r600_resource.c
deleted file mode 100644 (file)
index a8fa357..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo@gmail.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "r600_pipe.h"
-#include "evergreen_compute.h"
-
-static struct pipe_resource *r600_resource_create(struct pipe_screen *screen,
-                                               const struct pipe_resource *templ)
-{
-       if (templ->target == PIPE_BUFFER) {
-               if (templ->bind & PIPE_BIND_GLOBAL) {
-                   return r600_compute_global_buffer_create(screen, templ);
-               }
-               else {
-                   return r600_buffer_create(screen, templ, 4096);
-               }
-       } else {
-               return r600_texture_create(screen, templ);
-       }
-}
-
-static struct pipe_resource *r600_resource_from_handle(struct pipe_screen * screen,
-                                                       const struct pipe_resource *templ,
-                                                       struct winsys_handle *whandle)
-{
-       if (templ->target == PIPE_BUFFER) {
-               return NULL;
-       } else {
-               return r600_texture_from_handle(screen, templ, whandle);
-       }
-}
-
-void r600_resource_destroy(struct pipe_screen *screen, struct pipe_resource *res)
-{
-       if (res->target == PIPE_BUFFER && (res->bind & PIPE_BIND_GLOBAL)) {
-               r600_compute_global_buffer_destroy(screen, res);
-       } else {
-               u_resource_destroy_vtbl(screen, res);
-       }
-}
-
-void r600_init_screen_resource_functions(struct pipe_screen *screen)
-{
-       screen->resource_create = r600_resource_create;
-       screen->resource_from_handle = r600_resource_from_handle;
-       screen->resource_get_handle = u_resource_get_handle_vtbl;
-       screen->resource_destroy = r600_resource_destroy;
-}
-
-void r600_init_context_resource_functions(struct r600_context *r600)
-{
-       r600->b.b.transfer_map = u_transfer_map_vtbl;
-       r600->b.b.transfer_flush_region = u_default_transfer_flush_region;
-       r600->b.b.transfer_unmap = u_transfer_unmap_vtbl;
-       r600->b.b.transfer_inline_write = u_default_transfer_inline_write;
-}
index 96fea9afe0e887adf107f9572b9f024cbcf04c71..db88c9a5f00179743800842b17480566cbf9e344 100644 (file)
@@ -86,7 +86,4 @@ static INLINE bool r600_can_read_depth(struct r600_texture *rtex)
                rtex->resource.b.b.format == PIPE_FORMAT_Z32_FLOAT);
 }
 
-void r600_resource_destroy(struct pipe_screen *screen, struct pipe_resource *res);
-void r600_init_screen_resource_functions(struct pipe_screen *screen);
-
 #endif
index ad6dd253a1d2cbfffa1e868dcf244270475047c2..031f858dfe663f99aa0127c8b0cbcd91cb4bf086 100644 (file)
@@ -191,6 +191,16 @@ static bool r600_init_tiling(struct r600_common_screen *rscreen)
        }
 }
 
+struct pipe_resource *r600_resource_create_common(struct pipe_screen *screen,
+                                                 const struct pipe_resource *templ)
+{
+       if (templ->target == PIPE_BUFFER) {
+               return r600_buffer_create(screen, templ, 4096);
+       } else {
+               return r600_texture_create(screen, templ);
+       }
+}
+
 bool r600_common_screen_init(struct r600_common_screen *rscreen,
                             struct radeon_winsys *ws)
 {
@@ -199,6 +209,10 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
        rscreen->b.fence_finish = r600_fence_finish;
        rscreen->b.fence_reference = r600_fence_reference;
        rscreen->b.fence_signalled = r600_fence_signalled;
+       rscreen->b.resource_create = r600_resource_create_common;
+       rscreen->b.resource_destroy = u_resource_destroy_vtbl;
+
+       r600_init_texture_functions(rscreen);
 
        rscreen->ws = ws;
        rscreen->family = rscreen->info.family;
@@ -234,6 +248,11 @@ bool r600_common_context_init(struct r600_common_context *rctx,
        rctx->chip_class = rscreen->chip_class;
        rctx->max_db = rscreen->chip_class >= EVERGREEN ? 8 : 4;
 
+       rctx->b.transfer_map = u_transfer_map_vtbl;
+       rctx->b.transfer_flush_region = u_default_transfer_flush_region;
+       rctx->b.transfer_unmap = u_transfer_unmap_vtbl;
+       rctx->b.transfer_inline_write = u_default_transfer_inline_write;
+
        r600_streamout_init(rctx);
        r600_query_init(rctx);
 
index 48674c6e6252c589fa709566713ca6bea580a8ce..5496a12f2c152b65a6392f75bd6d08d566c30aae 100644 (file)
@@ -333,6 +333,8 @@ bool r600_can_dump_shader(struct r600_common_screen *rscreen,
                          const struct tgsi_token *tokens);
 void r600_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_resource *dst,
                              unsigned offset, unsigned size, unsigned value);
+struct pipe_resource *r600_resource_create_common(struct pipe_screen *screen,
+                                                 const struct pipe_resource *templ);
 
 /* r600_query.c */
 void r600_query_init(struct r600_common_context *rctx);
@@ -364,9 +366,7 @@ 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);
-struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
-                                               const struct pipe_resource *base,
-                                               struct winsys_handle *whandle);
+void r600_init_texture_functions(struct r600_common_screen *rscreen);
 
 
 /* Inline helpers. */
index caf3743e72fe3aaa4402e6ef4f93bc55f9803e02..878b26f20936a793cb43b472da1ac1256128e0fc 100644 (file)
@@ -236,8 +236,8 @@ static int r600_setup_surface(struct pipe_screen *screen,
 }
 
 static boolean r600_texture_get_handle(struct pipe_screen* screen,
-                                       struct pipe_resource *ptex,
-                                       struct winsys_handle *whandle)
+                                      struct pipe_resource *ptex,
+                                      struct winsys_handle *whandle)
 {
        struct r600_texture *rtex = (struct r600_texture*)ptex;
        struct r600_resource *resource = &rtex->resource;
@@ -763,9 +763,9 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
                                                                  0, NULL, &surface);
 }
 
-struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
-                                              const struct pipe_resource *templ,
-                                              struct winsys_handle *whandle)
+static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
+                                                     const struct pipe_resource *templ,
+                                                     struct winsys_handle *whandle)
 {
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct pb_buffer *buf = NULL;
@@ -1071,10 +1071,16 @@ static void r600_texture_transfer_unmap(struct pipe_context *ctx,
 
 static const struct u_resource_vtbl r600_texture_vtbl =
 {
-       r600_texture_get_handle,        /* get_handle */
+       NULL,                           /* get_handle */
        r600_texture_destroy,           /* resource_destroy */
        r600_texture_transfer_map,      /* transfer_map */
        NULL,                           /* transfer_flush_region */
        r600_texture_transfer_unmap,    /* transfer_unmap */
        NULL                            /* transfer_inline_write */
 };
+
+void r600_init_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;
+}
index 56295720f4d7c0fa31189309647af1a5374fdc47..c24eb75194b8eb3684b0d2fbd7b98d5ac52744cc 100644 (file)
@@ -7,7 +7,6 @@ C_SOURCES := \
        si_hw_context.c \
        si_pipe.c \
        si_pm4.c \
-       si_resource.c \
        si_shader.c \
        si_state.c \
        si_state_draw.c \
index 077706f4cf3d99c9be56b73f07dd51283a9a9816..4879b2ff914b697af7a7ff61a5d1832ecda685db 100644 (file)
@@ -142,7 +142,6 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void *
                goto fail;
 
        si_init_blit_functions(sctx);
-       si_init_context_resource_functions(sctx);
        si_init_compute_functions(sctx);
 
        if (sscreen->b.info.has_uvd) {
@@ -637,7 +636,6 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
                sscreen->b.b.get_video_param = si_get_video_param;
                sscreen->b.b.is_video_format_supported = vl_video_buffer_is_format_supported;
        }
-       si_init_screen_resource_functions(&sscreen->b.b);
 
        if (!r600_common_screen_init(&sscreen->b, ws)) {
                FREE(sscreen);
index ecc669932301fb0de9577b5354249abc78d8008c..aa62852b0931673103645742d43869bf9377f89d 100644 (file)
@@ -176,9 +176,6 @@ void si_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence,
               unsigned flags);
 const char *si_get_llvm_processor_name(enum radeon_family family);
 
-/* si_resource.c */
-void si_init_context_resource_functions(struct si_context *sctx);
-
 /* si_translate.c */
 void si_translate_index_buffer(struct si_context *sctx,
                               struct pipe_index_buffer *ib,
diff --git a/src/gallium/drivers/radeonsi/si_resource.c b/src/gallium/drivers/radeonsi/si_resource.c
deleted file mode 100644 (file)
index c0f1e26..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo@gmail.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "si_pipe.h"
-
-static struct pipe_resource *si_resource_create(struct pipe_screen *screen,
-                                               const struct pipe_resource *templ)
-{
-       if (templ->target == PIPE_BUFFER) {
-               return r600_buffer_create(screen, templ, 4096);
-       } else {
-               return r600_texture_create(screen, templ);
-       }
-}
-
-static struct pipe_resource *si_resource_from_handle(struct pipe_screen * screen,
-                                                    const struct pipe_resource *templ,
-                                                    struct winsys_handle *whandle)
-{
-       if (templ->target == PIPE_BUFFER) {
-               return NULL;
-       } else {
-               return r600_texture_from_handle(screen, templ, whandle);
-       }
-}
-
-void si_init_screen_resource_functions(struct pipe_screen *screen)
-{
-       screen->resource_create = si_resource_create;
-       screen->resource_from_handle = si_resource_from_handle;
-       screen->resource_get_handle = u_resource_get_handle_vtbl;
-       screen->resource_destroy = u_resource_destroy_vtbl;
-}
-
-void si_init_context_resource_functions(struct si_context *sctx)
-{
-       sctx->b.b.transfer_map = u_transfer_map_vtbl;
-       sctx->b.b.transfer_flush_region = u_default_transfer_flush_region;
-       sctx->b.b.transfer_unmap = u_transfer_unmap_vtbl;
-       sctx->b.b.transfer_inline_write = u_default_transfer_inline_write;
-}
index 67da8faead8bc3cb1a797e1f610301b090f466d8..a76419c7b2b73cba37b440edacb4236f9c8d541b 100644 (file)
@@ -44,8 +44,6 @@ struct si_surface {
        struct pipe_surface             base;
 };
 
-void si_init_screen_resource_functions(struct pipe_screen *screen);
-
 struct si_context;
 
 void si_upload_const_buffer(struct si_context *sctx, struct r600_resource **rbuffer,