iris: don't unconditionally emit 3DSTATE_VF / 3DSTATE_VF_TOPOLOGY
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 1 Sep 2018 01:03:19 +0000 (18:03 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
this was just laziness on my part

src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_draw.c
src/gallium/drivers/iris/iris_state.c

index 92e551739939df913bc940c2d173aa1b07bb51f3..f7411727bb01f3649ba30531b3b0a7bf8646d8c1 100644 (file)
@@ -106,6 +106,8 @@ struct blorp_params;
 #define IRIS_DIRTY_SO_DECL_LIST             (1ull << 49)
 #define IRIS_DIRTY_STREAMOUT                (1ull << 50)
 #define IRIS_DIRTY_VF_SGVS                  (1ull << 51)
+#define IRIS_DIRTY_VF                       (1ull << 52)
+#define IRIS_DIRTY_VF_TOPOLOGY              (1ull << 53)
 
 /**
  * Non-orthogonal state (NOS) dependency flags.
@@ -345,6 +347,11 @@ struct iris_context {
       struct pipe_stencil_ref stencil_ref;
       struct pipe_framebuffer_state framebuffer;
 
+      bool primitive_restart;
+      unsigned cut_index;
+      enum pipe_prim_type prim_mode:8;
+      uint8_t vertices_per_patch;
+
       /** Are depth writes enabled?  (Depth buffer may or may not exist.) */
       bool depth_writes_enabled;
 
index d938c3d0f4fb9cea0f95e2afc97aa05748f6c756..f6911350a7bf40cf69dd75b1f277b2b84e1fce95 100644 (file)
 #include "intel/compiler/brw_compiler.h"
 #include "iris_context.h"
 
+/**
+ * Record the current primitive mode and restart information, flagging
+ * related packets as dirty if necessary.
+ */
+static void
+iris_update_draw_info(struct iris_context *ice,
+                      const struct pipe_draw_info *info)
+{
+   if (ice->state.prim_mode != info->mode ||
+       ice->state.vertices_per_patch != info->vertices_per_patch) {
+      ice->state.prim_mode = info->mode;
+      ice->state.vertices_per_patch = info->vertices_per_patch;
+      ice->state.dirty |= IRIS_DIRTY_VF_TOPOLOGY;
+   }
+
+   if (ice->state.primitive_restart != info->primitive_restart ||
+       ice->state.cut_index != info->restart_index) {
+      ice->state.dirty |= IRIS_DIRTY_VF;
+      ice->state.primitive_restart = info->primitive_restart;
+      ice->state.cut_index = info->restart_index;
+   }
+}
+
 /**
  * The pipe->draw_vbo() driver hook.  Performs a draw on the GPU.
  */
@@ -51,6 +74,7 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 
    iris_batch_maybe_flush(batch, 1500);
 
+   iris_update_draw_info(ice, info);
    iris_update_compiled_shaders(ice);
 
    iris_predraw_resolve_inputs(ice, batch);
index abe4c442089b81f1b5438459f8f9a20ad516d52c..cfdd69bdde26768e9bb7566fcfb748c2c9f55fdf 100644 (file)
@@ -3641,7 +3641,7 @@ iris_upload_dirty_render_state(struct iris_context *ice,
       iris_batch_emit(batch, cso->line_stipple, sizeof(cso->line_stipple));
    }
 
-   if (1) {
+   if (dirty & IRIS_DIRTY_VF_TOPOLOGY) {
       iris_emit_cmd(batch, GENX(3DSTATE_VF_TOPOLOGY), topo) {
          topo.PrimitiveTopologyType =
             translate_prim_type(draw->mode, draw->vertices_per_patch);
@@ -3692,7 +3692,7 @@ iris_upload_dirty_render_state(struct iris_context *ice,
       }
    }
 
-   if (1) {
+   if (dirty & IRIS_DIRTY_VF) {
       iris_emit_cmd(batch, GENX(3DSTATE_VF), vf) {
          if (draw->primitive_restart) {
             vf.IndexedDrawCutIndexEnable = true;