From 7be6186e0cecccd7a64e9ba242f17ddbe588d84a Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 9 Jun 2017 19:21:18 +0200 Subject: radeonsi: allocate si_state_rasterizer::pm4_poly_offset only when needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each element has over 700 bytes. Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/radeonsi/si_state.c | 14 +++++++++++++- src/gallium/drivers/radeonsi/si_state.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 27a88a8cef5..f4d6ae1a986 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -870,6 +870,15 @@ static void *si_create_rs_state(struct pipe_context *ctx, S_028814_POLYMODE_FRONT_PTYPE(si_translate_fill(state->fill_front)) | S_028814_POLYMODE_BACK_PTYPE(si_translate_fill(state->fill_back))); + if (!rs->uses_poly_offset) + return rs; + + rs->pm4_poly_offset = CALLOC(3, sizeof(struct si_pm4_state)); + if (!rs->pm4_poly_offset) { + FREE(rs); + return NULL; + } + /* Precalculate polygon offset states for 16-bit, 24-bit, and 32-bit zbuffers. */ for (i = 0; i < 3; i++) { struct si_pm4_state *pm4 = &rs->pm4_poly_offset[i]; @@ -965,10 +974,13 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) static void si_delete_rs_state(struct pipe_context *ctx, void *state) { struct si_context *sctx = (struct si_context *)ctx; + struct si_state_rasterizer *rs = (struct si_state_rasterizer *)state; if (sctx->queued.named.rasterizer == state) si_pm4_bind_state(sctx, poly_offset, NULL); - si_pm4_delete_state(sctx, rasterizer, (struct si_state_rasterizer *)state); + + FREE(rs->pm4_poly_offset); + si_pm4_delete_state(sctx, rasterizer, rs); } /* diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index dabe9b9806e..8de86753f6d 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -60,7 +60,7 @@ struct si_state_blend { struct si_state_rasterizer { struct si_pm4_state pm4; /* poly offset states for 16-bit, 24-bit, and 32-bit zbuffers */ - struct si_pm4_state pm4_poly_offset[3]; + struct si_pm4_state *pm4_poly_offset; unsigned pa_sc_line_stipple; unsigned pa_cl_clip_cntl; unsigned sprite_coord_enable:8; -- cgit v1.2.3