lavapipe: refactor image surface creation
There is a need to create arbitrary surfaces for clearing, so split out the templating from the storing to img->vk_surface so temporary surfaces can be created for clearing. Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8182>
This commit is contained in:
@@ -1096,25 +1096,36 @@ static void handle_descriptor_sets(struct lvp_cmd_buffer_entry *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
static struct pipe_surface *create_img_surface(struct rendering_state *state,
|
||||
struct lvp_image_view *imgv,
|
||||
VkFormat format, int width,
|
||||
int height,
|
||||
int base_layer, int layer_count)
|
||||
{
|
||||
struct pipe_surface template;
|
||||
|
||||
memset(&template, 0, sizeof(struct pipe_surface));
|
||||
|
||||
template.format = vk_format_to_pipe(format);
|
||||
template.width = width;
|
||||
template.height = height;
|
||||
template.u.tex.first_layer = imgv->subresourceRange.baseArrayLayer + base_layer;
|
||||
template.u.tex.last_layer = imgv->subresourceRange.baseArrayLayer + layer_count;
|
||||
template.u.tex.level = imgv->subresourceRange.baseMipLevel;
|
||||
|
||||
if (template.format == PIPE_FORMAT_NONE)
|
||||
return NULL;
|
||||
return state->pctx->create_surface(state->pctx,
|
||||
imgv->image->bo, &template);
|
||||
|
||||
}
|
||||
static void add_img_view_surface(struct rendering_state *state,
|
||||
struct lvp_image_view *imgv, VkFormat format, int width, int height)
|
||||
{
|
||||
if (!imgv->surface) {
|
||||
struct pipe_surface template;
|
||||
|
||||
memset(&template, 0, sizeof(struct pipe_surface));
|
||||
|
||||
template.format = vk_format_to_pipe(format);
|
||||
template.width = width;
|
||||
template.height = height;
|
||||
template.u.tex.first_layer = imgv->subresourceRange.baseArrayLayer;
|
||||
template.u.tex.last_layer = imgv->subresourceRange.baseArrayLayer + lvp_get_layerCount(imgv->image, &imgv->subresourceRange) - 1;
|
||||
template.u.tex.level = imgv->subresourceRange.baseMipLevel;
|
||||
|
||||
if (template.format == PIPE_FORMAT_NONE)
|
||||
return;
|
||||
imgv->surface = state->pctx->create_surface(state->pctx,
|
||||
imgv->image->bo, &template);
|
||||
imgv->surface = create_img_surface(state, imgv, format,
|
||||
width, height,
|
||||
0, lvp_get_layerCount(imgv->image, &imgv->subresourceRange) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user