iris: Create binding table slot for num_work_groups only when needed
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 4 Jun 2019 20:38:36 +0000 (13:38 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 12 Jun 2019 00:57:37 +0000 (17:57 -0700)
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/iris/iris_state.c

index 691fb1fb258b45f1df7cbfea751f9bf7a20819f2..4bb2a7b96e38146d06035b392d3bffa44b3d4b5e 100644 (file)
@@ -670,7 +670,6 @@ iris_setup_binding_table(struct nir_shader *nir,
          BITFIELD64_MASK(num_render_targets);
    } else if (info->stage == MESA_SHADER_COMPUTE) {
       bt->sizes[IRIS_SURFACE_GROUP_CS_WORK_GROUPS] = 1;
-      bt->used_mask[IRIS_SURFACE_GROUP_CS_WORK_GROUPS] = 1;
    }
 
    bt->sizes[IRIS_SURFACE_GROUP_TEXTURE] = util_last_bit(info->textures_used);
@@ -706,6 +705,10 @@ iris_setup_binding_table(struct nir_shader *nir,
 
          nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
          switch (intrin->intrinsic) {
+         case nir_intrinsic_load_num_work_groups:
+            bt->used_mask[IRIS_SURFACE_GROUP_CS_WORK_GROUPS] = 1;
+            break;
+
          case nir_intrinsic_image_size:
          case nir_intrinsic_image_load:
          case nir_intrinsic_image_store:
index 9cab4625b81d14c0835264570db8f152820123c9..23f8d290368fe84c7fb95fc737c1ab35797a5d63 100644 (file)
@@ -4141,7 +4141,8 @@ iris_populate_binding_table(struct iris_context *ice,
       return;
    }
 
-   if (stage == MESA_SHADER_COMPUTE) {
+   if (stage == MESA_SHADER_COMPUTE &&
+       shader->bt.used_mask[IRIS_SURFACE_GROUP_CS_WORK_GROUPS]) {
       /* surface for gl_NumWorkGroups */
       struct iris_state_ref *grid_data = &ice->state.grid_size;
       struct iris_state_ref *grid_state = &ice->state.grid_surf_state;