radv/meta: rework creating the gfx depth decompress pipeline

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:
Samuel Pitoiset
2024-07-17 20:32:12 +02:00
committed by Marge Bot
parent b54dc6a29a
commit f3e7c7e19f

View File

@@ -93,7 +93,7 @@ cleanup:
} }
static VkResult static VkResult
create_pipeline(struct radv_device *device, uint32_t samples, VkPipelineLayout layout, VkPipeline *pipeline) create_pipeline_gfx(struct radv_device *device, uint32_t samples, VkPipelineLayout layout, VkPipeline *pipeline)
{ {
VkResult result; VkResult result;
VkDevice device_h = radv_device_to_handle(device); VkDevice device_h = radv_device_to_handle(device);
@@ -254,8 +254,8 @@ radv_device_init_meta_depth_decomp_state(struct radv_device *device, bool on_dem
if (on_demand) if (on_demand)
continue; continue;
res = res = create_pipeline_gfx(device, samples, state->depth_decomp[i].p_layout,
create_pipeline(device, samples, state->depth_decomp[i].p_layout, &state->depth_decomp[i].decompress_pipeline); &state->depth_decomp[i].decompress_pipeline);
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
return res; return res;
} }
@@ -263,31 +263,27 @@ radv_device_init_meta_depth_decomp_state(struct radv_device *device, bool on_dem
return create_expand_depth_stencil_compute(device); return create_expand_depth_stencil_compute(device);
} }
static VkPipeline * static VkResult
radv_get_depth_pipeline(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image) get_pipeline_gfx(struct radv_device *device, struct radv_image *image, VkPipeline *pipeline_out)
{ {
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
struct radv_meta_state *state = &device->meta_state; struct radv_meta_state *state = &device->meta_state;
uint32_t samples = image->vk.samples; uint32_t samples = image->vk.samples;
uint32_t samples_log2 = ffs(samples) - 1; uint32_t samples_log2 = ffs(samples) - 1;
VkResult result = VK_SUCCESS;
mtx_lock(&state->mtx); mtx_lock(&state->mtx);
if (!state->depth_decomp[samples_log2].decompress_pipeline) { if (!state->depth_decomp[samples_log2].decompress_pipeline) {
VkResult ret; result = create_pipeline_gfx(device, samples, state->depth_decomp[samples_log2].p_layout,
&state->depth_decomp[samples_log2].decompress_pipeline);
ret = create_pipeline(device, samples, state->depth_decomp[samples_log2].p_layout, if (result != VK_SUCCESS)
&state->depth_decomp[samples_log2].decompress_pipeline); goto fail;
if (ret != VK_SUCCESS) {
mtx_unlock(&state->mtx);
vk_command_buffer_set_error(&cmd_buffer->vk, ret);
return NULL;
}
} }
VkPipeline *pipeline = &state->depth_decomp[samples_log2].decompress_pipeline; *pipeline_out = state->depth_decomp[samples_log2].decompress_pipeline;
fail:
mtx_unlock(&state->mtx); mtx_unlock(&state->mtx);
return pipeline; return result;
} }
static void static void
@@ -356,17 +352,21 @@ radv_process_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image
const VkImageSubresourceRange *subresourceRange, const VkImageSubresourceRange *subresourceRange,
struct radv_sample_locations_state *sample_locs) struct radv_sample_locations_state *sample_locs)
{ {
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
struct radv_meta_saved_state saved_state; struct radv_meta_saved_state saved_state;
VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer); VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
VkPipeline *pipeline; VkPipeline pipeline;
VkResult result;
pipeline = radv_get_depth_pipeline(cmd_buffer, image); result = get_pipeline_gfx(device, image, &pipeline);
if (!pipeline) if (result != VK_SUCCESS) {
return; vk_command_buffer_set_error(&cmd_buffer->vk, result);
return;
}
radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_RENDER); radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_RENDER);
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline); radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
if (sample_locs) { if (sample_locs) {
assert(image->vk.create_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT); assert(image->vk.create_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT);