radv/meta: rework creating compute depth/stencil resolve pipelines
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30244>
This commit is contained in:

committed by
Marge Bot

parent
22e1d0f293
commit
c5130e779c
@@ -223,24 +223,11 @@ create_depth_stencil_resolve_pipeline(struct radv_device *device, int samples, i
|
|||||||
{
|
{
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
mtx_lock(&device->meta_state.mtx);
|
|
||||||
if (*pipeline) {
|
|
||||||
mtx_unlock(&device->meta_state.mtx);
|
|
||||||
return VK_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
nir_shader *cs = build_depth_stencil_resolve_compute_shader(device, samples, index, resolve_mode);
|
nir_shader *cs = build_depth_stencil_resolve_compute_shader(device, samples, index, resolve_mode);
|
||||||
|
|
||||||
result = radv_meta_create_compute_pipeline(device, cs, device->meta_state.resolve_compute.p_layout, pipeline);
|
result = radv_meta_create_compute_pipeline(device, cs, device->meta_state.resolve_compute.p_layout, pipeline);
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ralloc_free(cs);
|
ralloc_free(cs);
|
||||||
mtx_unlock(&device->meta_state.mtx);
|
|
||||||
return VK_SUCCESS;
|
|
||||||
fail:
|
|
||||||
ralloc_free(cs);
|
|
||||||
mtx_unlock(&device->meta_state.mtx);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,42 +413,18 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, struct radv_image_view *src_ivi
|
|||||||
radv_unaligned_dispatch(cmd_buffer, resolve_extent->width, resolve_extent->height, 1);
|
radv_unaligned_dispatch(cmd_buffer, resolve_extent->width, resolve_extent->height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static VkResult
|
||||||
emit_depth_stencil_resolve(struct radv_cmd_buffer *cmd_buffer, struct radv_image_view *src_iview,
|
get_depth_stencil_resolve_pipeline(struct radv_device *device, int samples, VkImageAspectFlags aspects,
|
||||||
struct radv_image_view *dst_iview, const VkOffset2D *resolve_offset,
|
VkResolveModeFlagBits resolve_mode, VkPipeline *pipeline_out)
|
||||||
const VkExtent3D *resolve_extent, VkImageAspectFlags aspects,
|
|
||||||
VkResolveModeFlagBits resolve_mode)
|
|
||||||
{
|
{
|
||||||
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
|
const int index = aspects == VK_IMAGE_ASPECT_DEPTH_BIT ? DEPTH_RESOLVE : STENCIL_RESOLVE;
|
||||||
const uint32_t samples = src_iview->image->vk.samples;
|
|
||||||
const uint32_t samples_log2 = ffs(samples) - 1;
|
const uint32_t samples_log2 = ffs(samples) - 1;
|
||||||
|
struct radv_meta_state *state = &device->meta_state;
|
||||||
|
VkResult result = VK_SUCCESS;
|
||||||
VkPipeline *pipeline;
|
VkPipeline *pipeline;
|
||||||
|
|
||||||
radv_meta_push_descriptor_set(cmd_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
mtx_lock(&state->mtx);
|
||||||
device->meta_state.resolve_compute.p_layout, 0, 2,
|
|
||||||
(VkWriteDescriptorSet[]){{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
||||||
.dstBinding = 0,
|
|
||||||
.dstArrayElement = 0,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
||||||
.pImageInfo =
|
|
||||||
(VkDescriptorImageInfo[]){
|
|
||||||
{.sampler = VK_NULL_HANDLE,
|
|
||||||
.imageView = radv_image_view_to_handle(src_iview),
|
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL},
|
|
||||||
}},
|
|
||||||
{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
||||||
.dstBinding = 1,
|
|
||||||
.dstArrayElement = 0,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
|
||||||
.pImageInfo = (VkDescriptorImageInfo[]){
|
|
||||||
{
|
|
||||||
.sampler = VK_NULL_HANDLE,
|
|
||||||
.imageView = radv_image_view_to_handle(dst_iview),
|
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
},
|
|
||||||
}}});
|
|
||||||
|
|
||||||
switch (resolve_mode) {
|
switch (resolve_mode) {
|
||||||
case VK_RESOLVE_MODE_SAMPLE_ZERO_BIT:
|
case VK_RESOLVE_MODE_SAMPLE_ZERO_BIT:
|
||||||
@@ -491,17 +454,62 @@ emit_depth_stencil_resolve(struct radv_cmd_buffer *cmd_buffer, struct radv_image
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!*pipeline) {
|
if (!*pipeline) {
|
||||||
int index = aspects == VK_IMAGE_ASPECT_DEPTH_BIT ? DEPTH_RESOLVE : STENCIL_RESOLVE;
|
result = create_depth_stencil_resolve_pipeline(device, samples, index, resolve_mode, pipeline);
|
||||||
VkResult ret;
|
if (result != VK_SUCCESS)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
ret = create_depth_stencil_resolve_pipeline(device, samples, index, resolve_mode, pipeline);
|
*pipeline_out = *pipeline;
|
||||||
if (ret != VK_SUCCESS) {
|
|
||||||
vk_command_buffer_set_error(&cmd_buffer->vk, ret);
|
fail:
|
||||||
|
mtx_unlock(&state->mtx);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
emit_depth_stencil_resolve(struct radv_cmd_buffer *cmd_buffer, struct radv_image_view *src_iview,
|
||||||
|
struct radv_image_view *dst_iview, const VkOffset2D *resolve_offset,
|
||||||
|
const VkExtent3D *resolve_extent, VkImageAspectFlags aspects,
|
||||||
|
VkResolveModeFlagBits resolve_mode)
|
||||||
|
{
|
||||||
|
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
|
||||||
|
const uint32_t samples = src_iview->image->vk.samples;
|
||||||
|
VkPipeline pipeline;
|
||||||
|
VkResult result;
|
||||||
|
|
||||||
|
radv_meta_push_descriptor_set(cmd_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||||
|
device->meta_state.resolve_compute.p_layout, 0, 2,
|
||||||
|
(VkWriteDescriptorSet[]){{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
|
.dstBinding = 0,
|
||||||
|
.dstArrayElement = 0,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||||
|
.pImageInfo =
|
||||||
|
(VkDescriptorImageInfo[]){
|
||||||
|
{.sampler = VK_NULL_HANDLE,
|
||||||
|
.imageView = radv_image_view_to_handle(src_iview),
|
||||||
|
.imageLayout = VK_IMAGE_LAYOUT_GENERAL},
|
||||||
|
}},
|
||||||
|
{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
|
.dstBinding = 1,
|
||||||
|
.dstArrayElement = 0,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
|
.pImageInfo = (VkDescriptorImageInfo[]){
|
||||||
|
{
|
||||||
|
.sampler = VK_NULL_HANDLE,
|
||||||
|
.imageView = radv_image_view_to_handle(dst_iview),
|
||||||
|
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
},
|
||||||
|
}}});
|
||||||
|
|
||||||
|
result = get_depth_stencil_resolve_pipeline(device, samples, aspects, resolve_mode, &pipeline);
|
||||||
|
if (result != VK_SUCCESS) {
|
||||||
|
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
|
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
|
||||||
|
|
||||||
uint32_t push_constants[2] = {resolve_offset->x, resolve_offset->y};
|
uint32_t push_constants[2] = {resolve_offset->x, resolve_offset->y};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user