mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
radeonsi: don't re-upload the sample position constant buffer repeatedly
This commit is contained in:
parent
b94824c787
commit
41a6c3de1f
4 changed files with 33 additions and 16 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue