aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-12-02 15:22:38 -0600
committerJason Ekstrand <[email protected]>2019-12-05 10:59:10 -0600
commit03450e9cfc526158e1a1e862a9f6bb8610de2be9 (patch)
treeb5667b5479c74413e4ba36cc633dba7d392f54aa /src/intel
parent597fdb9e210b53680f1eb703778f9d1a196190a8 (diff)
anv: Add an explicit_address parameter to anv_device_alloc_bo
We already have a mechanism for specifying that we want a fixed address provided by the driver internals. We're about to let the client start specifying addresses in some very special scenarios as well so we want to pass this through to the allocation function. Reviewed-by: Ivan Briano <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_allocator.c13
-rw-r--r--src/intel/vulkan/anv_descriptor_set.c1
-rw-r--r--src/intel/vulkan/anv_device.c9
-rw-r--r--src/intel/vulkan/anv_private.h6
-rw-r--r--src/intel/vulkan/anv_queue.c3
-rw-r--r--src/intel/vulkan/genX_query.c1
6 files changed, 26 insertions, 7 deletions
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index f939a0c7c0e..eed6a194dd7 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -498,18 +498,17 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
if (pool->use_softpin) {
uint32_t new_bo_size = size - pool->size;
struct anv_bo *new_bo;
+ assert(center_bo_offset == 0);
VkResult result = anv_device_alloc_bo(pool->device, new_bo_size,
bo_alloc_flags |
ANV_BO_ALLOC_FIXED_ADDRESS |
ANV_BO_ALLOC_MAPPED |
ANV_BO_ALLOC_SNOOPED,
+ pool->start_address + pool->size,
&new_bo);
if (result != VK_SUCCESS)
return result;
- assert(center_bo_offset == 0);
-
- new_bo->offset = pool->start_address + pool->size;
pool->bos[pool->nbos++] = new_bo;
/* This pointer will always point to the first BO in the list */
@@ -1316,6 +1315,7 @@ anv_bo_pool_alloc(struct anv_bo_pool *pool, uint32_t size,
pow2_size,
ANV_BO_ALLOC_MAPPED |
ANV_BO_ALLOC_SNOOPED,
+ 0 /* explicit_address */,
&bo);
if (result != VK_SUCCESS)
return result;
@@ -1454,7 +1454,9 @@ anv_scratch_pool_alloc(struct anv_device *device, struct anv_scratch_pool *pool,
* so nothing will ever touch the top page.
*/
VkResult result = anv_device_alloc_bo(device, size,
- ANV_BO_ALLOC_32BIT_ADDRESS, &bo);
+ ANV_BO_ALLOC_32BIT_ADDRESS,
+ 0 /* explicit_address */,
+ &bo);
if (result != VK_SUCCESS)
return NULL; /* TODO */
@@ -1528,6 +1530,7 @@ VkResult
anv_device_alloc_bo(struct anv_device *device,
uint64_t size,
enum anv_bo_alloc_flags alloc_flags,
+ uint64_t explicit_address,
struct anv_bo **bo_out)
{
const uint32_t bo_flags =
@@ -1580,7 +1583,9 @@ anv_device_alloc_bo(struct anv_device *device,
if (alloc_flags & ANV_BO_ALLOC_FIXED_ADDRESS) {
new_bo.has_fixed_address = true;
+ new_bo.offset = explicit_address;
} else {
+ assert(explicit_address == 0);
if (!anv_vma_alloc(device, &new_bo)) {
if (new_bo.map)
anv_gem_munmap(new_bo.map, size);
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index af8fa40a0a9..020b6abd5ed 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -746,6 +746,7 @@ VkResult anv_CreateDescriptorPool(
descriptor_bo_size,
ANV_BO_ALLOC_MAPPED |
ANV_BO_ALLOC_SNOOPED,
+ 0 /* explicit_address */,
&pool->bo);
if (result != VK_SUCCESS) {
vk_free2(&device->alloc, pAllocator, pool);
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 6a2c25478d1..d300350b789 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -2158,6 +2158,7 @@ anv_device_init_trivial_batch(struct anv_device *device)
{
VkResult result = anv_device_alloc_bo(device, 4096,
ANV_BO_ALLOC_MAPPED,
+ 0 /* explicit_address */,
&device->trivial_batch_bo);
if (result != VK_SUCCESS)
return result;
@@ -2266,6 +2267,7 @@ anv_device_init_hiz_clear_value_bo(struct anv_device *device)
{
VkResult result = anv_device_alloc_bo(device, 4096,
ANV_BO_ALLOC_MAPPED,
+ 0 /* explicit_address */,
&device->hiz_clear_bo);
if (result != VK_SUCCESS)
return result;
@@ -2597,7 +2599,9 @@ VkResult anv_CreateDevice(
goto fail_binding_table_pool;
}
- result = anv_device_alloc_bo(device, 4096, 0, &device->workaround_bo);
+ result = anv_device_alloc_bo(device, 4096, 0 /* flags */,
+ 0 /* explicit_address */,
+ &device->workaround_bo);
if (result != VK_SUCCESS)
goto fail_surface_aux_map_pool;
@@ -3184,7 +3188,8 @@ VkResult anv_AllocateMemory(
alloc_flags |= ANV_BO_ALLOC_EXTERNAL;
result = anv_device_alloc_bo(device, pAllocateInfo->allocationSize,
- alloc_flags, &mem->bo);
+ alloc_flags, 0 /* explicit_address */,
+ &mem->bo);
if (result != VK_SUCCESS)
goto fail;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 127af8b01fd..3e168f2b66d 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1331,7 +1331,10 @@ enum anv_bo_alloc_flags {
/** Specifies that the BO should be captured in error states */
ANV_BO_ALLOC_CAPTURE = (1 << 4),
- /** Specifies that the BO will have an address assigned by the caller */
+ /** Specifies that the BO will have an address assigned by the caller
+ *
+ * Such BOs do not exist in any VMA heap.
+ */
ANV_BO_ALLOC_FIXED_ADDRESS = (1 << 5),
/** Enables implicit synchronization on the BO
@@ -1349,6 +1352,7 @@ enum anv_bo_alloc_flags {
VkResult anv_device_alloc_bo(struct anv_device *device, uint64_t size,
enum anv_bo_alloc_flags alloc_flags,
+ uint64_t explicit_address,
struct anv_bo **bo);
VkResult anv_device_import_bo_from_host_ptr(struct anv_device *device,
void *host_ptr, uint32_t size,
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index 3dedbcade46..86010dbba0f 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -167,6 +167,7 @@ anv_timeline_add_point_locked(struct anv_device *device,
result = anv_device_alloc_bo(device, 4096,
ANV_BO_ALLOC_EXTERNAL |
ANV_BO_ALLOC_IMPLICIT_SYNC,
+ 0 /* explicit_address */,
&(*point)->bo);
if (result != VK_SUCCESS)
vk_free(&device->alloc, *point);
@@ -573,6 +574,7 @@ anv_queue_submit_simple_batch(struct anv_queue *queue,
result = anv_device_alloc_bo(device, 4096,
ANV_BO_ALLOC_EXTERNAL |
ANV_BO_ALLOC_IMPLICIT_SYNC,
+ 0 /* explicit_address */,
&sync_bo);
if (result != VK_SUCCESS)
goto err_free_submit;
@@ -1669,6 +1671,7 @@ binary_semaphore_create(struct anv_device *device,
anv_device_alloc_bo(device, 4096,
ANV_BO_ALLOC_EXTERNAL |
ANV_BO_ALLOC_IMPLICIT_SYNC,
+ 0 /* explicit_address */,
&impl->bo);
/* If we're going to use this as a fence, we need to *not* have the
* EXEC_OBJECT_ASYNC bit set.
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
index 0a295cebb87..6a512d3ea7b 100644
--- a/src/intel/vulkan/genX_query.c
+++ b/src/intel/vulkan/genX_query.c
@@ -125,6 +125,7 @@ VkResult genX(CreateQueryPool)(
result = anv_device_alloc_bo(device, size,
ANV_BO_ALLOC_MAPPED |
ANV_BO_ALLOC_SNOOPED,
+ 0 /* explicit_address */,
&pool->bo);
if (result != VK_SUCCESS)
goto fail;