gallium/dri: let the driver know if the imported image is DRI_PRIME buffer
Use createImageFromFds2 together with __DRI_IMAGE_PRIME_LINEAR_BUFFER, so the driver's resource_from_handle hook will be aware that this specific image is the linear buffer. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13362>
This commit is contained in:
@@ -1411,6 +1411,7 @@ enum __DRIChromaSiting {
|
|||||||
* Flags for createImageFromDmaBufs3 and createImageFromFds2
|
* Flags for createImageFromDmaBufs3 and createImageFromFds2
|
||||||
*/
|
*/
|
||||||
#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
|
#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
|
||||||
|
#define __DRI_IMAGE_PRIME_LINEAR_BUFFER 0x00000002
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* queryDmaBufFormatModifierAttribs attributes
|
* queryDmaBufFormatModifierAttribs attributes
|
||||||
|
@@ -1526,6 +1526,8 @@ dri2_from_fds2(__DRIscreen *screen, int width, int height, int fourcc,
|
|||||||
unsigned bind = 0;
|
unsigned bind = 0;
|
||||||
if (flags & __DRI_IMAGE_PROTECTED_CONTENT_FLAG)
|
if (flags & __DRI_IMAGE_PROTECTED_CONTENT_FLAG)
|
||||||
bind |= PIPE_BIND_PROTECTED;
|
bind |= PIPE_BIND_PROTECTED;
|
||||||
|
if (flags & __DRI_IMAGE_PRIME_LINEAR_BUFFER)
|
||||||
|
bind |= PIPE_BIND_DRI_PRIME;
|
||||||
|
|
||||||
return dri2_create_image_from_fd(screen, width, height, fourcc,
|
return dri2_create_image_from_fd(screen, width, height, fourcc,
|
||||||
DRM_FORMAT_MOD_INVALID, fds, num_fds,
|
DRM_FORMAT_MOD_INVALID, fds, num_fds,
|
||||||
|
@@ -514,6 +514,7 @@ enum pipe_flush_flags
|
|||||||
#define PIPE_BIND_LINEAR (1 << 21)
|
#define PIPE_BIND_LINEAR (1 << 21)
|
||||||
#define PIPE_BIND_PROTECTED (1 << 22) /* Resource will be protected/encrypted */
|
#define PIPE_BIND_PROTECTED (1 << 22) /* Resource will be protected/encrypted */
|
||||||
#define PIPE_BIND_SAMPLER_REDUCTION_MINMAX (1 << 23) /* PIPE_CAP_SAMPLER_REDUCTION_MINMAX */
|
#define PIPE_BIND_SAMPLER_REDUCTION_MINMAX (1 << 23) /* PIPE_CAP_SAMPLER_REDUCTION_MINMAX */
|
||||||
|
#define PIPE_BIND_DRI_PRIME (1 << 24)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1545,15 +1545,27 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
|
|||||||
/* The linear buffer was created in the display GPU's vram, so we
|
/* The linear buffer was created in the display GPU's vram, so we
|
||||||
* need to make it visible to render GPU
|
* need to make it visible to render GPU
|
||||||
*/
|
*/
|
||||||
buffer->linear_buffer =
|
if (draw->ext->image->base.version >= 20)
|
||||||
draw->ext->image->createImageFromFds(draw->dri_screen,
|
buffer->linear_buffer =
|
||||||
width,
|
draw->ext->image->createImageFromFds2(draw->dri_screen,
|
||||||
height,
|
width,
|
||||||
image_format_to_fourcc(format),
|
height,
|
||||||
&buffer_fds[0], num_planes,
|
image_format_to_fourcc(format),
|
||||||
&buffer->strides[0],
|
&buffer_fds[0], num_planes,
|
||||||
&buffer->offsets[0],
|
__DRI_IMAGE_PRIME_LINEAR_BUFFER,
|
||||||
buffer);
|
&buffer->strides[0],
|
||||||
|
&buffer->offsets[0],
|
||||||
|
buffer);
|
||||||
|
else
|
||||||
|
buffer->linear_buffer =
|
||||||
|
draw->ext->image->createImageFromFds(draw->dri_screen,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
image_format_to_fourcc(format),
|
||||||
|
&buffer_fds[0], num_planes,
|
||||||
|
&buffer->strides[0],
|
||||||
|
&buffer->offsets[0],
|
||||||
|
buffer);
|
||||||
if (!buffer->linear_buffer)
|
if (!buffer->linear_buffer)
|
||||||
goto no_buffer_attrib;
|
goto no_buffer_attrib;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user