mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 05:20:09 +01:00
v3d: make v3d_flush_resource reallocate non-shareable resources
When we create a tiled resource originally to be non shareable, if later we want to share it, it could happen the tile format is not valid for sharing: only UIF formats are appropiate. In this case, we need to re-create the resource with a valid format. For more details, see https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13154. This commit is heavily inspired by asahi. Fixes `spec@ext_image_dma_buf_import@ext_image_dma_buf_import-tex-modifier`. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32661>
This commit is contained in:
parent
734ba8d785
commit
2abd85bbc0
3 changed files with 52 additions and 4 deletions
|
|
@ -198,7 +198,6 @@ spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail
|
|||
spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-modifiers,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-modifiers@autogen-R16-DRM_FORMAT_MOD_LINEAR-clear_reimport,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-tex-modifier,Crash
|
||||
spec@ext_packed_depth_stencil@texwrap formats bordercolor,Fail
|
||||
spec@ext_packed_depth_stencil@texwrap formats bordercolor-swizzled,Fail
|
||||
spec@ext_packed_depth_stencil@texwrap formats bordercolor-swizzled@GL_DEPTH24_STENCIL8- swizzled- border color only,Fail
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail
|
|||
spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-modifiers,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-modifiers@autogen-R16-DRM_FORMAT_MOD_LINEAR-clear_reimport,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-tex-modifier,Crash
|
||||
spec@ext_packed_depth_stencil@texwrap formats bordercolor,Fail
|
||||
spec@ext_packed_depth_stencil@texwrap formats bordercolor-swizzled,Fail
|
||||
spec@ext_packed_depth_stencil@texwrap formats bordercolor-swizzled@GL_DEPTH24_STENCIL8- swizzled- border color only,Fail
|
||||
|
|
|
|||
|
|
@ -1164,11 +1164,61 @@ v3d_surface_destroy(struct pipe_context *pctx, struct pipe_surface *psurf)
|
|||
}
|
||||
|
||||
static void
|
||||
v3d_flush_resource(struct pipe_context *pctx, struct pipe_resource *resource)
|
||||
v3d_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
|
||||
{
|
||||
/* All calls to flush_resource are followed by a flush of the context,
|
||||
* so there's nothing to do.
|
||||
* so there's nothing to do. Still, if the resource is going to be
|
||||
* shared and it is tiled, only UIF format is valid, so we need to
|
||||
* convert it.
|
||||
*/
|
||||
struct v3d_resource *rsc = v3d_resource(prsc);
|
||||
if (rsc->tiled &&
|
||||
rsc->slices[0].tiling != V3D_TILING_UIF_XOR &&
|
||||
rsc->slices[0].tiling != V3D_TILING_UIF_NO_XOR) {
|
||||
/* Shared resources must be not mipmapped */
|
||||
assert(prsc->last_level == 0);
|
||||
/* Shared resources must not be multisampled */
|
||||
assert(prsc->nr_samples <= 1);
|
||||
|
||||
struct pipe_resource ptmpl = *prsc;
|
||||
ptmpl.bind |= PIPE_BIND_SHARED;
|
||||
struct v3d_resource *new_rsc =
|
||||
v3d_resource(pctx->screen->resource_create(pctx->screen, &ptmpl));
|
||||
assert(new_rsc);
|
||||
|
||||
struct pipe_blit_info blit = { 0 };
|
||||
u_box_3d(0, 0, 0,
|
||||
prsc->width0, prsc->height0, prsc->depth0,
|
||||
&blit.dst.box);
|
||||
blit.src.box = blit.dst.box;
|
||||
blit.dst.resource = &new_rsc->base;
|
||||
blit.dst.format = new_rsc->base.format;
|
||||
blit.dst.level = 0;
|
||||
blit.src.resource = prsc;
|
||||
blit.src.format = prsc->format;
|
||||
blit.src.level = 0 ;
|
||||
blit.mask = util_format_get_mask(blit.src.format);
|
||||
blit.filter = PIPE_TEX_FILTER_NEAREST;
|
||||
|
||||
v3d_blit(pctx, &blit);
|
||||
|
||||
rsc->base.bind = new_rsc->base.bind;
|
||||
/* Swap the BOs */
|
||||
struct v3d_bo *old_bo = rsc->bo;
|
||||
rsc->bo = new_rsc->bo;
|
||||
rsc->serial_id++;
|
||||
new_rsc->bo = old_bo;
|
||||
|
||||
/* Copy the affected fields */
|
||||
rsc->slices[0] = new_rsc->slices[0];
|
||||
rsc->cube_map_stride = new_rsc->cube_map_stride;
|
||||
rsc->sand_col128_stride = new_rsc->sand_col128_stride;
|
||||
rsc->size = new_rsc->size;
|
||||
rsc->tiled = new_rsc->tiled;
|
||||
|
||||
struct pipe_resource *new_prsc = (struct pipe_resource *)&new_rsc;
|
||||
pipe_resource_reference(&new_prsc, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static enum pipe_format
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue