intel: Add and use max_constant_urb_size_kb
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 24 Sep 2021 05:59:40 +0000 (22:59 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 27 Sep 2021 20:51:28 +0000 (20:51 +0000)
This knowledge was repeated in multiple places so move the values to
intel_device_info struct.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13014>

src/gallium/drivers/crocus/crocus_state.c
src/intel/common/intel_urb_config.c
src/intel/dev/intel_device_info.c
src/intel/dev/intel_device_info.h
src/intel/dev/intel_device_info_test.c
src/intel/vulkan/genX_cmd_buffer.c
src/mesa/drivers/dri/i965/gfx7_urb.c

index 0b65451..273a259 100644 (file)
@@ -1321,13 +1321,8 @@ emit_pipeline_select(struct crocus_batch *batch, uint32_t pipeline)
 static void
 crocus_alloc_push_constants(struct crocus_batch *batch)
 {
-#if GFX_VERx10 == 75
-   const unsigned push_constant_kb = batch->screen->devinfo.gt == 3 ? 32 : 16;
-#elif GFX_VER == 8
-   const unsigned push_constant_kb = 32;
-#else
-   const unsigned push_constant_kb = 16;
-#endif
+   const unsigned push_constant_kb =
+      batch->screen->devinfo.max_constant_urb_size_kb;
    unsigned size_per_stage = push_constant_kb / 5;
 
    /* For now, we set a static partitioning of the push constant area,
index 283e521..f7fabde 100644 (file)
@@ -87,8 +87,7 @@ intel_get_urb_config(const struct intel_device_info *devinfo,
    if (devinfo->ver >= 12)
       urb_size_kB -= 4 * devinfo->l3_banks;
 
-   const unsigned push_constant_kB =
-      (devinfo->ver >= 8 || (devinfo->is_haswell && devinfo->gt == 3)) ? 32 : 16;
+   const unsigned push_constant_kB = devinfo->max_constant_urb_size_kb;
 
    const bool active[4] = { true, tess_present, tess_present, gs_present };
 
index 5e9e86b..5cf6e0e 100644 (file)
@@ -219,6 +219,7 @@ static const struct intel_device_info intel_device_info_snb_gt2 = {
    .has_64bit_float = true,                         \
    .has_surface_tile_offset = true,                 \
    .timestamp_frequency = 12500000,                 \
+   .max_constant_urb_size_kb = 16,                  \
    .cs_prefetch_size = 512
 
 static const struct intel_device_info intel_device_info_ivb_gt1 = {
@@ -394,6 +395,7 @@ static const struct intel_device_info intel_device_info_hsw_gt3 = {
          [MESA_SHADER_GEOMETRY]  = 640,
       },
    },
+   .max_constant_urb_size_kb = 32,
    .simulator_id = 9,
 };
 
@@ -419,6 +421,7 @@ static const struct intel_device_info intel_device_info_hsw_gt3 = {
    .max_gs_threads = 504,                           \
    .max_wm_threads = 384,                           \
    .timestamp_frequency = 12500000,                 \
+   .max_constant_urb_size_kb = 32,                  \
    .cs_prefetch_size = 512
 
 static const struct intel_device_info intel_device_info_bdw_gt1 = {
index d6bce7d..b26296b 100644 (file)
@@ -265,6 +265,12 @@ struct intel_device_info
       unsigned max_entries[4];
    } urb;
 
+   /* Maximum size in Kb that can be allocated to constants in the URB, this
+    * is usually divided among the stages for implementing push constants.
+    * See 3DSTATE_PUSH_CONSTANT_ALLOC_*.
+    */
+   unsigned max_constant_urb_size_kb;
+
    /**
     * Size of the command streamer prefetch. This is important to know for
     * self modifying batches.
index 8ff22cf..06e51ac 100644 (file)
@@ -28,6 +28,8 @@ main(int argc, char *argv[])
       assert(devinfo.num_thread_per_eu != 0);
       assert(devinfo.timestamp_frequency != 0);
       assert(devinfo.cs_prefetch_size > 0);
+
+      assert(devinfo.ver < 7 || devinfo.max_constant_urb_size_kb > 0);
    }
 
    return 0;
index 9b09120..d24bb82 100644 (file)
@@ -2501,13 +2501,8 @@ cmd_buffer_alloc_push_constants(struct anv_cmd_buffer *cmd_buffer)
    if (stages == cmd_buffer->state.gfx.push_constant_stages)
       return;
 
-#if GFX_VER >= 8
-   const unsigned push_constant_kb = 32;
-#elif GFX_VERx10 == 75
-   const unsigned push_constant_kb = cmd_buffer->device->info.gt == 3 ? 32 : 16;
-#else
-   const unsigned push_constant_kb = 16;
-#endif
+   const unsigned push_constant_kb =
+      cmd_buffer->device->info.max_constant_urb_size_kb;
 
    const unsigned num_stages =
       util_bitcount(stages & VK_SHADER_STAGE_ALL_GRAPHICS);
index 0f06d26..79c28c1 100644 (file)
@@ -71,8 +71,7 @@ gfx7_allocate_push_constants(struct brw_context *brw)
    bool tess_present = brw->programs[MESA_SHADER_TESS_EVAL];
 
    unsigned avail_size = 16;
-   unsigned multiplier =
-      (devinfo->ver >= 8 || (devinfo->is_haswell && devinfo->gt == 3)) ? 2 : 1;
+   unsigned multiplier = devinfo->max_constant_urb_size_kb / 16;
 
    int stages = 2 + gs_present + 2 * tess_present;