[Mesa-dev] [PATCH 14/22] r600g, radeonsi: consolidate remaining obviously duplicated pipe_screen code
Marek Olšák
maraeo at gmail.com
Wed Jan 22 12:13:06 PST 2014
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/drivers/r600/r600_pipe.c | 35 ++++++---------------------
src/gallium/drivers/radeon/r600_pipe_common.c | 24 +++++++++++++++---
src/gallium/drivers/radeon/r600_pipe_common.h | 2 +-
src/gallium/drivers/radeonsi/si_pipe.c | 26 +-------------------
4 files changed, 30 insertions(+), 57 deletions(-)
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index d95e717..49521e0 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -518,19 +518,11 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
if (!radeon_winsys_unref(rscreen->b.ws))
return;
- r600_common_screen_cleanup(&rscreen->b);
-
if (rscreen->global_pool) {
compute_memory_pool_delete(rscreen->global_pool);
}
- if (rscreen->b.trace_bo) {
- rscreen->b.ws->buffer_unmap(rscreen->b.trace_bo->cs_buf);
- pipe_resource_reference((struct pipe_resource**)&rscreen->b.trace_bo, NULL);
- }
-
- rscreen->b.ws->destroy(rscreen->b.ws);
- FREE(rscreen);
+ r600_destroy_common_screen(&rscreen->b);
}
static struct pipe_resource *r600_resource_create(struct pipe_screen *screen,
@@ -551,18 +543,11 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
return NULL;
}
- ws->query_info(ws, &rscreen->b.info);
-
/* Set functions first. */
rscreen->b.b.context_create = r600_create_context;
rscreen->b.b.destroy = r600_destroy_screen;
rscreen->b.b.get_param = r600_get_param;
rscreen->b.b.get_shader_param = r600_get_shader_param;
- if (rscreen->b.info.chip_class >= EVERGREEN) {
- rscreen->b.b.is_format_supported = evergreen_is_format_supported;
- } else {
- rscreen->b.b.is_format_supported = r600_is_format_supported;
- }
rscreen->b.b.resource_create = r600_resource_create;
if (!r600_common_screen_init(&rscreen->b, ws)) {
@@ -570,6 +555,12 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
return NULL;
}
+ if (rscreen->b.info.chip_class >= EVERGREEN) {
+ rscreen->b.b.is_format_supported = evergreen_is_format_supported;
+ } else {
+ rscreen->b.b.is_format_supported = r600_is_format_supported;
+ }
+
rscreen->b.debug_flags |= debug_get_flags_option("R600_DEBUG", r600_debug_options, 0);
if (debug_get_bool_option("R600_DEBUG_COMPUTE", FALSE))
rscreen->b.debug_flags |= DBG_COMPUTE;
@@ -632,18 +623,6 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
rscreen->global_pool = compute_memory_pool_new(rscreen);
- rscreen->b.cs_count = 0;
- if (rscreen->b.info.drm_minor >= 28 && (rscreen->b.debug_flags & DBG_TRACE_CS)) {
- rscreen->b.trace_bo = (struct r600_resource*)pipe_buffer_create(&rscreen->b.b,
- PIPE_BIND_CUSTOM,
- PIPE_USAGE_STAGING,
- 4096);
- if (rscreen->b.trace_bo) {
- rscreen->b.trace_ptr = rscreen->b.ws->buffer_map(rscreen->b.trace_bo->cs_buf, NULL,
- PIPE_TRANSFER_UNSYNCHRONIZED);
- }
- }
-
/* Create the auxiliary context. This must be done last. */
rscreen->b.aux_context = rscreen->b.b.context_create(&rscreen->b.b, NULL);
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 931c91c..396ff86 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -616,17 +616,35 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
if (!r600_init_tiling(rscreen)) {
return false;
}
-
util_format_s3tc_init();
-
pipe_mutex_init(rscreen->aux_context_lock);
+
+ if (rscreen->info.drm_minor >= 28 && (rscreen->debug_flags & DBG_TRACE_CS)) {
+ rscreen->trace_bo = (struct r600_resource*)pipe_buffer_create(&rscreen->b,
+ PIPE_BIND_CUSTOM,
+ PIPE_USAGE_STAGING,
+ 4096);
+ if (rscreen->trace_bo) {
+ rscreen->trace_ptr = rscreen->ws->buffer_map(rscreen->trace_bo->cs_buf, NULL,
+ PIPE_TRANSFER_UNSYNCHRONIZED);
+ }
+ }
+
return true;
}
-void r600_common_screen_cleanup(struct r600_common_screen *rscreen)
+void r600_destroy_common_screen(struct r600_common_screen *rscreen)
{
pipe_mutex_destroy(rscreen->aux_context_lock);
rscreen->aux_context->destroy(rscreen->aux_context);
+
+ if (rscreen->trace_bo) {
+ rscreen->ws->buffer_unmap(rscreen->trace_bo->cs_buf);
+ pipe_resource_reference((struct pipe_resource**)&rscreen->trace_bo, NULL);
+ }
+
+ rscreen->ws->destroy(rscreen->ws);
+ FREE(rscreen);
}
static unsigned tgsi_get_processor_type(const struct tgsi_token *tokens)
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 975a8a1..6f8dc91 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -326,7 +326,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
/* r600_common_pipe.c */
bool r600_common_screen_init(struct r600_common_screen *rscreen,
struct radeon_winsys *ws);
-void r600_common_screen_cleanup(struct r600_common_screen *rscreen);
+void r600_destroy_common_screen(struct r600_common_screen *rscreen);
bool r600_common_context_init(struct r600_common_context *rctx,
struct r600_common_screen *rscreen);
void r600_common_context_cleanup(struct r600_common_context *rctx);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 2656fdd..f4df4b1 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -416,17 +416,7 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
if (!radeon_winsys_unref(sscreen->b.ws))
return;
- r600_common_screen_cleanup(&sscreen->b);
-
-#if SI_TRACE_CS
- if (sscreen->b.trace_bo) {
- sscreen->ws->buffer_unmap(sscreen->b.trace_bo->cs_buf);
- pipe_resource_reference((struct pipe_resource**)&sscreen->b.trace_bo, NULL);
- }
-#endif
-
- sscreen->b.ws->destroy(sscreen->b.ws);
- FREE(sscreen);
+ r600_destroy_common_screen(&sscreen->b);
}
struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
@@ -454,20 +444,6 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
if (debug_get_bool_option("RADEON_DUMP_SHADERS", FALSE))
sscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS;
-#if SI_TRACE_CS
- sscreen->b.cs_count = 0;
- if (sscreen->info.drm_minor >= 28) {
- sscreen->b.trace_bo = (struct r600_resource*)pipe_buffer_create(&sscreen->screen,
- PIPE_BIND_CUSTOM,
- PIPE_USAGE_STAGING,
- 4096);
- if (sscreen->b.trace_bo) {
- sscreen->b.trace_ptr = sscreen->ws->buffer_map(sscreen->b.trace_bo->cs_buf, NULL,
- PIPE_TRANSFER_UNSYNCHRONIZED);
- }
- }
-#endif
-
/* Create the auxiliary context. This must be done last. */
sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL);
--
1.8.3.2
More information about the mesa-dev
mailing list