r600g,radeonsi: consolidate remaining obviously duplicated pipe_screen code
authorMarek Olšák <marek.olsak@amd.com>
Wed, 22 Jan 2014 01:49:53 +0000 (02:49 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 28 Jan 2014 00:39:50 +0000 (01:39 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/si_pipe.c

index 7df89f6a36c0ff223409c665ac6740761c7ebd9a..07f6c1ce56640198265ba0ef8641fab4c4bf9604 100644 (file)
@@ -520,19 +520,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,
@@ -553,18 +545,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)) {
@@ -572,6 +557,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;
@@ -634,18 +625,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);
 
index 7640d6f24af97b07250c330142fd873aa16b9500..f40adf23565e01cbe2e1e80130e20445312c40b3 100644 (file)
@@ -619,17 +619,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)
index 48f2be5f65d25515d0d839245b1655e0b8e265d8..16a9c768dd32587b0633024a91f60b1fbcea5a60 100644 (file)
@@ -328,7 +328,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);
index 941e6dec4887f29067a681bc0f8487f4303250ae..79a99f14fe7d288e3b5d5eed33ce95d952febe09 100644 (file)
@@ -418,17 +418,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)
@@ -456,20 +446,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);