/* Return false if the shader isn't ready. */
static bool si_shader_select_prim_discard_cs(struct si_context *sctx,
- const struct pipe_draw_info *info)
+ const struct pipe_draw_info *info,
+ bool primitive_restart)
{
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
struct si_shader_key key;
/* Primitive restart needs ordered counters. */
- assert(!info->primitive_restart || VERTEX_COUNTER_GDS_MODE == 2);
- assert(!info->primitive_restart || info->instance_count == 1);
+ assert(!primitive_restart || VERTEX_COUNTER_GDS_MODE == 2);
+ assert(!primitive_restart || info->instance_count == 1);
memset(&key, 0, sizeof(key));
si_shader_selector_key_vs(sctx, sctx->vs_shader.cso, &key, &key.part.vs.prolog);
key.opt.cs_prim_type = info->mode;
key.opt.cs_indexed = info->index_size != 0;
key.opt.cs_instancing = info->instance_count > 1;
- key.opt.cs_primitive_restart = info->primitive_restart;
+ key.opt.cs_primitive_restart = primitive_restart;
key.opt.cs_provoking_vertex_first = rs->provoking_vertex_first;
/* Primitive restart with triangle strips needs to preserve primitive
* orientation for cases where front and back primitive orientation matters.
*/
- if (info->primitive_restart) {
+ if (primitive_restart) {
struct si_shader_selector *ps = sctx->ps_shader.cso;
key.opt.cs_need_correct_orientation =
enum si_prim_discard_outcome
si_prepare_prim_discard_or_split_draw(struct si_context *sctx,
- const struct pipe_draw_info *info)
+ const struct pipe_draw_info *info,
+ bool primitive_restart)
{
/* If the compute shader compilation isn't finished, this returns false. */
- if (!si_shader_select_prim_discard_cs(sctx, info))
+ if (!si_shader_select_prim_discard_cs(sctx, info, primitive_restart))
return SI_PRIM_DISCARD_DISABLED;
if (!si_initialize_prim_discard_cmdbuf(sctx))
(1 << PIPE_PRIM_TRIANGLE_STRIP))) {
/* Split draws. */
struct pipe_draw_info split_draw = *info;
+ split_draw.primitive_restart = primitive_restart;
+
unsigned base_start = split_draw.start;
if (prim == PIPE_PRIM_TRIANGLES) {
sctx->b.draw_vbo(&sctx->b, &split_draw);
if (start == 0 &&
- split_draw.primitive_restart &&
+ primitive_restart &&
sctx->cs_prim_discard_state.current->key.opt.cs_need_correct_orientation)
sctx->preserve_prim_restart_gds_at_flush = true;
}
si_resource_reference(&indexbuf_desc, NULL);
+ bool primitive_restart = sctx->cs_prim_discard_state.current->key.opt.cs_primitive_restart;
+
if (VERTEX_COUNTER_GDS_MODE == 1) {
gds_offset = sctx->compute_gds_offset;
- gds_size = info->primitive_restart ? 8 : 4;
+ gds_size = primitive_restart ? 8 : 4;
sctx->compute_gds_offset += gds_size;
/* Reset the counters in GDS for the first dispatch using WRITE_DATA.
uint32_t gds_prim_restart_continue_bit = 0;
if (sctx->preserve_prim_restart_gds_at_flush) {
- assert(info->primitive_restart &&
+ assert(primitive_restart &&
info->mode == PIPE_PRIM_TRIANGLE_STRIP);
assert(start_prim < 1 << 31);
gds_prim_restart_continue_bit = 1 << 31;
unsigned index_size = info->index_size;
unsigned index_offset = info->indirect ? info->start * index_size : 0;
unsigned instance_count = info->instance_count;
- bool primitive_restart = info->primitive_restart;
+ bool primitive_restart = info->primitive_restart &&
+ (!sctx->screen->options.prim_restart_tri_strips_only ||
+ (prim != PIPE_PRIM_TRIANGLE_STRIP &&
+ prim != PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY));
if (likely(!info->indirect)) {
/* GFX6-GFX7 treat instance_count==0 as instance_count==1. There is
bool gs_tri_strip_adj_fix =
!sctx->tes_shader.cso &&
prim == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY &&
- !info->primitive_restart;
+ !primitive_restart;
if (gs_tri_strip_adj_fix != sctx->gs_tri_strip_adj_fix) {
sctx->gs_tri_strip_adj_fix = gs_tri_strip_adj_fix;
/* Check that all buffers are used for read only, because compute
* dispatches can run ahead. */
(si_all_vs_resources_read_only(sctx, index_size ? indexbuf : NULL) || pd_msg("write reference"))) {
- switch (si_prepare_prim_discard_or_split_draw(sctx, info)) {
+ switch (si_prepare_prim_discard_or_split_draw(sctx, info, primitive_restart)) {
case SI_PRIM_DISCARD_ENABLED:
original_index_size = index_size;
prim_discard_cs_instancing = instance_count > 1;