diff options
author | Marek Olšák <[email protected]> | 2018-09-28 20:38:26 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-10-16 15:28:22 -0400 |
commit | 41a6c3de1fb4b955217b0f53b3f301d236acebb3 (patch) | |
tree | 1cc25899afb619cc9e5aa183096ce6c026c74b68 | |
parent | b94824c787ba747060f359391ddf454a15843e63 (diff) |
radeonsi: don't re-upload the sample position constant buffer repeatedly
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.h | 13 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 19 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_msaa.c | 10 |
4 files changed, 33 insertions, 16 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 14b075c7b76..4b481b47af3 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -160,6 +160,7 @@ static void si_destroy_context(struct pipe_context *context) pipe_resource_reference(&sctx->gsvs_ring, NULL); pipe_resource_reference(&sctx->tess_rings, NULL); pipe_resource_reference(&sctx->null_const_buf.buffer, NULL); + pipe_resource_reference(&sctx->sample_pos_buffer, NULL); r600_resource_reference(&sctx->border_color_buffer, NULL); free(sctx->border_color_table); r600_resource_reference(&sctx->scratch_buffer, NULL); @@ -599,6 +600,12 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, util_dynarray_init(&sctx->resident_img_needs_color_decompress, NULL); util_dynarray_init(&sctx->resident_tex_needs_depth_decompress, NULL); + sctx->sample_pos_buffer = + pipe_buffer_create(sctx->b.screen, 0, PIPE_USAGE_DEFAULT, + sizeof(sctx->sample_positions)); + pipe_buffer_write(&sctx->b, sctx->sample_pos_buffer, 0, + sizeof(sctx->sample_positions), &sctx->sample_positions); + /* this must be last */ si_begin_new_gfx_cs(sctx); return &sctx->b; diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index ff11eab0224..93082e262d6 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -965,11 +965,14 @@ struct si_context { /* MSAA sample locations. * The first index is the sample index. * The second index is the coordinate: X, Y. */ - float sample_locations_1x[1][2]; - float sample_locations_2x[2][2]; - float sample_locations_4x[4][2]; - float sample_locations_8x[8][2]; - float sample_locations_16x[16][2]; + struct { + float x1[1][2]; + float x2[2][2]; + float x4[4][2]; + float x8[8][2]; + float x16[16][2]; + } sample_positions; + struct pipe_resource *sample_pos_buffer; /* Misc stats. */ unsigned num_draw_calls; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 132085a40c4..b1e2fc30e2a 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2717,7 +2717,6 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, const struct pipe_framebuffer_state *state) { struct si_context *sctx = (struct si_context *)ctx; - struct pipe_constant_buffer constbuf = {0}; struct si_surface *surf = NULL; struct si_texture *tex; bool old_any_dst_linear = sctx->framebuffer.any_dst_linear; @@ -2941,25 +2940,33 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config); if (sctx->framebuffer.nr_samples != old_nr_samples) { + struct pipe_constant_buffer constbuf = {0}; + si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config); si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state); + constbuf.buffer = sctx->sample_pos_buffer; + /* Set sample locations as fragment shader constants. */ switch (sctx->framebuffer.nr_samples) { case 1: - constbuf.user_buffer = sctx->sample_locations_1x; + constbuf.buffer_offset = 0; break; case 2: - constbuf.user_buffer = sctx->sample_locations_2x; + constbuf.buffer_offset = (ubyte*)sctx->sample_positions.x2 - + (ubyte*)sctx->sample_positions.x1; break; case 4: - constbuf.user_buffer = sctx->sample_locations_4x; + constbuf.buffer_offset = (ubyte*)sctx->sample_positions.x4 - + (ubyte*)sctx->sample_positions.x1; break; case 8: - constbuf.user_buffer = sctx->sample_locations_8x; + constbuf.buffer_offset = (ubyte*)sctx->sample_positions.x8 - + (ubyte*)sctx->sample_positions.x1; break; case 16: - constbuf.user_buffer = sctx->sample_locations_16x; + constbuf.buffer_offset = (ubyte*)sctx->sample_positions.x16 - + (ubyte*)sctx->sample_positions.x1; break; default: PRINT_ERR("Requested an invalid number of samples %i.\n", diff --git a/src/gallium/drivers/radeonsi/si_state_msaa.c b/src/gallium/drivers/radeonsi/si_state_msaa.c index f9387e75ed1..b741bcadec8 100644 --- a/src/gallium/drivers/radeonsi/si_state_msaa.c +++ b/src/gallium/drivers/radeonsi/si_state_msaa.c @@ -198,14 +198,14 @@ void si_init_msaa_functions(struct si_context *sctx) sctx->b.get_sample_position = si_get_sample_position; - si_get_sample_position(&sctx->b, 1, 0, sctx->sample_locations_1x[0]); + si_get_sample_position(&sctx->b, 1, 0, sctx->sample_positions.x1[0]); for (i = 0; i < 2; i++) - si_get_sample_position(&sctx->b, 2, i, sctx->sample_locations_2x[i]); + si_get_sample_position(&sctx->b, 2, i, sctx->sample_positions.x2[i]); for (i = 0; i < 4; i++) - si_get_sample_position(&sctx->b, 4, i, sctx->sample_locations_4x[i]); + si_get_sample_position(&sctx->b, 4, i, sctx->sample_positions.x4[i]); for (i = 0; i < 8; i++) - si_get_sample_position(&sctx->b, 8, i, sctx->sample_locations_8x[i]); + si_get_sample_position(&sctx->b, 8, i, sctx->sample_positions.x8[i]); for (i = 0; i < 16; i++) - si_get_sample_position(&sctx->b, 16, i, sctx->sample_locations_16x[i]); + si_get_sample_position(&sctx->b, 16, i, sctx->sample_positions.x16[i]); } |