radv: Use vk_command_pool
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
This commit is contained in:
parent
c5b8ee8810
commit
29a164b088
|
@ -434,7 +434,7 @@ radv_destroy_cmd_buffer(struct radv_cmd_buffer *cmd_buffer)
|
|||
vk_object_base_finish(&cmd_buffer->meta_push_descriptors.base);
|
||||
|
||||
vk_command_buffer_finish(&cmd_buffer->vk);
|
||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
|
||||
vk_free(&cmd_buffer->pool->vk.alloc, cmd_buffer);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
|
@ -443,14 +443,15 @@ radv_create_cmd_buffer(struct radv_device *device, struct radv_cmd_pool *pool,
|
|||
{
|
||||
struct radv_cmd_buffer *cmd_buffer;
|
||||
unsigned ring;
|
||||
cmd_buffer = vk_zalloc(&pool->alloc, sizeof(*cmd_buffer), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
cmd_buffer = vk_zalloc(&pool->vk.alloc, sizeof(*cmd_buffer), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (cmd_buffer == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
VkResult result =
|
||||
vk_command_buffer_init(&cmd_buffer->vk, &device->vk, level);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
|
||||
vk_free(&cmd_buffer->pool->vk.alloc, cmd_buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -458,7 +459,7 @@ radv_create_cmd_buffer(struct radv_device *device, struct radv_cmd_pool *pool,
|
|||
cmd_buffer->pool = pool;
|
||||
|
||||
list_addtail(&cmd_buffer->pool_link, &pool->cmd_buffers);
|
||||
cmd_buffer->queue_family_index = pool->queue_family_index;
|
||||
cmd_buffer->queue_family_index = pool->vk.queue_family_index;
|
||||
|
||||
ring = radv_queue_family_to_ring(cmd_buffer->queue_family_index);
|
||||
|
||||
|
@ -4224,7 +4225,7 @@ radv_cmd_state_setup_sample_locations(struct radv_cmd_buffer *cmd_buffer,
|
|||
}
|
||||
|
||||
state->subpass_sample_locs =
|
||||
vk_alloc(&cmd_buffer->pool->alloc,
|
||||
vk_alloc(&cmd_buffer->pool->vk.alloc,
|
||||
sample_locs->postSubpassSampleLocationsCount * sizeof(state->subpass_sample_locs[0]),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (state->subpass_sample_locs == NULL) {
|
||||
|
@ -4271,8 +4272,8 @@ radv_cmd_state_setup_attachments(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
}
|
||||
|
||||
state->attachments =
|
||||
vk_alloc(&cmd_buffer->pool->alloc, pass->attachment_count * sizeof(state->attachments[0]), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
vk_alloc(&cmd_buffer->pool->vk.alloc, pass->attachment_count * sizeof(state->attachments[0]),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (state->attachments == NULL) {
|
||||
cmd_buffer->record_result = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
return cmd_buffer->record_result;
|
||||
|
@ -4962,8 +4963,8 @@ radv_EndCommandBuffer(VkCommandBuffer commandBuffer)
|
|||
|
||||
radv_describe_end_cmd_buffer(cmd_buffer);
|
||||
|
||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
|
||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.subpass_sample_locs);
|
||||
vk_free(&cmd_buffer->pool->vk.alloc, cmd_buffer->state.attachments);
|
||||
vk_free(&cmd_buffer->pool->vk.alloc, cmd_buffer->state.subpass_sample_locs);
|
||||
|
||||
VkResult result = cmd_buffer->device->ws->cs_finalize(cmd_buffer->cs);
|
||||
if (result != VK_SUCCESS)
|
||||
|
@ -5694,18 +5695,15 @@ radv_CreateCommandPool(VkDevice _device, const VkCommandPoolCreateInfo *pCreateI
|
|||
if (pool == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
vk_object_base_init(&device->vk, &pool->base, VK_OBJECT_TYPE_COMMAND_POOL);
|
||||
|
||||
if (pAllocator)
|
||||
pool->alloc = *pAllocator;
|
||||
else
|
||||
pool->alloc = device->vk.alloc;
|
||||
VkResult result = vk_command_pool_init(&pool->vk, &device->vk, pCreateInfo, pAllocator);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_free2(&device->vk.alloc, pAllocator, pool);
|
||||
return result;
|
||||
}
|
||||
|
||||
list_inithead(&pool->cmd_buffers);
|
||||
list_inithead(&pool->free_cmd_buffers);
|
||||
|
||||
pool->queue_family_index = pCreateInfo->queueFamilyIndex;
|
||||
|
||||
*pCmdPool = radv_cmd_pool_to_handle(pool);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
@ -5731,7 +5729,7 @@ radv_DestroyCommandPool(VkDevice _device, VkCommandPool commandPool,
|
|||
radv_destroy_cmd_buffer(cmd_buffer);
|
||||
}
|
||||
|
||||
vk_object_base_finish(&pool->base);
|
||||
vk_command_pool_finish(&pool->vk);
|
||||
vk_free2(&device->vk.alloc, pAllocator, pool);
|
||||
}
|
||||
|
||||
|
@ -7527,8 +7525,8 @@ radv_CmdSetRayTracingPipelineStackSizeKHR(VkCommandBuffer commandBuffer, uint32_
|
|||
void
|
||||
radv_cmd_buffer_end_render_pass(struct radv_cmd_buffer *cmd_buffer)
|
||||
{
|
||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
|
||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.subpass_sample_locs);
|
||||
vk_free(&cmd_buffer->pool->vk.alloc, cmd_buffer->state.attachments);
|
||||
vk_free(&cmd_buffer->pool->vk.alloc, cmd_buffer->state.subpass_sample_locs);
|
||||
|
||||
cmd_buffer->state.pass = NULL;
|
||||
cmd_buffer->state.subpass = NULL;
|
||||
|
|
|
@ -274,7 +274,7 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
|||
.height = dst_height,
|
||||
.layers = 1,
|
||||
},
|
||||
&cmd_buffer->pool->alloc, &fb);
|
||||
&cmd_buffer->pool->vk.alloc, &fb);
|
||||
VkPipeline *pipeline = NULL;
|
||||
unsigned fs_key = 0;
|
||||
switch (src_iview->aspect_mask) {
|
||||
|
@ -438,7 +438,7 @@ fail_pipeline:
|
|||
/* TODO: above comment is not valid for at least descriptor sets/pools,
|
||||
* as we may not free them till after execution finishes. Check others. */
|
||||
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb, &cmd_buffer->pool->alloc);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb, &cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -490,7 +490,7 @@ blit_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
|||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
},
|
||||
&cmd_buffer->pool->alloc, &sampler);
|
||||
&cmd_buffer->pool->vk.alloc, &sampler);
|
||||
|
||||
radv_meta_save(
|
||||
&saved_state, cmd_buffer,
|
||||
|
@ -620,7 +620,7 @@ blit_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
|||
|
||||
radv_meta_restore(&saved_state, cmd_buffer);
|
||||
|
||||
radv_DestroySampler(radv_device_to_handle(device), sampler, &cmd_buffer->pool->alloc);
|
||||
radv_DestroySampler(radv_device_to_handle(device), sampler, &cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
|
|
|
@ -179,7 +179,7 @@ blit2d_bind_dst(struct radv_cmd_buffer *cmd_buffer, struct radv_meta_blit2d_surf
|
|||
.width = width,
|
||||
.height = height,
|
||||
.layers = 1},
|
||||
&cmd_buffer->pool->alloc, &tmp->fb);
|
||||
&cmd_buffer->pool->vk.alloc, &tmp->fb);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -394,7 +394,7 @@ radv_meta_blit2d_normal_dst(struct radv_cmd_buffer *cmd_buffer,
|
|||
* descriptor sets, etc. has been used. We are free to delete it.
|
||||
*/
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), dst_temps.fb,
|
||||
&cmd_buffer->pool->alloc);
|
||||
&cmd_buffer->pool->vk.alloc);
|
||||
|
||||
if (src_type == BLIT2D_SRC_TYPE_BUFFER)
|
||||
radv_buffer_view_finish(&src_temps.bview);
|
||||
|
|
|
@ -2153,7 +2153,7 @@ radv_clear_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_image *im
|
|||
.width = width,
|
||||
.height = height,
|
||||
.layers = layer_count},
|
||||
&cmd_buffer->pool->alloc, &fb);
|
||||
&cmd_buffer->pool->vk.alloc, &fb);
|
||||
|
||||
VkAttachmentDescription2 att_desc = {
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
|
@ -2218,7 +2218,7 @@ radv_clear_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_image *im
|
|||
.srcAccessMask = 0,
|
||||
.dstAccessMask = 0,
|
||||
.dependencyFlags = 0}}},
|
||||
&cmd_buffer->pool->alloc, &pass);
|
||||
&cmd_buffer->pool->vk.alloc, &pass);
|
||||
|
||||
radv_cmd_buffer_begin_render_pass(cmd_buffer,
|
||||
&(VkRenderPassBeginInfo){
|
||||
|
@ -2265,8 +2265,8 @@ radv_clear_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_image *im
|
|||
|
||||
radv_image_view_finish(&iview);
|
||||
radv_cmd_buffer_end_render_pass(cmd_buffer);
|
||||
radv_DestroyRenderPass(device_h, pass, &cmd_buffer->pool->alloc);
|
||||
radv_DestroyFramebuffer(device_h, fb, &cmd_buffer->pool->alloc);
|
||||
radv_DestroyRenderPass(device_h, pass, &cmd_buffer->pool->vk.alloc);
|
||||
radv_DestroyFramebuffer(device_h, fb, &cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -278,7 +278,7 @@ copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buf
|
|||
struct radv_image *image, VkImageLayout layout,
|
||||
const VkBufferImageCopy2KHR *region)
|
||||
{
|
||||
if (cmd_buffer->pool->queue_family_index == RADV_QUEUE_TRANSFER) {
|
||||
if (cmd_buffer->pool->vk.queue_family_index == RADV_QUEUE_TRANSFER) {
|
||||
/* RADV_QUEUE_TRANSFER should only be used for the prime blit */
|
||||
assert(!region->imageOffset.x && !region->imageOffset.y && !region->imageOffset.z);
|
||||
assert(image->type == VK_IMAGE_TYPE_2D);
|
||||
|
|
|
@ -513,7 +513,7 @@ radv_process_depth_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_i
|
|||
.width = width,
|
||||
.height = height,
|
||||
.layers = 1},
|
||||
&cmd_buffer->pool->alloc, &fb_h);
|
||||
&cmd_buffer->pool->vk.alloc, &fb_h);
|
||||
|
||||
radv_cmd_buffer_begin_render_pass(cmd_buffer,
|
||||
&(VkRenderPassBeginInfo){
|
||||
|
@ -540,7 +540,7 @@ radv_process_depth_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_i
|
|||
radv_cmd_buffer_end_render_pass(cmd_buffer);
|
||||
|
||||
radv_image_view_finish(&iview);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->alloc);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -582,7 +582,7 @@ radv_process_color_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_i
|
|||
.width = width,
|
||||
.height = height,
|
||||
.layers = 1},
|
||||
&cmd_buffer->pool->alloc, &fb_h);
|
||||
&cmd_buffer->pool->vk.alloc, &fb_h);
|
||||
|
||||
radv_cmd_buffer_begin_render_pass(cmd_buffer,
|
||||
&(VkRenderPassBeginInfo){
|
||||
|
@ -619,7 +619,7 @@ radv_process_color_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_i
|
|||
radv_cmd_buffer_end_render_pass(cmd_buffer);
|
||||
|
||||
radv_image_view_finish(&iview);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->alloc);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -564,7 +564,7 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
.width = radv_minify(dst_image->info.width, region->dstSubresource.mipLevel),
|
||||
.height = radv_minify(dst_image->info.height, region->dstSubresource.mipLevel),
|
||||
.layers = 1},
|
||||
&cmd_buffer->pool->alloc, &fb_h);
|
||||
&cmd_buffer->pool->vk.alloc, &fb_h);
|
||||
|
||||
radv_cmd_buffer_begin_render_pass(cmd_buffer,
|
||||
&(VkRenderPassBeginInfo){
|
||||
|
@ -602,7 +602,7 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
|
||||
radv_image_view_finish(&src_iview);
|
||||
radv_image_view_finish(&dst_iview);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->alloc);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
radv_meta_restore(&saved_state, cmd_buffer);
|
||||
|
|
|
@ -1024,7 +1024,7 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
.width = extent.width + dstOffset.x,
|
||||
.height = extent.height + dstOffset.y,
|
||||
.layers = 1},
|
||||
&cmd_buffer->pool->alloc, &fb);
|
||||
&cmd_buffer->pool->vk.alloc, &fb);
|
||||
|
||||
radv_cmd_buffer_begin_render_pass(cmd_buffer,
|
||||
&(VkRenderPassBeginInfo){
|
||||
|
@ -1056,7 +1056,7 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
radv_image_view_finish(&src_iview);
|
||||
radv_image_view_finish(&dest_iview);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(cmd_buffer->device), fb,
|
||||
&cmd_buffer->pool->alloc);
|
||||
&cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
radv_meta_restore(&saved_state, cmd_buffer);
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#include "util/rwlock.h"
|
||||
#include "util/xmlconfig.h"
|
||||
#include "vk_alloc.h"
|
||||
#include "vk_command_buffer.h"
|
||||
#include "vk_command_pool.h"
|
||||
#include "vk_debug_report.h"
|
||||
#include "vk_device.h"
|
||||
#include "vk_format.h"
|
||||
|
@ -62,7 +64,6 @@
|
|||
#include "vk_log.h"
|
||||
#include "vk_physical_device.h"
|
||||
#include "vk_shader_module.h"
|
||||
#include "vk_command_buffer.h"
|
||||
#include "vk_queue.h"
|
||||
#include "vk_util.h"
|
||||
#include "vk_image.h"
|
||||
|
@ -1472,11 +1473,9 @@ struct radv_cmd_state {
|
|||
};
|
||||
|
||||
struct radv_cmd_pool {
|
||||
struct vk_object_base base;
|
||||
VkAllocationCallbacks alloc;
|
||||
struct vk_command_pool vk;
|
||||
struct list_head cmd_buffers;
|
||||
struct list_head free_cmd_buffers;
|
||||
uint32_t queue_family_index;
|
||||
};
|
||||
|
||||
struct radv_cmd_buffer_upload {
|
||||
|
@ -2888,7 +2887,7 @@ VK_DEFINE_HANDLE_CASTS(radv_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
|||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_acceleration_structure, base,
|
||||
VkAccelerationStructureKHR,
|
||||
VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_cmd_pool, base, VkCommandPool,
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_cmd_pool, vk.base, VkCommandPool,
|
||||
VK_OBJECT_TYPE_COMMAND_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer, base, VkBuffer, VK_OBJECT_TYPE_BUFFER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer_view, base, VkBufferView,
|
||||
|
|
Loading…
Reference in New Issue