~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/drivers/etnaviv/etnaviv_context.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
{
169
169
   const struct etna_shader_variant *old = ctx->shader.vs;
170
170
 
171
 
   ctx->shader.vs = etna_shader_variant(ctx->shader.bind_vs, key, &ctx->base.debug);
 
171
   ctx->shader.vs = etna_shader_variant(ctx->shader.bind_vs, key, &ctx->base.debug, true);
172
172
 
173
173
   if (!ctx->shader.vs)
174
174
      return false;
204
204
      }
205
205
   }
206
206
 
207
 
   ctx->shader.fs = etna_shader_variant(ctx->shader.bind_fs, key, &ctx->base.debug);
 
207
   ctx->shader.fs = etna_shader_variant(ctx->shader.bind_fs, key, &ctx->base.debug, true);
208
208
 
209
209
   if (!ctx->shader.fs)
210
210
      return false;
245
245
      return; /* Nothing to do */
246
246
 
247
247
   if (unlikely(ctx->rasterizer->cull_face == PIPE_FACE_FRONT_AND_BACK &&
248
 
                u_decomposed_prim(info->mode) == PIPE_PRIM_TRIANGLES))
 
248
                u_decomposed_prim(info->mode) == MESA_PRIM_TRIANGLES))
 
249
      return;
 
250
 
 
251
   if (!etna_render_condition_check(pctx))
249
252
      return;
250
253
 
251
254
   int prims = u_decomposed_prims_for_vertices(info->mode, draws[0].count);
504
507
 
505
508
   ctx->dirty = ~0L;
506
509
   ctx->dirty_sampler_views = ~0L;
 
510
   ctx->prev_active_samplers = ~0L;
507
511
}
508
512
 
509
 
static void
 
513
void
510
514
etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
511
 
           enum pipe_flush_flags flags)
 
515
           enum pipe_flush_flags flags, bool internal)
512
516
{
513
517
   struct etna_context *ctx = etna_context(pctx);
514
518
   int out_fence_fd = -1;
516
520
   list_for_each_entry(struct etna_acc_query, aq, &ctx->active_acc_queries, node)
517
521
      etna_acc_query_suspend(aq, ctx);
518
522
 
519
 
   /* flush all resources that need an implicit flush */
520
 
   set_foreach(ctx->flush_resources, entry) {
521
 
      struct pipe_resource *prsc = (struct pipe_resource *)entry->key;
 
523
   if (!internal) {
 
524
      /* flush all resources that need an implicit flush */
 
525
      set_foreach(ctx->flush_resources, entry) {
 
526
         struct pipe_resource *prsc = (struct pipe_resource *)entry->key;
522
527
 
523
 
      pctx->flush_resource(pctx, prsc);
524
 
      pipe_resource_reference(&prsc, NULL);
 
528
         pctx->flush_resource(pctx, prsc);
 
529
         pipe_resource_reference(&prsc, NULL);
 
530
      }
 
531
      _mesa_set_clear(ctx->flush_resources, NULL);
525
532
   }
526
 
   _mesa_set_clear(ctx->flush_resources, NULL);
527
533
 
528
534
   etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd,
529
535
                          (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd : NULL,
541
547
}
542
548
 
543
549
static void
 
550
etna_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
 
551
                   enum pipe_flush_flags flags)
 
552
{
 
553
   etna_flush(pctx, fence, flags, false);
 
554
}
 
555
 
 
556
static void
544
557
etna_context_force_flush(struct etna_cmd_stream *stream, void *priv)
545
558
{
546
559
   struct pipe_context *pctx = priv;
547
560
 
548
 
   pctx->flush(pctx, NULL, 0);
 
561
   etna_flush(pctx, NULL, 0, true);
549
562
 
550
563
   /* update derived states as the context is now fully dirty */
551
564
   etna_state_update(etna_context(pctx));
619
632
 
620
633
   pctx->destroy = etna_context_destroy;
621
634
   pctx->draw_vbo = etna_draw_vbo;
622
 
   pctx->flush = etna_flush;
 
635
   pctx->flush = etna_context_flush;
623
636
   pctx->set_debug_callback = etna_set_debug_callback;
624
637
   pctx->create_fence_fd = etna_create_fence_fd;
625
638
   pctx->fence_server_sync = etna_fence_server_sync;
626
639
   pctx->emit_string_marker = etna_emit_string_marker;
627
640
   pctx->set_frontend_noop = etna_set_frontend_noop;
628
641
   pctx->clear_buffer = u_default_clear_buffer;
629
 
   pctx->clear_texture = util_clear_texture;
 
642
   pctx->clear_texture = u_default_clear_texture;
630
643
 
631
644
   /* creation of compile states */
632
645
   pctx->create_blend_state = etna_blend_state_create;
655
668
 
656
669
   return NULL;
657
670
}
 
671
 
 
672
bool
 
673
etna_render_condition_check(struct pipe_context *pctx)
 
674
{
 
675
   struct etna_context *ctx = etna_context(pctx);
 
676
 
 
677
   if (!ctx->cond_query)
 
678
      return true;
 
679
 
 
680
   perf_debug_ctx(ctx, "Implementing conditional rendering on the CPU");
 
681
 
 
682
   union pipe_query_result res = { 0 };
 
683
   bool wait =
 
684
      ctx->cond_mode != PIPE_RENDER_COND_NO_WAIT &&
 
685
      ctx->cond_mode != PIPE_RENDER_COND_BY_REGION_NO_WAIT;
 
686
 
 
687
   if (pctx->get_query_result(pctx, ctx->cond_query, wait, &res))
 
688
      return (bool)res.u64 != ctx->cond_cond;
 
689
 
 
690
   return true;
 
691
}