radeonsi: split si_emit_shader_pointer
authorMarek Olšák <marek.olsak@amd.com>
Sat, 7 Oct 2017 20:16:46 +0000 (22:16 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 17 Oct 2017 20:03:03 +0000 (22:03 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c

index 6e1fd80a5e152a49d76909ced1c3ae6466fa9e05..a0f3dcfaa9bb57fa74467d75d6e9857e3cdf4a15 100644 (file)
@@ -1954,25 +1954,37 @@ void si_shader_change_notify(struct si_context *sctx)
        }
 }
 
-static void si_emit_shader_pointer(struct si_context *sctx,
-                                  struct si_descriptors *desc,
-                                  unsigned sh_base)
+static void si_emit_shader_pointer_head(struct radeon_winsys_cs *cs,
+                                       struct si_descriptors *desc,
+                                       unsigned sh_base,
+                                       unsigned pointer_count)
 {
-       struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
-       uint64_t va;
+       radeon_emit(cs, PKT3(PKT3_SET_SH_REG, pointer_count * 2, 0));
+       radeon_emit(cs, (sh_base + desc->shader_userdata_offset - SI_SH_REG_OFFSET) >> 2);
+}
 
-       if (!desc->buffer)
-               return; /* the pointer is not used by current shaders */
+static void si_emit_shader_pointer_body(struct radeon_winsys_cs *cs,
+                                       struct si_descriptors *desc)
+{
+       uint64_t va = 0;
 
-       va = desc->buffer->gpu_address +
-            desc->buffer_offset;
+       if (desc->buffer)
+               va = desc->buffer->gpu_address + desc->buffer_offset;
 
-       radeon_emit(cs, PKT3(PKT3_SET_SH_REG, 2, 0));
-       radeon_emit(cs, (sh_base + desc->shader_userdata_offset - SI_SH_REG_OFFSET) >> 2);
        radeon_emit(cs, va);
        radeon_emit(cs, va >> 32);
 }
 
+static void si_emit_shader_pointer(struct si_context *sctx,
+                                  struct si_descriptors *desc,
+                                  unsigned sh_base)
+{
+       struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
+
+       si_emit_shader_pointer_head(cs, desc, sh_base, 1);
+       si_emit_shader_pointer_body(cs, desc);
+}
+
 static void si_emit_global_shader_pointers(struct si_context *sctx,
                                           struct si_descriptors *descs)
 {