pan/midgard: Implement nir_intrinsic_load_num_work_groups
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 6 Aug 2019 21:07:10 +0000 (14:07 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 12 Aug 2019 19:43:02 +0000 (12:43 -0700)
Just a sysval to route through.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_compile.h

index 78f3a88507345db93e586ef922672063dc9da723..5ca63c15929d306361863f2676b716cd5f2d58a8 100644 (file)
@@ -87,6 +87,8 @@ panfrost_launch_grid(struct pipe_context *pipe,
 {
         struct panfrost_context *ctx = pan_context(pipe);
 
+        ctx->compute_grid = info;
+
         struct mali_job_descriptor_header job = {
                 .job_type = JOB_TYPE_COMPUTE,
                 .job_descriptor_size = 1,
index 035ce52128b5a21654e0b767964f26465ad82e5a..409c852a228e229f6de69602f5b036ff33f2a7f2 100644 (file)
@@ -749,6 +749,14 @@ static void panfrost_upload_ssbo_sysval(
         uniform->u[2] = sb.buffer_size;
 }
 
+static void panfrost_upload_num_work_groups_sysval(struct panfrost_context *ctx,
+                struct sysval_uniform *uniform)
+{
+        uniform->u[0] = ctx->compute_grid->grid[0];
+        uniform->u[1] = ctx->compute_grid->grid[1];
+        uniform->u[2] = ctx->compute_grid->grid[2];
+}
+
 static void panfrost_upload_sysvals(struct panfrost_context *ctx, void *buf,
                                     struct panfrost_shader_state *ss,
                                     enum pipe_shader_type st)
@@ -773,6 +781,10 @@ static void panfrost_upload_sysvals(struct panfrost_context *ctx, void *buf,
                         panfrost_upload_ssbo_sysval(ctx, st, PAN_SYSVAL_ID(sysval),
                                                     &uniforms[i]);
                         break;
+                case PAN_SYSVAL_NUM_WORK_GROUPS:
+                        panfrost_upload_num_work_groups_sysval(ctx, &uniforms[i]);
+                        break;
+
                 default:
                         assert(0);
                 }
index 542d24d2c2703e93c9600954dfe94d22ff4c70a0..1277629382aee3d31c6e20ec36af369cf28c0576 100644 (file)
@@ -108,6 +108,9 @@ struct panfrost_context {
         /* panfrost_resource -> panfrost_job */
         struct hash_table *write_jobs;
 
+        /* Within a launch_grid call.. */
+        const struct pipe_grid_info *compute_grid;
+
         /* Bit mask for supported PIPE_DRAW for this hardware */
         unsigned draw_modes;
 
index ab9ea664cb75037bb8b19e54229a7c687ac2819d..460847e8266036094c4a007fdd8ff34aec901fbe 100644 (file)
@@ -330,6 +330,8 @@ midgard_nir_sysval_for_intrinsic(nir_intrinsic_instr *instr)
                 return PAN_SYSVAL_VIEWPORT_SCALE;
         case nir_intrinsic_load_viewport_offset:
                 return PAN_SYSVAL_VIEWPORT_OFFSET;
+        case nir_intrinsic_load_num_work_groups:
+                return PAN_SYSVAL_NUM_WORK_GROUPS;
         case nir_intrinsic_load_ssbo: 
         case nir_intrinsic_store_ssbo: 
                 return midgard_sysval_for_ssbo(instr);
@@ -1575,6 +1577,7 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
 
         case nir_intrinsic_load_viewport_scale:
         case nir_intrinsic_load_viewport_offset:
+        case nir_intrinsic_load_num_work_groups:
                 emit_sysval_read(ctx, &instr->instr, -1, 3);
                 break;
 
index a15d6c0cdedf0cda4d75f0dabac2f7afc1653d69..2eb873f39e4da92cdba52eeadda9830fcda0341c 100644 (file)
@@ -67,6 +67,7 @@ enum {
         PAN_SYSVAL_VIEWPORT_OFFSET = 2,
         PAN_SYSVAL_TEXTURE_SIZE = 3,
         PAN_SYSVAL_SSBO = 4,
+        PAN_SYSVAL_NUM_WORK_GROUPS = 5,
 } pan_sysval;
 
 #define PAN_TXS_SYSVAL_ID(texidx, dim, is_array)          \