lavapipe: break out resolves into separate functions

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15462>
This commit is contained in:
Mike Blumenkrantz 2022-02-18 11:55:17 -05:00 committed by Marge Bot
parent 441c553ef7
commit 4a13b11f4a

View file

@ -1652,62 +1652,65 @@ slow_clear:
render_subpass_clear(state);
}
static void render_pass_resolve(struct rendering_state *state)
static void
resolve_ds(struct rendering_state *state, const struct lvp_subpass *subpass)
{
const struct lvp_subpass *subpass = state->subpass;
if (!subpass->depth_stencil_attachment || !(*subpass->depth_stencil_attachment) ||
!subpass->ds_resolve_attachment || !(*subpass->ds_resolve_attachment))
return;
struct lvp_render_pass_attachment *src_att = *subpass->depth_stencil_attachment;
struct lvp_render_pass_attachment *dst_att = *subpass->ds_resolve_attachment;
int num_blits = 1;
if (subpass->depth_resolve_mode != subpass->stencil_resolve_mode)
num_blits = 2;
if (subpass->depth_stencil_attachment && *subpass->depth_stencil_attachment &&
subpass->ds_resolve_attachment && *subpass->ds_resolve_attachment) {
struct lvp_render_pass_attachment *src_att = *subpass->depth_stencil_attachment;
struct lvp_render_pass_attachment *dst_att = *subpass->ds_resolve_attachment;
int num_blits = 1;
if (subpass->depth_resolve_mode != subpass->stencil_resolve_mode)
num_blits = 2;
for (unsigned i = 0; i < num_blits; i++) {
for (unsigned i = 0; i < num_blits; i++) {
if (i == 0 && subpass->depth_resolve_mode == VK_RESOLVE_MODE_NONE)
continue;
if (i == 0 && subpass->depth_resolve_mode == VK_RESOLVE_MODE_NONE)
continue;
if (i == 1 && subpass->stencil_resolve_mode == VK_RESOLVE_MODE_NONE)
continue;
if (i == 1 && subpass->stencil_resolve_mode == VK_RESOLVE_MODE_NONE)
continue;
struct lvp_image_view *src_imgv = get_attachment(state, src_att->attachment);
struct lvp_image_view *dst_imgv = get_attachment(state, dst_att->attachment);
struct lvp_image_view *src_imgv = get_attachment(state, src_att->attachment);
struct lvp_image_view *dst_imgv = get_attachment(state, dst_att->attachment);
struct pipe_blit_info info;
memset(&info, 0, sizeof(info));
struct pipe_blit_info info;
memset(&info, 0, sizeof(info));
info.src.resource = src_imgv->image->bo;
info.dst.resource = dst_imgv->image->bo;
info.src.format = src_imgv->pformat;
info.dst.format = dst_imgv->pformat;
info.filter = PIPE_TEX_FILTER_NEAREST;
info.src.resource = src_imgv->image->bo;
info.dst.resource = dst_imgv->image->bo;
info.src.format = src_imgv->pformat;
info.dst.format = dst_imgv->pformat;
info.filter = PIPE_TEX_FILTER_NEAREST;
if (num_blits == 1)
info.mask = PIPE_MASK_ZS;
else if (i == 0)
info.mask = PIPE_MASK_Z;
else
info.mask = PIPE_MASK_S;
if (num_blits == 1)
info.mask = PIPE_MASK_ZS;
else if (i == 0)
info.mask = PIPE_MASK_Z;
else
info.mask = PIPE_MASK_S;
if (i == 0 && subpass->depth_resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
info.sample0_only = true;
if (i == 1 && subpass->stencil_resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
info.sample0_only = true;
if (i == 0 && subpass->depth_resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
info.sample0_only = true;
if (i == 1 && subpass->stencil_resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
info.sample0_only = true;
info.src.box.x = state->render_area.offset.x;
info.src.box.y = state->render_area.offset.y;
info.src.box.width = state->render_area.extent.width;
info.src.box.height = state->render_area.extent.height;
info.src.box.depth = state->vk_framebuffer->layers;
info.src.box.x = state->render_area.offset.x;
info.src.box.y = state->render_area.offset.y;
info.src.box.width = state->render_area.extent.width;
info.src.box.height = state->render_area.extent.height;
info.src.box.depth = state->vk_framebuffer->layers;
info.dst.box = info.src.box;
info.dst.box = info.src.box;
state->pctx->blit(state->pctx, &info);
}
state->pctx->blit(state->pctx, &info);
}
}
static void
resolve_color(struct rendering_state *state, const struct lvp_subpass *subpass)
{
if (!subpass->has_color_resolve)
return;
for (uint32_t i = 0; i < subpass->color_count; i++) {
@ -1744,6 +1747,13 @@ static void render_pass_resolve(struct rendering_state *state)
}
}
static void render_pass_resolve(struct rendering_state *state)
{
const struct lvp_subpass *subpass = state->subpass;
resolve_ds(state, subpass);
resolve_color(state, subpass);
}
static void begin_render_subpass(struct rendering_state *state,
const struct lvp_subpass *subpass)
{