From 9670e72f6ef85f0e6f6c9afe136dc67c017e3fae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 21 Feb 2012 18:08:32 +0100 Subject: [PATCH] r600g: consolidate common context init code Reviewed-by: Jerome Glisse Reviewed-by: Alex Deucher --- .../drivers/r600/evergreen_hw_context.c | 16 ---------------- src/gallium/drivers/r600/r600_hw_context.c | 18 ------------------ src/gallium/drivers/r600/r600_pipe.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_hw_context.c b/src/gallium/drivers/r600/evergreen_hw_context.c index 308224be352..75fca229025 100644 --- a/src/gallium/drivers/r600/evergreen_hw_context.c +++ b/src/gallium/drivers/r600/evergreen_hw_context.c @@ -713,19 +713,6 @@ int evergreen_context_init(struct r600_context *ctx) { int r; - LIST_INITHEAD(&ctx->active_query_list); - - /* init dirty list */ - LIST_INITHEAD(&ctx->dirty); - LIST_INITHEAD(&ctx->resource_dirty); - LIST_INITHEAD(&ctx->enable_list); - - ctx->range = calloc(NUM_RANGES, sizeof(struct r600_range)); - if (!ctx->range) { - r = -ENOMEM; - goto out_err; - } - /* add blocks */ if (ctx->family == CHIP_CAYMAN) r = r600_context_add_block(ctx, cayman_config_reg_list, @@ -796,9 +783,6 @@ int evergreen_context_init(struct r600_context *ctx) if (r) goto out_err; - ctx->cs = ctx->ws->cs_create(ctx->ws); - r600_emit_atom(ctx, &ctx->atom_start_cs.atom); - ctx->max_db = 8; return 0; out_err: diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index 40a851990ef..5738b486e22 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -664,9 +664,7 @@ void r600_context_fini(struct r600_context *ctx) r600_free_resource_range(ctx, &ctx->ps_resources, ctx->num_ps_resources); r600_free_resource_range(ctx, &ctx->vs_resources, ctx->num_vs_resources); r600_free_resource_range(ctx, &ctx->fs_resources, ctx->num_fs_resources); - free(ctx->range); free(ctx->blocks); - ctx->ws->cs_destroy(ctx->cs); } static void r600_add_resource_block(struct r600_context *ctx, struct r600_range *range, int num_blocks, int *index) @@ -720,19 +718,6 @@ int r600_context_init(struct r600_context *ctx) { int r; - LIST_INITHEAD(&ctx->active_query_list); - - /* init dirty list */ - LIST_INITHEAD(&ctx->dirty); - LIST_INITHEAD(&ctx->resource_dirty); - LIST_INITHEAD(&ctx->enable_list); - - ctx->range = calloc(NUM_RANGES, sizeof(struct r600_range)); - if (!ctx->range) { - r = -ENOMEM; - goto out_err; - } - /* add blocks */ r = r600_context_add_block(ctx, r600_config_reg_list, Elements(r600_config_reg_list), PKT3_SET_CONFIG_REG, R600_CONFIG_REG_OFFSET); @@ -795,9 +780,6 @@ int r600_context_init(struct r600_context *ctx) if (r) goto out_err; - ctx->cs = ctx->ws->cs_create(ctx->ws); - r600_emit_atom(ctx, &ctx->atom_start_cs.atom); - ctx->max_db = 4; return 0; out_err: diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 3d35ed289ce..e7ba97110ef 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -208,6 +208,10 @@ static void r600_destroy_context(struct pipe_context *context) r600_update_num_contexts(rctx->screen, -1); r600_release_command_buffer(&rctx->atom_start_cs); + + rctx->ws->cs_destroy(rctx->cs); + + FREE(rctx->range); FREE(rctx); } @@ -233,6 +237,16 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void rctx->chip_class = rscreen->chip_class; LIST_INITHEAD(&rctx->dirty_states); + LIST_INITHEAD(&rctx->active_query_list); + LIST_INITHEAD(&rctx->dirty); + LIST_INITHEAD(&rctx->resource_dirty); + LIST_INITHEAD(&rctx->enable_list); + + rctx->range = CALLOC(NUM_RANGES, sizeof(struct r600_range)); + if (!rctx->range) { + FREE(rctx); + return NULL; + } r600_init_blit_functions(rctx); r600_init_query_functions(rctx); @@ -272,7 +286,9 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void return NULL; } + rctx->cs = rctx->ws->cs_create(rctx->ws); rctx->ws->cs_set_flush_callback(rctx->cs, r600_flush_from_winsys, rctx); + r600_emit_atom(rctx, &rctx->atom_start_cs.atom); util_slab_create(&rctx->pool_transfers, sizeof(struct pipe_transfer), 64, -- 2.30.2