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);
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;
/* 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;
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;
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",
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]);
}