vk/device: Use a bo pool for batch buffers
This commit is contained in:
@@ -303,6 +303,8 @@ parse_debug_flags(struct anv_device *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint32_t BATCH_SIZE = 1 << 15;
|
||||||
|
|
||||||
VkResult anv_CreateDevice(
|
VkResult anv_CreateDevice(
|
||||||
VkPhysicalDevice _physicalDevice,
|
VkPhysicalDevice _physicalDevice,
|
||||||
const VkDeviceCreateInfo* pCreateInfo,
|
const VkDeviceCreateInfo* pCreateInfo,
|
||||||
@@ -333,6 +335,8 @@ VkResult anv_CreateDevice(
|
|||||||
if (device->context_id == -1)
|
if (device->context_id == -1)
|
||||||
goto fail_fd;
|
goto fail_fd;
|
||||||
|
|
||||||
|
anv_bo_pool_init(&device->batch_bo_pool, device, BATCH_SIZE);
|
||||||
|
|
||||||
anv_block_pool_init(&device->dynamic_state_block_pool, device, 2048);
|
anv_block_pool_init(&device->dynamic_state_block_pool, device, 2048);
|
||||||
|
|
||||||
anv_state_pool_init(&device->dynamic_state_pool,
|
anv_state_pool_init(&device->dynamic_state_pool,
|
||||||
@@ -381,6 +385,8 @@ VkResult anv_DestroyDevice(
|
|||||||
|
|
||||||
anv_compiler_destroy(device->compiler);
|
anv_compiler_destroy(device->compiler);
|
||||||
|
|
||||||
|
|
||||||
|
anv_bo_pool_finish(&device->batch_bo_pool);
|
||||||
anv_block_pool_finish(&device->dynamic_state_block_pool);
|
anv_block_pool_finish(&device->dynamic_state_block_pool);
|
||||||
anv_block_pool_finish(&device->instruction_block_pool);
|
anv_block_pool_finish(&device->instruction_block_pool);
|
||||||
anv_block_pool_finish(&device->surface_state_block_pool);
|
anv_block_pool_finish(&device->surface_state_block_pool);
|
||||||
@@ -495,41 +501,25 @@ VkResult anv_GetDeviceQueue(
|
|||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint32_t BATCH_SIZE = 8192;
|
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
anv_batch_init(struct anv_batch *batch, struct anv_device *device)
|
anv_batch_init(struct anv_batch *batch, struct anv_device *device)
|
||||||
{
|
{
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
result = anv_bo_init_new(&batch->bo, device, BATCH_SIZE);
|
result = anv_bo_pool_alloc(&device->batch_bo_pool, &batch->bo);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
batch->bo.map =
|
|
||||||
anv_gem_mmap(device, batch->bo.gem_handle, 0, BATCH_SIZE);
|
|
||||||
if (batch->bo.map == NULL) {
|
|
||||||
result = vk_error(VK_ERROR_MEMORY_MAP_FAILED);
|
|
||||||
goto fail_bo;
|
|
||||||
}
|
|
||||||
|
|
||||||
batch->cmd_relocs.num_relocs = 0;
|
batch->cmd_relocs.num_relocs = 0;
|
||||||
batch->next = batch->bo.map;
|
batch->next = batch->bo.map;
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
fail_bo:
|
|
||||||
anv_gem_close(device, batch->bo.gem_handle);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
anv_batch_finish(struct anv_batch *batch, struct anv_device *device)
|
anv_batch_finish(struct anv_batch *batch, struct anv_device *device)
|
||||||
{
|
{
|
||||||
anv_gem_munmap(batch->bo.map, BATCH_SIZE);
|
anv_bo_pool_free(&device->batch_bo_pool, &batch->bo);
|
||||||
anv_gem_close(device, batch->bo.gem_handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -320,6 +320,8 @@ struct anv_device {
|
|||||||
bool no_hw;
|
bool no_hw;
|
||||||
bool dump_aub;
|
bool dump_aub;
|
||||||
|
|
||||||
|
struct anv_bo_pool batch_bo_pool;
|
||||||
|
|
||||||
struct anv_block_pool dynamic_state_block_pool;
|
struct anv_block_pool dynamic_state_block_pool;
|
||||||
struct anv_state_pool dynamic_state_pool;
|
struct anv_state_pool dynamic_state_pool;
|
||||||
|
|
||||||
@@ -421,7 +423,7 @@ struct anv_address {
|
|||||||
static inline uint64_t
|
static inline uint64_t
|
||||||
__gen_combine_address(struct anv_batch *batch, void *location,
|
__gen_combine_address(struct anv_batch *batch, void *location,
|
||||||
const struct anv_address address, uint32_t delta)
|
const struct anv_address address, uint32_t delta)
|
||||||
{
|
{
|
||||||
if (address.bo == NULL) {
|
if (address.bo == NULL) {
|
||||||
return delta;
|
return delta;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user