radv/meta: create the fill/copy pipelines on-demand
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30233>
This commit is contained in:
committed by
Marge Bot
parent
c57987afc7
commit
20be729636
@@ -473,7 +473,7 @@ radv_device_init_meta(struct radv_device *device)
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_depth_decomp;
|
||||
|
||||
result = radv_device_init_meta_buffer_state(device);
|
||||
result = radv_device_init_meta_buffer_state(device, on_demand);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_buffer;
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ void radv_device_finish_meta_blit_state(struct radv_device *device);
|
||||
VkResult radv_device_init_meta_blit2d_state(struct radv_device *device, bool on_demand);
|
||||
void radv_device_finish_meta_blit2d_state(struct radv_device *device);
|
||||
|
||||
VkResult radv_device_init_meta_buffer_state(struct radv_device *device);
|
||||
VkResult radv_device_init_meta_buffer_state(struct radv_device *device, bool on_demand);
|
||||
void radv_device_finish_meta_buffer_state(struct radv_device *device);
|
||||
|
||||
VkResult radv_device_init_meta_query_state(struct radv_device *device, bool on_demand);
|
||||
|
||||
@@ -59,6 +59,26 @@ create_fill_pipeline(struct radv_device *device)
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_fill_pipeline(struct radv_device *device, VkPipeline *pipeline_out)
|
||||
{
|
||||
struct radv_meta_state *state = &device->meta_state;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
mtx_lock(&state->mtx);
|
||||
if (!state->buffer.fill_pipeline) {
|
||||
result = create_fill_pipeline(device);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*pipeline_out = state->buffer.fill_pipeline;
|
||||
|
||||
fail:
|
||||
mtx_unlock(&state->mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
static nir_shader *
|
||||
build_buffer_copy_shader(struct radv_device *dev)
|
||||
{
|
||||
@@ -111,11 +131,34 @@ create_copy_pipeline(struct radv_device *device)
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_copy_pipeline(struct radv_device *device, VkPipeline *pipeline_out)
|
||||
{
|
||||
struct radv_meta_state *state = &device->meta_state;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
mtx_lock(&state->mtx);
|
||||
if (!state->buffer.copy_pipeline) {
|
||||
result = create_copy_pipeline(device);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*pipeline_out = state->buffer.copy_pipeline;
|
||||
|
||||
fail:
|
||||
mtx_unlock(&state->mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
VkResult
|
||||
radv_device_init_meta_buffer_state(struct radv_device *device)
|
||||
radv_device_init_meta_buffer_state(struct radv_device *device, bool on_demand)
|
||||
{
|
||||
VkResult result;
|
||||
|
||||
if (on_demand)
|
||||
return VK_SUCCESS;
|
||||
|
||||
result = create_fill_pipeline(device);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
@@ -143,11 +186,18 @@ fill_buffer_shader(struct radv_cmd_buffer *cmd_buffer, uint64_t va, uint64_t siz
|
||||
{
|
||||
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
|
||||
struct radv_meta_saved_state saved_state;
|
||||
VkPipeline pipeline;
|
||||
VkResult result;
|
||||
|
||||
result = get_fill_pipeline(device, &pipeline);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_COMPUTE_PIPELINE | RADV_META_SAVE_CONSTANTS);
|
||||
|
||||
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
device->meta_state.buffer.fill_pipeline);
|
||||
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
|
||||
|
||||
assert(size >= 16 && size <= UINT32_MAX);
|
||||
|
||||
@@ -170,11 +220,18 @@ copy_buffer_shader(struct radv_cmd_buffer *cmd_buffer, uint64_t src_va, uint64_t
|
||||
{
|
||||
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
|
||||
struct radv_meta_saved_state saved_state;
|
||||
VkPipeline pipeline;
|
||||
VkResult result;
|
||||
|
||||
result = get_copy_pipeline(device, &pipeline);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_COMPUTE_PIPELINE | RADV_META_SAVE_CONSTANTS);
|
||||
|
||||
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
device->meta_state.buffer.copy_pipeline);
|
||||
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
|
||||
|
||||
assert(size >= 16 && size <= UINT32_MAX);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user