i965/blorp: Add a param array to prog_data
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 28 Apr 2016 00:15:11 +0000 (17:15 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 14 May 2016 20:34:52 +0000 (13:34 -0700)
This array allows the push constants to be re-arranged on upload.  The
actual arrangement will, eventually, come from the back-end compiler.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_blorp.c
src/mesa/drivers/dri/i965/brw_blorp.h
src/mesa/drivers/dri/i965/gen6_blorp.c

index 8fd936323c0afdac40e73383eed80354ac7bf915..40c02e26773d93878b7a541e18b02749e5c8b9f8 100644 (file)
@@ -139,6 +139,10 @@ brw_blorp_prog_data_init(struct brw_blorp_prog_data *prog_data)
 {
    prog_data->first_curbe_grf = 0;
    prog_data->persample_msaa_dispatch = false;
+
+   prog_data->nr_params = BRW_BLORP_NUM_PUSH_CONSTANT_DWORDS;
+   for (unsigned i = 0; i < BRW_BLORP_NUM_PUSH_CONSTANT_DWORDS; i++)
+      prog_data->param[i] = i;
 }
 
 
index 8c1f92bb59ffb0e5982634b2b9306793dfeeb7ed..95e0e45ce39f3368b63ecea09580ec65502e13c8 100644 (file)
@@ -199,6 +199,9 @@ struct brw_blorp_wm_push_constants
    uint32_t pad[5];
 };
 
+#define BRW_BLORP_NUM_PUSH_CONSTANT_DWORDS \
+   (sizeof(struct brw_blorp_wm_push_constants) / 4)
+
 /* Every 32 bytes of push constant data constitutes one GEN register. */
 static const unsigned int BRW_BLORP_NUM_PUSH_CONST_REGS =
    sizeof(struct brw_blorp_wm_push_constants) / 32;
@@ -212,6 +215,14 @@ struct brw_blorp_prog_data
     * than one sample per pixel.
     */
    bool persample_msaa_dispatch;
+
+   /* The compiler will re-arrange push constants and store the upload order
+    * here. Given an index 'i' in the final upload buffer, param[i] gives the
+    * index in the uniform store. In other words, the value to be uploaded can
+    * be found by brw_blorp_params::wm_push_consts[param[i]].
+    */
+   uint8_t nr_params;
+   uint8_t param[BRW_BLORP_NUM_PUSH_CONSTANT_DWORDS];
 };
 
 void brw_blorp_prog_data_init(struct brw_blorp_prog_data *prog_data);
index 1955811b002b2eb0ed22e4ca051ed3b714cd29eb..fdd82869612e08c590ce2ce7b9fdb2473ca79415 100644 (file)
@@ -308,11 +308,13 @@ gen6_blorp_emit_wm_constants(struct brw_context *brw,
 {
    uint32_t wm_push_const_offset;
 
-   void *constants = brw_state_batch(brw, AUB_TRACE_WM_CONSTANTS,
-                                     sizeof(params->wm_push_consts),
-                                     32, &wm_push_const_offset);
-   memcpy(constants, &params->wm_push_consts,
-          sizeof(params->wm_push_consts));
+   uint32_t *constants = brw_state_batch(brw, AUB_TRACE_WM_CONSTANTS,
+                                         sizeof(params->wm_push_consts),
+                                         32, &wm_push_const_offset);
+
+   const uint32_t *push_consts = (const uint32_t *)&params->wm_push_consts;
+   for (unsigned i = 0; i < params->wm_prog_data->nr_params; i++)
+      constants[i] = push_consts[params->wm_prog_data->param[i]];
 
    return wm_push_const_offset;
 }