vk: Add anv_batch_emit_merge() helper macro
authorKristian Høgsberg <kristian.h.kristensen@intel.com>
Tue, 12 May 2015 05:23:38 +0000 (22:23 -0700)
committerKristian Høgsberg <kristian.h.kristensen@intel.com>
Tue, 12 May 2015 06:25:28 +0000 (23:25 -0700)
This lets us emit a state packet by merging to half-backed versions,
typically one from the pipeline object and one from a dynamic state
objects.

src/vulkan/device.c
src/vulkan/private.h

index 86fa3b8..737db86 100644 (file)
@@ -2236,14 +2236,9 @@ anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
    if (cmd_buffer->dirty & ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY)
       flush_descriptor_sets(cmd_buffer);
 
-   if (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_RS_DIRTY)) {
-      /* maybe: anv_batch_merge(batch, GEN8_3DSTATE_SF, a, b) */
-      uint32_t *dw;
-
-      dw = anv_batch_emit_dwords(&cmd_buffer->batch, GEN8_3DSTATE_SF_length);
-      for (uint32_t i = 0; i < GEN8_3DSTATE_SF_length; i++)
-         dw[i] = cmd_buffer->rs_state->state_sf[i] | pipeline->state_sf[i];
-   }
+   if (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_RS_DIRTY))
+      anv_batch_emit_merge(&cmd_buffer->batch,
+                           cmd_buffer->rs_state->state_sf, pipeline->state_sf);
 
    cmd_buffer->vb_dirty = 0;
    cmd_buffer->dirty = 0;
index cfcaf1c..545aeb3 100644 (file)
@@ -386,6 +386,16 @@ __gen_combine_address(struct anv_batch *batch, void *location,
       __dst;                                            \
    })
 
+#define anv_batch_emit_merge(batch, dwords0, dwords1)                   \
+   do {                                                                 \
+      uint32_t *dw;                                                     \
+                                                                        \
+      assert(ARRAY_SIZE(dwords0) == ARRAY_SIZE(dwords1));               \
+      dw = anv_batch_emit_dwords((batch), ARRAY_SIZE(dwords0));         \
+      for (uint32_t i = 0; i < ARRAY_SIZE(dwords0); i++)                \
+         dw[i] = (dwords0)[i] | (dwords1)[i];                           \
+   } while (0)
+
 struct anv_device_memory {
    struct anv_bo bo;
    VkDeviceSize map_size;