iris/compute: Push subgroup-id
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 18 Sep 2018 23:24:13 +0000 (16:24 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:09 +0000 (10:26 -0800)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/iris/iris_state.c

index e5d2372358cfee465bea680a0cdc90003066eb4a..cc28af263750f0ba1c7f66725464fd4f3a33127a 100644 (file)
@@ -485,6 +485,8 @@ void iris_init_resource_functions(struct pipe_context *ctx);
 void iris_init_query_functions(struct pipe_context *ctx);
 void iris_update_compiled_shaders(struct iris_context *ice);
 void iris_update_compiled_compute_shader(struct iris_context *ice);
+void iris_fill_cs_push_const_buffer(struct brw_cs_prog_data *cs_prog_data,
+                                    uint32_t *dst);
 
 
 /* iris_blit.c */
index 4aba8d0bfe34f3c1045ef1122eb67cb1cce1aa8d..ed72c2848e2911219595df640d4b5b2ebc52cce2 100644 (file)
@@ -1058,6 +1058,19 @@ iris_update_compiled_compute_shader(struct iris_context *ice)
    UNUSED bool success = iris_compile_cs(ice, ish, &key);
 }
 
+void
+iris_fill_cs_push_const_buffer(struct brw_cs_prog_data *cs_prog_data,
+                               uint32_t *dst)
+{
+   struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
+   assert(cs_prog_data->push.total.size > 0);
+   assert(cs_prog_data->push.cross_thread.size == 0);
+   assert(cs_prog_data->push.per_thread.dwords == 1);
+   assert(prog_data->param[0] == BRW_PARAM_BUILTIN_SUBGROUP_ID);
+   for (unsigned t = 0; t < cs_prog_data->threads; t++)
+      dst[8 * t] = t;
+}
+
 void
 iris_init_program_functions(struct pipe_context *ctx)
 {
index 313b3e979ad6e239e90ab2cb36ecc28e13e2dd97..5931907f814442317e12fb88034fc538d9434060 100644 (file)
@@ -4357,12 +4357,23 @@ iris_upload_compute_state(struct iris_context *ice,
    // XXX: hack iris_set_constant_buffers to upload compute shader constants
    // XXX: differently...?
 
-   if (cs_prog_data->push.total.size > 0) {
-      iris_emit_cmd(batch, GENX(MEDIA_CURBE_LOAD), curbe) {
-         curbe.CURBETotalDataLength =
-            ALIGN(cs_prog_data->push.total.size, 64);
-         // XXX: curbe.CURBEDataStartAddress = stage_state->push_const_offset;
-      }
+   uint32_t curbe_data_offset = 0;
+   // TODO: Move subgroup-id into uniforms ubo so we can push uniforms
+   assert(cs_prog_data->push.cross_thread.dwords == 0 &&
+          cs_prog_data->push.per_thread.dwords == 1 &&
+          cs_prog_data->base.param[0] == BRW_PARAM_BUILTIN_SUBGROUP_ID);
+   struct pipe_resource *curbe_data_res = NULL;
+   uint32_t *curbe_data_map =
+      stream_state(batch, ice->state.dynamic_uploader, &curbe_data_res,
+                   ALIGN(cs_prog_data->push.total.size, 64), 64,
+                   &curbe_data_offset);
+   assert(curbe_data_map);
+   memset(curbe_data_map, 0x5a, ALIGN(cs_prog_data->push.total.size, 64));
+   iris_fill_cs_push_const_buffer(cs_prog_data, curbe_data_map);
+   iris_emit_cmd(batch, GENX(MEDIA_CURBE_LOAD), curbe) {
+     curbe.CURBETotalDataLength =
+        ALIGN(cs_prog_data->push.total.size, 64);
+     curbe.CURBEDataStartAddress = curbe_data_offset;
    }
 
    struct pipe_resource *desc_res = NULL;
@@ -4371,6 +4382,11 @@ iris_upload_compute_state(struct iris_context *ice,
    iris_pack_state(GENX(INTERFACE_DESCRIPTOR_DATA), desc, idd) {
       idd.SamplerStatePointer = shs->sampler_table.offset;
       idd.BindingTablePointer = binder->bt_offset[MESA_SHADER_COMPUTE];
+      idd.ConstantURBEntryReadLength = cs_prog_data->push.per_thread.regs;
+#if GEN_GEN >= 8 || GEN_IS_HASWELL
+      idd.CrossThreadConstantDataReadLength =
+         cs_prog_data->push.cross_thread.regs;
+#endif
    }
 
    for (int i = 0; i < GENX(INTERFACE_DESCRIPTOR_DATA_length); i++)