anv: Emit 3DSTATE_URB_* via a loop.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 22 Feb 2016 23:23:06 +0000 (15:23 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 24 Feb 2016 19:13:02 +0000 (11:13 -0800)
Rather than keeping separate {vs,hs,ds,gs}_start fields, we now store an
array indexed by the shader stage (MESA_SHADER_*).  The 3DSTATE_URB_*
commands are also sequentially numbered.  This makes it easy to just
emit them in a loop.

This simplifies the code a little, and also will make it easier to add
more credible HS and DS code later.

src/intel/vulkan/anv_pipeline.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_pipeline_util.h

index 27872d2769ad67ff9d009b8a1fb6458d1e611be1..df78362ee70dbf8fcb1943def3574963b71533df 100644 (file)
@@ -870,13 +870,21 @@ gen7_compute_urb_partition(struct anv_pipeline *pipeline)
     * - VS
     * - GS
     */
-   pipeline->urb.vs_start = push_constant_chunks;
-   pipeline->urb.vs_size = vs_size;
-   pipeline->urb.nr_vs_entries = nr_vs_entries;
+   pipeline->urb.start[MESA_SHADER_VERTEX] = push_constant_chunks;
+   pipeline->urb.size[MESA_SHADER_VERTEX] = vs_size;
+   pipeline->urb.entries[MESA_SHADER_VERTEX] = nr_vs_entries;
 
-   pipeline->urb.gs_start = push_constant_chunks + vs_chunks;
-   pipeline->urb.gs_size = gs_size;
-   pipeline->urb.nr_gs_entries = nr_gs_entries;
+   pipeline->urb.start[MESA_SHADER_GEOMETRY] = push_constant_chunks + vs_chunks;
+   pipeline->urb.size[MESA_SHADER_GEOMETRY] = gs_size;
+   pipeline->urb.entries[MESA_SHADER_GEOMETRY] = nr_gs_entries;
+
+   pipeline->urb.start[MESA_SHADER_TESS_CTRL] = push_constant_chunks;
+   pipeline->urb.size[MESA_SHADER_TESS_CTRL] = 1;
+   pipeline->urb.entries[MESA_SHADER_TESS_CTRL] = 0;
+
+   pipeline->urb.start[MESA_SHADER_TESS_EVAL] = push_constant_chunks;
+   pipeline->urb.size[MESA_SHADER_TESS_EVAL] = 1;
+   pipeline->urb.entries[MESA_SHADER_TESS_EVAL] = 0;
 }
 
 static void
index b1b4d265b89a49e6ec903c27c4bf59e9e7dca9a5..3e3cbf09a68d3fc456384865e529e17a980568a9 100644 (file)
@@ -1410,12 +1410,9 @@ struct anv_pipeline {
    uint32_t                                     scratch_start[MESA_SHADER_STAGES];
    uint32_t                                     total_scratch;
    struct {
-      uint32_t                                  vs_start;
-      uint32_t                                  vs_size;
-      uint32_t                                  nr_vs_entries;
-      uint32_t                                  gs_start;
-      uint32_t                                  gs_size;
-      uint32_t                                  nr_gs_entries;
+      uint32_t                                  start[MESA_SHADER_GEOMETRY + 1];
+      uint32_t                                  size[MESA_SHADER_GEOMETRY + 1];
+      uint32_t                                  entries[MESA_SHADER_GEOMETRY + 1];
    } urb;
 
    VkShaderStageFlags                           active_stages;
index 51fbd8bf2730a7f6829b680a1a369506be7f0724..dea96a934b8867ce21ed49000a7d9f1c81863e39 100644 (file)
@@ -210,25 +210,13 @@ emit_urb_setup(struct anv_pipeline *pipeline)
       .ConstantBufferOffset                     = 8,
       .ConstantBufferSize                       = 4);
 
-   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_VS),
-      .VSURBStartingAddress                     = pipeline->urb.vs_start,
-      .VSURBEntryAllocationSize                 = pipeline->urb.vs_size - 1,
-      .VSNumberofURBEntries                     = pipeline->urb.nr_vs_entries);
-
-   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_GS),
-      .GSURBStartingAddress                     = pipeline->urb.gs_start,
-      .GSURBEntryAllocationSize                 = pipeline->urb.gs_size - 1,
-      .GSNumberofURBEntries                     = pipeline->urb.nr_gs_entries);
-
-   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_HS),
-      .HSURBStartingAddress                     = pipeline->urb.vs_start,
-      .HSURBEntryAllocationSize                 = 0,
-      .HSNumberofURBEntries                     = 0);
-
-   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_DS),
-      .DSURBStartingAddress                     = pipeline->urb.vs_start,
-      .DSURBEntryAllocationSize                 = 0,
-      .DSNumberofURBEntries                     = 0);
+   for (int i = MESA_SHADER_VERTEX; i <= MESA_SHADER_GEOMETRY; i++) {
+      anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_VS),
+         ._3DCommandSubOpcode                   = 48 + i,
+         .VSURBStartingAddress                  = pipeline->urb.start[i],
+         .VSURBEntryAllocationSize              = pipeline->urb.size[i] - 1,
+         .VSNumberofURBEntries                  = pipeline->urb.entries[i]);
+   }
 }
 
 static inline uint32_t