vk: Call anv_batch_emit_dwords() up front in anv_batch_emit()
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 31 Jul 2015 20:45:54 +0000 (13:45 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Mon, 3 Aug 2015 22:38:14 +0000 (15:38 -0700)
This avoids putting a memory barrier between the template struct and
the pack function, which generates much better code.

src/vulkan/anv_private.h

index f14a6ca858f8720f80e0f7d5571f68814aafcaec..48edc6c95ed04e9fe97e29457652c9fc3909f5c7 100644 (file)
@@ -528,22 +528,22 @@ __gen_combine_address(struct anv_batch *batch, void *location,
 #include "gen8_pack.h"
 
 #define anv_batch_emit(batch, cmd, ...) do {                            \
+      void *__dst = anv_batch_emit_dwords(batch, cmd ## _length);       \
       struct cmd __template = {                                         \
          cmd ## _header,                                                \
          __VA_ARGS__                                                    \
       };                                                                \
-      void *__dst = anv_batch_emit_dwords(batch, cmd ## _length);       \
       cmd ## _pack(batch, __dst, &__template);                          \
       VG(VALGRIND_CHECK_MEM_IS_DEFINED(__dst, cmd ## _length * 4));     \
    } while (0)
 
 #define anv_batch_emitn(batch, n, cmd, ...) ({          \
+      void *__dst = anv_batch_emit_dwords(batch, n);    \
       struct cmd __template = {                         \
          cmd ## _header,                                \
         .DwordLength = n - cmd ## _length_bias,         \
          __VA_ARGS__                                    \
       };                                                \
-      void *__dst = anv_batch_emit_dwords(batch, n);    \
       cmd ## _pack(batch, __dst, &__template);          \
       __dst;                                            \
    })