mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 20:20:18 +01:00
lp: only map dt buffer on import from dmabuf
Adjusts `resource_from_handle` to follow original execution path
in cases where we are not importing a dmabuf.
Fixes: db38a4913e
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30441>
This commit is contained in:
parent
93f9afa1e0
commit
c44d65a467
1 changed files with 9 additions and 16 deletions
|
|
@ -730,7 +730,6 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
|
||||||
lpr->size_required = lpr->sample_stride;
|
lpr->size_required = lpr->sample_stride;
|
||||||
|
|
||||||
if (whandle->type != WINSYS_HANDLE_TYPE_UNBACKED) {
|
if (whandle->type != WINSYS_HANDLE_TYPE_UNBACKED) {
|
||||||
void *data;
|
|
||||||
#ifdef HAVE_LINUX_UDMABUF_H
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
struct llvmpipe_memory_allocation *alloc;
|
struct llvmpipe_memory_allocation *alloc;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
|
@ -741,13 +740,16 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
|
||||||
_screen->import_memory_fd(_screen, whandle->handle,
|
_screen->import_memory_fd(_screen, whandle->handle,
|
||||||
(struct pipe_memory_allocation**)&alloc,
|
(struct pipe_memory_allocation**)&alloc,
|
||||||
&size, true)) {
|
&size, true)) {
|
||||||
data = alloc->cpu_addr;
|
void *data = alloc->cpu_addr;
|
||||||
lpr->dt = winsys->displaytarget_create_mapped(winsys, template->bind,
|
lpr->dt = winsys->displaytarget_create_mapped(winsys, template->bind,
|
||||||
template->format, template->width0, template->height0,
|
template->format, template->width0, template->height0,
|
||||||
whandle->stride, data);
|
whandle->stride, data);
|
||||||
if (!lpr->dt)
|
if (!lpr->dt)
|
||||||
goto no_dt;
|
goto no_dt;
|
||||||
lpr->dmabuf_alloc = alloc;
|
lpr->dmabuf_alloc = alloc;
|
||||||
|
lpr->dmabuf = true;
|
||||||
|
lpr->tex_data = data;
|
||||||
|
lpr->row_stride[0] = whandle->stride;
|
||||||
whandle->size = size;
|
whandle->size = size;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -758,26 +760,16 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
|
||||||
&lpr->row_stride[0]);
|
&lpr->row_stride[0]);
|
||||||
if (!lpr->dt)
|
if (!lpr->dt)
|
||||||
goto no_dt;
|
goto no_dt;
|
||||||
data = winsys->displaytarget_map(winsys, lpr->dt, PIPE_MAP_READ_WRITE);
|
|
||||||
if (!data) {
|
|
||||||
winsys->displaytarget_destroy(winsys, lpr->dt);
|
|
||||||
goto no_dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
whandle->size = lpr->size_required;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(llvmpipe_resource_is_texture(&lpr->base));
|
assert(llvmpipe_resource_is_texture(&lpr->base));
|
||||||
lpr->tex_data = data;
|
|
||||||
} else {
|
} else {
|
||||||
whandle->size = lpr->size_required;
|
whandle->size = lpr->size_required;
|
||||||
lpr->backable = true;
|
lpr->backable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpr->row_stride[0] = whandle->stride;
|
|
||||||
|
|
||||||
lpr->id = id_counter++;
|
lpr->id = id_counter++;
|
||||||
lpr->dmabuf = true;
|
|
||||||
|
|
||||||
#if MESA_DEBUG
|
#if MESA_DEBUG
|
||||||
simple_mtx_lock(&resource_list_mutex);
|
simple_mtx_lock(&resource_list_mutex);
|
||||||
|
|
@ -805,9 +797,7 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
|
||||||
struct sw_winsys *winsys = screen->winsys;
|
struct sw_winsys *winsys = screen->winsys;
|
||||||
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
|
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
|
||||||
|
|
||||||
whandle->stride = lpr->row_stride[0];
|
|
||||||
#ifdef HAVE_LINUX_UDMABUF_H
|
#ifdef HAVE_LINUX_UDMABUF_H
|
||||||
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
|
|
||||||
if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_FD) {
|
if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_FD) {
|
||||||
if (!lpr->dmabuf_alloc) {
|
if (!lpr->dmabuf_alloc) {
|
||||||
lpr->dmabuf_alloc = (struct llvmpipe_memory_allocation*)_screen->allocate_memory_fd(_screen, lpr->size_required, (int*)&whandle->handle, true);
|
lpr->dmabuf_alloc = (struct llvmpipe_memory_allocation*)_screen->allocate_memory_fd(_screen, lpr->size_required, (int*)&whandle->handle, true);
|
||||||
|
|
@ -833,11 +823,14 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
|
||||||
lpr->backable = true;
|
lpr->backable = true;
|
||||||
}
|
}
|
||||||
whandle->handle = lpr->dmabuf_alloc->dmabuf_fd;
|
whandle->handle = lpr->dmabuf_alloc->dmabuf_fd;
|
||||||
|
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
|
||||||
|
whandle->stride = lpr->row_stride[0];
|
||||||
return true;
|
return true;
|
||||||
} else if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_KMS) {
|
} else if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_KMS) {
|
||||||
/* dri winsys code will use this to query the drm modifiers
|
/* dri winsys code will use this to query the drm modifiers
|
||||||
* We can just return an null handle and return DRM_FORMAT_MOD_LINEAR */
|
* We can just return an null handle and return DRM_FORMAT_MOD_LINEAR */
|
||||||
whandle->handle = 0;
|
whandle->handle = 0;
|
||||||
|
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1683,7 +1676,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
|
||||||
|
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case PIPE_RESOURCE_PARAM_NPLANES:
|
case PIPE_RESOURCE_PARAM_NPLANES:
|
||||||
*value = lpr->dt ? util_format_get_num_planes(lpr->dt_format) : 1;
|
*value = lpr->dmabuf ? util_format_get_num_planes(lpr->dt_format) : 1;
|
||||||
return true;
|
return true;
|
||||||
case PIPE_RESOURCE_PARAM_STRIDE:
|
case PIPE_RESOURCE_PARAM_STRIDE:
|
||||||
*value = lpr->row_stride[level];
|
*value = lpr->row_stride[level];
|
||||||
|
|
@ -1696,7 +1689,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
|
||||||
return true;
|
return true;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
case PIPE_RESOURCE_PARAM_MODIFIER:
|
case PIPE_RESOURCE_PARAM_MODIFIER:
|
||||||
*value = lpr->dt ? DRM_FORMAT_MOD_LINEAR : DRM_FORMAT_MOD_INVALID;
|
*value = lpr->dmabuf ? DRM_FORMAT_MOD_LINEAR : DRM_FORMAT_MOD_INVALID;
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_SHARED:
|
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_SHARED:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue