Mesa (main): anv: Make anv_batch_emit_reloc inline and optimize SKL+
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 8 23:09:30 UTC 2021
Module: Mesa
Branch: main
Commit: 6afc3f97b680bbdb671cbbc337e6d3a169b5ed61
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6afc3f97b680bbdb671cbbc337e6d3a169b5ed61
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Mon Jun 7 20:16:07 2021 -0500
anv: Make anv_batch_emit_reloc inline and optimize SKL+
This should drop the CPU overhead of processing buffers on SKL+ by
dropping some of the logic contained in anv_reloc_list_add() whenever we
have enough compile-time information to know we have softpin.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11236>
---
src/intel/vulkan/anv_batch_chain.c | 16 ----------------
src/intel/vulkan/anv_private.h | 32 ++++++++++++++++++++++++++++++--
2 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 51f78f71d12..a4a71d3c906 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -292,22 +292,6 @@ anv_batch_emit_dwords(struct anv_batch *batch, int num_dwords)
return p;
}
-uint64_t
-anv_batch_emit_reloc(struct anv_batch *batch,
- void *location, struct anv_bo *bo, uint32_t delta)
-{
- uint64_t address_u64 = 0;
- VkResult result = anv_reloc_list_add(batch->relocs, batch->alloc,
- location - batch->start, bo, delta,
- &address_u64);
- if (result != VK_SUCCESS) {
- anv_batch_set_error(batch, result);
- return 0;
- }
-
- return address_u64;
-}
-
struct anv_address
anv_batch_address(struct anv_batch *batch, void *batch_location)
{
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 0086a80afe4..f5716efba53 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1258,6 +1258,12 @@ struct anv_device {
struct intel_debug_block_frame *debug_frame_desc;
};
+#if defined(GFX_VERx10) && GFX_VERx10 >= 90
+#define ANV_ALWAYS_SOFTPIN true
+#else
+#define ANV_ALWAYS_SOFTPIN false
+#endif
+
static inline bool
anv_use_softpin(const struct anv_physical_device *pdevice)
{
@@ -1576,8 +1582,6 @@ struct anv_batch {
void *anv_batch_emit_dwords(struct anv_batch *batch, int num_dwords);
void anv_batch_emit_batch(struct anv_batch *batch, struct anv_batch *other);
-uint64_t anv_batch_emit_reloc(struct anv_batch *batch,
- void *location, struct anv_bo *bo, uint32_t offset);
struct anv_address anv_batch_address(struct anv_batch *batch, void *batch_location);
static inline void
@@ -1604,6 +1608,30 @@ anv_batch_has_error(struct anv_batch *batch)
return batch->status != VK_SUCCESS;
}
+static inline uint64_t
+anv_batch_emit_reloc(struct anv_batch *batch,
+ void *location, struct anv_bo *bo, uint32_t delta)
+{
+ uint64_t address_u64 = 0;
+ VkResult result;
+
+ if (ANV_ALWAYS_SOFTPIN) {
+ address_u64 = bo->offset + delta;
+ result = anv_reloc_list_add_bo(batch->relocs, batch->alloc, bo);
+ } else {
+ result = anv_reloc_list_add(batch->relocs, batch->alloc,
+ location - batch->start, bo, delta,
+ &address_u64);
+ }
+ if (unlikely(result != VK_SUCCESS)) {
+ anv_batch_set_error(batch, result);
+ return 0;
+ }
+
+ return address_u64;
+}
+
+
#define ANV_NULL_ADDRESS ((struct anv_address) { NULL, 0 })
static inline bool
More information about the mesa-commit
mailing list