summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2021-04-01 13:52:58 +1000
committerMarge Bot <eric+marge@anholt.net>2021-04-01 19:05:29 +0000
commitfe53c22294900142c358b75d39c43710ccfd414e (patch)
treeb88789f6ef507070e4736ec41a21d825f2b747fe
parent7878497c94fcd6d60a52df1118601809e3246a43 (diff)
lavapipe: fix only clearing depth or stencil paths.
This fixes the ds clears path to clear only depth or stencil Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Fixes: b38879f8c5f ("vallium: initial import of the vulkan frontend") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9971>
-rw-r--r--src/gallium/frontends/lavapipe/lvp_execute.c81
1 files changed, 48 insertions, 33 deletions
diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c
index 50a150af1e9..874a1353c0a 100644
--- a/src/gallium/frontends/lavapipe/lvp_execute.c
+++ b/src/gallium/frontends/lavapipe/lvp_execute.c
@@ -1160,29 +1160,42 @@ 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)
+static struct pipe_surface *create_img_surface_bo(struct rendering_state *state,
+ VkImageSubresourceRange *range,
+ struct pipe_resource *bo,
+ enum pipe_format pformat,
+ int width,
+ int height,
+ int base_layer, int layer_count,
+ int level)
{
struct pipe_surface template;
memset(&template, 0, sizeof(struct pipe_surface));
- template.format = vk_format_to_pipe(format);
+ template.format = pformat;
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;
+ template.u.tex.first_layer = range->baseArrayLayer + base_layer;
+ template.u.tex.last_layer = range->baseArrayLayer + layer_count;
+ template.u.tex.level = range->baseMipLevel + level;
if (template.format == PIPE_FORMAT_NONE)
return NULL;
return state->pctx->create_surface(state->pctx,
- imgv->image->bo, &template);
+ bo, &template);
}
+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)
+{
+ return create_img_surface_bo(state, &imgv->subresourceRange, imgv->image->bo,
+ vk_format_to_pipe(format), width, height, base_layer, layer_count, 0);
+}
+
static void add_img_view_surface(struct rendering_state *state,
struct lvp_image_view *imgv, VkFormat format, int width, int height)
{
@@ -2464,33 +2477,35 @@ static void handle_clear_ds_image(struct lvp_cmd_buffer_entry *cmd,
struct rendering_state *state)
{
struct lvp_image *image = cmd->u.clear_ds_image.image;
- uint64_t col_val;
- col_val = util_pack64_z_stencil(image->bo->format, cmd->u.clear_ds_image.clear_val.depth, cmd->u.clear_ds_image.clear_val.stencil);
for (unsigned i = 0; i < cmd->u.clear_ds_image.range_count; i++) {
VkImageSubresourceRange *range = &cmd->u.clear_ds_image.ranges[i];
- struct pipe_box box;
- box.x = 0;
- box.y = 0;
- box.z = 0;
+ uint32_t ds_clear_flags = 0;
+ if (range->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT)
+ ds_clear_flags |= PIPE_CLEAR_DEPTH;
+ if (range->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)
+ ds_clear_flags |= PIPE_CLEAR_STENCIL;
uint32_t level_count = lvp_get_levelCount(image, range);
- for (unsigned j = range->baseMipLevel; j < range->baseMipLevel + level_count; j++) {
- box.width = u_minify(image->bo->width0, j);
- box.height = u_minify(image->bo->height0, j);
- box.depth = 1;
- if (image->bo->target == PIPE_TEXTURE_3D)
- box.depth = u_minify(image->bo->depth0, j);
- else if (image->bo->target == PIPE_TEXTURE_1D_ARRAY) {
- box.y = range->baseArrayLayer;
- box.height = lvp_get_layerCount(image, range);
- box.depth = 1;
- } else {
- box.z = range->baseArrayLayer;
- box.depth = lvp_get_layerCount(image, range);
- }
-
- state->pctx->clear_texture(state->pctx, image->bo,
- j, &box, (void *)&col_val);
+ for (unsigned j = 0; j < level_count; j++) {
+ struct pipe_surface *surf;
+ unsigned width, height;
+
+ width = u_minify(image->bo->width0, range->baseMipLevel + j);
+ height = u_minify(image->bo->height0, range->baseMipLevel + j);
+
+ surf = create_img_surface_bo(state, range,
+ image->bo, image->bo->format,
+ width, height,
+ 0, lvp_get_layerCount(image, range) - 1, j);
+
+ state->pctx->clear_depth_stencil(state->pctx,
+ surf,
+ ds_clear_flags,
+ cmd->u.clear_ds_image.clear_val.depth,
+ cmd->u.clear_ds_image.clear_val.stencil,
+ 0, 0,
+ width, height, true);
+ state->pctx->surface_destroy(state->pctx, surf);
}
}
}