iris: only bother with params if there are any...
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 9 Nov 2018 08:51:58 +0000 (00:51 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:09 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/iris/iris_state.c

index 731a3d7a347bc85e1233fc6fb2818195fedec267..773d4e5ebb3268291e67347cd2a26e6609361965 100644 (file)
@@ -470,23 +470,27 @@ iris_setup_uniforms(const struct brw_compiler *compiler,
       }
    }
 
-   nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(instr, block) {
-         if (instr->type != nir_instr_type_intrinsic)
-            continue;
-
-         nir_intrinsic_instr *load = nir_instr_as_intrinsic(instr);
-
-         if (load->intrinsic != nir_intrinsic_load_ubo)
-            continue;
-
-         if (load->src[0].ssa == temp_ubo_name) {
-            load->src[0] = nir_src_for_ssa(nir_imm_int(&b, 0));
-         } else if (nir_src_as_uint(load->src[0]) == 0) {
-            nir_ssa_def *offset =
-               nir_iadd(&b, load->src[1].ssa,
-                        nir_imm_int(&b, prog_data->nr_params));
-            load->src[1] = nir_src_for_ssa(offset);
+   if (prog_data->nr_params > 0) {
+      nir_foreach_block(block, impl) {
+         nir_foreach_instr_safe(instr, block) {
+            if (instr->type != nir_instr_type_intrinsic)
+               continue;
+
+            nir_intrinsic_instr *load = nir_instr_as_intrinsic(instr);
+
+            if (load->intrinsic != nir_intrinsic_load_ubo)
+               continue;
+
+            b.cursor = nir_before_instr(instr);
+
+            if (load->src[0].ssa == temp_ubo_name) {
+               load->src[0] = nir_src_for_ssa(nir_imm_int(&b, 0));
+            } else if (nir_src_as_uint(load->src[0]) == 0) {
+               nir_ssa_def *offset =
+                  nir_iadd(&b, load->src[1].ssa,
+                           nir_imm_int(&b, prog_data->nr_params));
+               load->src[1] = nir_src_for_ssa(offset);
+            }
          }
       }
    }
index 862cb4853c3acd2cfa241c77ee977c0ba8a957af..c6e90b979c0c851ee6911821d574ad5f9466b28e 100644 (file)
@@ -2168,8 +2168,11 @@ upload_uniforms(struct iris_context *ice,
    struct iris_compiled_shader *shader = ice->shaders.prog[stage];
    struct brw_stage_prog_data *prog_data = (void *) shader->prog_data;
 
-   unsigned upload_size = prog_data->nr_params * sizeof(uint32_t);
-   assert(upload_size >= shs->cbuf0.buffer_size);
+   unsigned upload_size = prog_data->nr_params * sizeof(uint32_t) +
+                          shs->cbuf0.buffer_size;
+
+   if (upload_size == 0)
+      return;
 
    uint32_t *map =
       upload_state(ice->ctx.const_uploader, &cbuf->data, upload_size, 64);
@@ -2178,29 +2181,16 @@ upload_uniforms(struct iris_context *ice,
       uint32_t param = prog_data->param[i];
       uint32_t value = 0;
 
-      switch (IRIS_PARAM_DOMAIN(param)) {
-      case IRIS_PARAM_DOMAIN_BUILTIN:
-         assert(!"not used yet");
-         break;
-      case IRIS_PARAM_DOMAIN_UNIFORM:
-         if (shs->cbuf0.user_buffer) {
-            const uint32_t *src = shs->cbuf0.user_buffer;
-
-            value = src[IRIS_PARAM_VALUE(param)];
-         }
-         break;
-      }
+      printf("got a param to upload - %u\n", param);
 
       *map++ = value;
    }
 
    if (shs->cbuf0.user_buffer) {
-      u_upload_data(ice->ctx.const_uploader, 0, shs->cbuf0.buffer_size, 32,
-                    shs->cbuf0.user_buffer, &cbuf->data.offset,
-                    &cbuf->data.res);
-
-      upload_ubo_surf_state(ice, cbuf, shs->cbuf0.buffer_size);
+      memcpy(map, shs->cbuf0.user_buffer, shs->cbuf0.buffer_size);
    }
+
+   upload_ubo_surf_state(ice, cbuf, upload_size);
 }
 
 /**