iris: fix sysval only binding tables
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 10 Nov 2018 01:35:22 +0000 (17:35 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:10 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_program.c

index 10b41e3e457e7964ac8a276386c7aa741706ec6a..a4d46118e44a1c97f31cb063bc4cca3eb69582b7 100644 (file)
@@ -343,7 +343,8 @@ static uint32_t
 assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
                                     const struct nir_shader *nir,
                                     struct brw_stage_prog_data *prog_data,
-                                    uint32_t next_binding_table_offset)
+                                    uint32_t next_binding_table_offset,
+                                    unsigned num_system_values)
 {
    const struct shader_info *info = &nir->info;
 
@@ -363,7 +364,8 @@ assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
       prog_data->binding_table.image_start = 0xd0d0d0d0;
    }
 
-   int num_ubos = info->num_ubos + (nir->num_uniforms > 0 ? 1 : 0);
+   int num_ubos = info->num_ubos +
+                  ((nir->num_uniforms || num_system_values) ? 1 : 0);
 
    if (num_ubos) {
       //assert(info->num_ubos <= BRW_MAX_UBO);
@@ -567,11 +569,13 @@ iris_compile_vs(struct iris_context *ice,
    }
 
    // XXX: alt mode
-   assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
 
    iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
                        &num_system_values);
 
+   assign_common_binding_table_offsets(devinfo, nir, prog_data, 0,
+                                       num_system_values);
+
    brw_compute_vue_map(devinfo,
                        &vue_prog_data->vue_map, nir->info.outputs_written,
                        nir->info.separate_shader);
@@ -643,11 +647,13 @@ unsigned
 iris_get_shader_num_ubos(const struct iris_context *ice, gl_shader_stage stage)
 {
    const struct iris_uncompiled_shader *ish = ice->shaders.uncompiled[stage];
+   const struct iris_compiled_shader *shader = ice->shaders.prog[stage];
 
    if (ish) {
       const nir_shader *nir = ish->nir;
       /* see assign_common_binding_table_offsets */
-      return nir->info.num_ubos + (nir->num_uniforms > 0 ? 1 : 0);
+      return nir->info.num_ubos +
+             ((nir->num_uniforms || shader->num_system_values) ? 1 : 0);
    }
    return 0;
 }
@@ -709,9 +715,10 @@ iris_compile_tcs(struct iris_context *ice,
    if (ish) {
       nir = nir_shader_clone(mem_ctx, ish->nir);
 
-      assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
       iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
                           &num_system_values);
+      assign_common_binding_table_offsets(devinfo, nir, prog_data, 0,
+                                          num_system_values);
    } else {
       nir = brw_nir_create_passthrough_tcs(mem_ctx, compiler, options, key);
 
@@ -787,11 +794,12 @@ iris_compile_tes(struct iris_context *ice,
 
    nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
-   assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
-
    iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
                        &num_system_values);
 
+   assign_common_binding_table_offsets(devinfo, nir, prog_data, 0,
+                                       num_system_values);
+
    struct brw_vue_map input_vue_map;
    brw_compute_tess_vue_map(&input_vue_map, key->inputs_read,
                             key->patch_inputs_read);
@@ -859,11 +867,12 @@ iris_compile_gs(struct iris_context *ice,
 
    nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
-   assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
-
    iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
                        &num_system_values);
 
+   assign_common_binding_table_offsets(devinfo, nir, prog_data, 0,
+                                       num_system_values);
+
    brw_compute_vue_map(devinfo,
                        &vue_prog_data->vue_map, nir->info.outputs_written,
                        nir->info.separate_shader);
@@ -936,12 +945,13 @@ iris_compile_fs(struct iris_context *ice,
    nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    // XXX: alt mode
-   assign_common_binding_table_offsets(devinfo, nir, prog_data,
-                                       MAX2(key->nr_color_regions, 1));
 
    iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
                        &num_system_values);
 
+   assign_common_binding_table_offsets(devinfo, nir, prog_data,
+                                       MAX2(key->nr_color_regions, 1),
+                                       num_system_values);
    char *error_str = NULL;
    const unsigned *program =
       brw_compile_fs(compiler, &ice->dbg, mem_ctx, key, fs_prog_data,
@@ -1127,11 +1137,13 @@ iris_compile_cs(struct iris_context *ice,
    nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    cs_prog_data->binding_table.work_groups_start = 0;
-   assign_common_binding_table_offsets(devinfo, nir, prog_data, 1);
 
    iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
                        &num_system_values);
 
+   assign_common_binding_table_offsets(devinfo, nir, prog_data, 1,
+                                       num_system_values);
+
    char *error_str = NULL;
    const unsigned *program =
       brw_compile_cs(compiler, &ice->dbg, mem_ctx, key, cs_prog_data,