This is required for glXCopySubBufferMESA to work.
Signed-off-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11714>
static struct virgl_hw_res *
fake_resource_create(struct virgl_winsys *vws,
enum pipe_texture_target target,
+ const void *map_front_private,
uint32_t format, uint32_t bind,
uint32_t width, uint32_t height,
uint32_t depth, uint32_t array_size,
static struct virgl_hw_res *
failing_resource_create(struct virgl_winsys *vws,
enum pipe_texture_target target,
+ const void *map_front_private,
uint32_t format, uint32_t bind,
uint32_t width, uint32_t height,
uint32_t depth, uint32_t array_size,
vflags = pipe_to_virgl_flags(vs, templ->flags);
hw_res = vs->vws->resource_create(vs->vws,
templ->target,
+ NULL,
templ->format,
vbind,
templ->width0,
metadata->total_size = 0;
}
-static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen,
- const struct pipe_resource *templ)
+static struct pipe_resource *virgl_resource_create_front(struct pipe_screen *screen,
+ const struct pipe_resource *templ,
+ const void *map_front_private)
{
unsigned vbind, vflags;
struct virgl_screen *vs = virgl_screen(screen);
alloc_size = res->metadata.total_size;
res->hw_res = vs->vws->resource_create(vs->vws, templ->target,
+ map_front_private,
templ->format, vbind,
templ->width0,
templ->height0,
}
+static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *templ)
+{
+ return virgl_resource_create_front(screen, templ, NULL);
+}
+
static struct pipe_resource *virgl_resource_from_handle(struct pipe_screen *screen,
const struct pipe_resource *templ,
struct winsys_handle *whandle,
void virgl_init_screen_resource_functions(struct pipe_screen *screen)
{
+ screen->resource_create_front = virgl_resource_create_front;
screen->resource_create = virgl_resource_create;
screen->resource_from_handle = virgl_resource_from_handle;
screen->resource_get_handle = virgl_resource_get_handle;
staging->hw_res = vws->resource_create(vws,
PIPE_BUFFER,
+ NULL,
PIPE_FORMAT_R8_UNORM,
VIRGL_BIND_STAGING,
size, /* width */
uint32_t buf_offset, uint32_t level);
struct virgl_hw_res *(*resource_create)(struct virgl_winsys *vws,
- enum pipe_texture_target target,
- uint32_t format, uint32_t bind,
- uint32_t width, uint32_t height,
- uint32_t depth, uint32_t array_size,
- uint32_t last_level, uint32_t nr_samples,
- uint32_t flags, uint32_t size);
+ enum pipe_texture_target target,
+ const void *map_front_private,
+ uint32_t format, uint32_t bind,
+ uint32_t width, uint32_t height,
+ uint32_t depth, uint32_t array_size,
+ uint32_t last_level, uint32_t nr_samples,
+ uint32_t flags, uint32_t size);
void (*resource_reference)(struct virgl_winsys *qws,
struct virgl_hw_res **dres,
static struct virgl_hw_res *
virgl_drm_winsys_resource_cache_create(struct virgl_winsys *qws,
enum pipe_texture_target target,
+ const void *map_front_private,
uint32_t format,
uint32_t bind,
uint32_t width,
static struct virgl_hw_res *
virgl_vtest_winsys_resource_create(struct virgl_winsys *vws,
enum pipe_texture_target target,
+ const void *map_front_private,
uint32_t format,
uint32_t bind,
uint32_t width,
if (bind & (VIRGL_BIND_DISPLAY_TARGET | VIRGL_BIND_SCANOUT)) {
res->dt = vtws->sws->displaytarget_create(vtws->sws, bind, format,
- width, height, 64, NULL,
+ width, height, 64, map_front_private,
&res->stride);
} else if (vtws->protocol_version < 2) {
if (vtws->protocol_version >= 2) {
if (res->size == 0) {
res->ptr = NULL;
+ res->res_handle = handle;
goto out;
}
close(fd);
}
+ res->res_handle = handle;
+ if (map_front_private && res->ptr && res->dt) {
+ void *dt_map = vtws->sws->displaytarget_map(vtws->sws, res->dt, PIPE_MAP_READ_WRITE);
+ uint32_t shm_stride = util_format_get_stride(res->format, res->width);
+ util_copy_rect(res->ptr, res->format, shm_stride, 0, 0,
+ res->width, res->height, dt_map, res->stride, 0, 0);
+
+ struct pipe_box box;
+ u_box_2d(0, 0, res->width, res->height, &box);
+ virgl_vtest_transfer_put(vws, res, &box, res->stride, 0, 0, 0);
+ }
+
out:
virgl_resource_cache_entry_init(&res->cache_entry, params);
- res->res_handle = handle++;
+ handle++;
pipe_reference_init(&res->reference, 1);
p_atomic_set(&res->num_cs_references, 0);
return res;
static struct virgl_hw_res *
virgl_vtest_winsys_resource_cache_create(struct virgl_winsys *vws,
enum pipe_texture_target target,
+ const void *map_front_private,
uint32_t format,
uint32_t bind,
uint32_t width,
mtx_unlock(&vtws->mutex);
alloc:
- res = virgl_vtest_winsys_resource_create(vws, target, format, bind,
- width, height, depth, array_size,
- last_level, nr_samples, size);
+ res = virgl_vtest_winsys_resource_create(vws, target, map_front_private,
+ format, bind, width, height, depth,
+ array_size, last_level, nr_samples,
+ size);
return res;
}
*/
res = virgl_vtest_winsys_resource_create(vws,
PIPE_BUFFER,
+ NULL,
PIPE_FORMAT_R8_UNORM,
VIRGL_BIND_CUSTOM,
8, 1, 1, 0, 0, 0, 8);