summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_batch_chain.c
diff options
context:
space:
mode:
authorKristian Høgsberg Kristensen <[email protected]>2015-08-19 14:33:22 -0700
committerKristian Høgsberg Kristensen <[email protected]>2015-08-24 13:45:40 -0700
commite43fc871be2d60bd182c9c83372c61ff43d19ab1 (patch)
tree3d2989ed21fc7be63a55fad0ed06d036215a85e9 /src/vulkan/anv_batch_chain.c
parent25ab43ee8cde04914eb19ed060cedf98c94287a3 (diff)
vk: Make batch chain code gen-agnostic
Since the extra dword in MI_BATCH_BUFFER_START added in gen8 is at the end of the struct, we can emit the gen8 packet on all gens as long as we set the instruction length correctly. Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
Diffstat (limited to 'src/vulkan/anv_batch_chain.c')
-rw-r--r--src/vulkan/anv_batch_chain.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/vulkan/anv_batch_chain.c b/src/vulkan/anv_batch_chain.c
index f1d7bea840a..af90fb7ae21 100644
--- a/src/vulkan/anv_batch_chain.c
+++ b/src/vulkan/anv_batch_chain.c
@@ -398,7 +398,21 @@ anv_cmd_buffer_current_surface_relocs(struct anv_cmd_buffer *cmd_buffer)
static void
emit_batch_buffer_start(struct anv_batch *batch, struct anv_bo *bo, uint32_t offset)
{
+ /* In gen8+ the address field grew to two dwords to accomodate 48 bit
+ * offsets. The high 16 bits are in the last dword, so we can use the gen8
+ * version in either case, as long as we set the instruction length in the
+ * header accordingly. This means that we always emit three dwords here
+ * and all the padding and adjustment we do in this file works for all
+ * gens.
+ */
+
+ const uint32_t gen7_length =
+ GEN7_MI_BATCH_BUFFER_START_length - GEN7_MI_BATCH_BUFFER_START_length_bias;
+ const uint32_t gen8_length =
+ GEN8_MI_BATCH_BUFFER_START_length - GEN8_MI_BATCH_BUFFER_START_length_bias;
+
anv_batch_emit(batch, GEN8_MI_BATCH_BUFFER_START,
+ .DwordLength = batch->device->info.gen < 8 ? gen7_length : gen8_length,
._2ndLevelBatchBuffer = _1stlevelbatch,
.AddressSpaceIndicator = ASI_PPGTT,
.BatchBufferStartAddress = { bo, offset });