anv/gen7: Add support for gl_NumWorkGroups
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 23 Jan 2016 00:26:34 +0000 (16:26 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Sat, 30 Jan 2016 17:00:00 +0000 (09:00 -0800)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
src/vulkan/gen7_cmd_buffer.c

index 613971651b294722cba07a47fb6c0a9905869fac..e4a35388170eae79c6b4e7da4e7d50147aab7268 100644 (file)
@@ -725,6 +725,20 @@ void genX(CmdDispatch)(
    struct anv_pipeline *pipeline = cmd_buffer->state.compute_pipeline;
    struct brw_cs_prog_data *prog_data = &pipeline->cs_prog_data;
 
+   if (prog_data->uses_num_work_groups) {
+      struct anv_state state =
+         anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, 12, 4);
+      uint32_t *sizes = state.map;
+      sizes[0] = x;
+      sizes[1] = y;
+      sizes[2] = z;
+      if (!cmd_buffer->device->info.has_llc)
+         anv_state_clflush(state);
+      cmd_buffer->state.num_workgroups_offset = state.offset;
+      cmd_buffer->state.num_workgroups_bo =
+         &cmd_buffer->device->dynamic_state_block_pool.bo;
+   }
+
    cmd_buffer_flush_compute_state(cmd_buffer);
 
    anv_batch_emit(&cmd_buffer->batch, GEN7_GPGPU_WALKER,
@@ -757,6 +771,11 @@ void genX(CmdDispatchIndirect)(
    struct anv_bo *bo = buffer->bo;
    uint32_t bo_offset = buffer->offset + offset;
 
+   if (prog_data->uses_num_work_groups) {
+      cmd_buffer->state.num_workgroups_offset = bo_offset;
+      cmd_buffer->state.num_workgroups_bo = bo;
+   }
+
    cmd_buffer_flush_compute_state(cmd_buffer);
 
    gen7_batch_lrm(&cmd_buffer->batch, GPGPU_DISPATCHDIMX, bo, bo_offset);