iris: handle PatchVerticesIn as a system value.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 4 Dec 2018 22:11:51 +0000 (14:11 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:10 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_draw.c
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/iris/iris_state.c
src/intel/compiler/brw_compiler.h

index 4b8205a2bbe41fac192f30786290b27060163fe4..d33bad0a0ff724fbfb4651f9783e32164a5ffc51 100644 (file)
@@ -47,11 +47,24 @@ 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) {
+   if (ice->state.prim_mode != info->mode) {
       ice->state.prim_mode = info->mode;
+      ice->state.dirty |= IRIS_DIRTY_VF_TOPOLOGY;
+   }
+
+   if (info->mode == PIPE_PRIM_PATCHES &&
+       ice->state.vertices_per_patch != info->vertices_per_patch) {
       ice->state.vertices_per_patch = info->vertices_per_patch;
       ice->state.dirty |= IRIS_DIRTY_VF_TOPOLOGY;
+
+      /* Flag constants dirty for gl_PatchVerticesIn if needed. */
+      const struct shader_info *tcs_info =
+         iris_get_shader_info(ice, MESA_SHADER_TESS_CTRL);
+      if (tcs_info &&
+          tcs_info->system_values_read & (1ull << SYSTEM_VALUE_VERTICES_IN)) {
+         ice->state.dirty |= IRIS_DIRTY_CONSTANTS_TCS;
+         ice->state.shaders[MESA_SHADER_TESS_CTRL].cbuf0_needs_upload = true;
+      }
    }
 
    if (ice->state.primitive_restart != info->primitive_restart ||
index 5fb4ef64861c597b4bfc81ff6aa694a0d69f131b..0200b9bb1ec62c3ee848c4c6b0c8d8af06c9d099 100644 (file)
@@ -628,6 +628,10 @@ iris_setup_uniforms(const struct brw_compiler *compiler,
             }
             break;
          }
+         case nir_intrinsic_load_patch_vertices_in:
+            system_values[num_system_values++] =
+               BRW_PARAM_BUILTIN_PATCH_VERTICES_IN;
+            break;
          default:
             continue;
          }
index 195829991a9581e3015561139d3f8a28b9e2ffa2..d41cb7490b4dd3c882c1a3099ed9fff8bb325874 100644 (file)
@@ -2245,6 +2245,17 @@ upload_uniforms(struct iris_context *ice,
          int plane = BRW_PARAM_BUILTIN_CLIP_PLANE_IDX(sysval);
          int comp  = BRW_PARAM_BUILTIN_CLIP_PLANE_COMP(sysval);
          value = fui(ice->state.clip_planes.ucp[plane][comp]);
+      } else if (sysval == BRW_PARAM_BUILTIN_PATCH_VERTICES_IN) {
+         if (stage == MESA_SHADER_TESS_CTRL) {
+            value = ice->state.vertices_per_patch;
+         } else {
+            assert(stage == MESA_SHADER_TESS_EVAL);
+            const struct shader_info *tcs_info =
+               iris_get_shader_info(ice, MESA_SHADER_TESS_CTRL);
+            assert(tcs_info);
+
+            value = tcs_info->tess.tcs_vertices_out;
+         }
       } else {
          assert(!"unhandled system value");
       }
index 560f2c3c6ba673c96d5cb1d7b804a6c8ae54a51e..b894c47ed6b938c0be686d324dffd335c4bc5ca5 100644 (file)
@@ -567,6 +567,8 @@ enum brw_param_builtin {
    BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X,
    BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_Y,
 
+   BRW_PARAM_BUILTIN_PATCH_VERTICES_IN,
+
    BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_X,
    BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Y,
    BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Z,