virgl: implemement resource_get_param() for modifier query
Without such, Xwayland gets back the implicit modifier token (INVALID) when calling gbm_bo_get_modifier() for a dmabuf shared by the WSI layer. Then mistakenly sends INVALID upon wl_buffer creation, rather than the explicit modifier sent by WSI. The logic of Xwayland's Glamor gbm backend is a bit circuitous, since the modifier is sent by WSI alongside the dmabuf fd. Rather than use that modifier directly when creating wl_buffer (via zwp_linux_dmabuf_v1), Glamor first imports the dmabuf+modifier with gbm_bo_import(), then uses the result of later gbm_bo_get_modifier(). Signed-off-by: Ryan Neph <ryanneph@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26240>
This commit is contained in:
@@ -809,6 +809,28 @@ static struct pipe_resource *virgl_resource_from_handle(struct pipe_screen *scre
|
||||
return &res->b;
|
||||
}
|
||||
|
||||
static bool
|
||||
virgl_resource_get_param(struct pipe_screen *screen,
|
||||
struct pipe_context *context,
|
||||
struct pipe_resource *resource,
|
||||
unsigned plane,
|
||||
unsigned layer,
|
||||
unsigned level,
|
||||
enum pipe_resource_param param,
|
||||
unsigned handle_usage,
|
||||
uint64_t *value)
|
||||
{
|
||||
struct virgl_resource *res = virgl_resource(resource);
|
||||
|
||||
switch(param) {
|
||||
case PIPE_RESOURCE_PARAM_MODIFIER:
|
||||
*value = res->metadata.modifier;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void virgl_init_screen_resource_functions(struct pipe_screen *screen)
|
||||
{
|
||||
screen->resource_create_front = virgl_resource_create_front;
|
||||
@@ -816,6 +838,7 @@ void virgl_init_screen_resource_functions(struct pipe_screen *screen)
|
||||
screen->resource_from_handle = virgl_resource_from_handle;
|
||||
screen->resource_get_handle = virgl_resource_get_handle;
|
||||
screen->resource_destroy = virgl_resource_destroy;
|
||||
screen->resource_get_param = virgl_resource_get_param;
|
||||
}
|
||||
|
||||
static void virgl_buffer_subdata(struct pipe_context *pipe,
|
||||
|
Reference in New Issue
Block a user