Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ui: add optional d3d texture pointer to scanout texture
The following patch will get the underlying D3D11 Texture2D from the
virgl renderer scanout. Pass it along to the texture scanout callbacks
as a priliminary step, to simplify review.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230606115658.677673-20-marcandre.lureau@redhat.com>
  • Loading branch information
elmarco committed Jun 27, 2023
1 parent 06c63a3 commit bf41ab6
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 21 deletions.
4 changes: 3 additions & 1 deletion hw/display/virtio-gpu-virgl.c
Expand Up @@ -154,6 +154,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
{
struct virtio_gpu_set_scanout ss;
struct virgl_renderer_resource_info info;
void *d3d_tex2d = NULL;
int ret;

VIRTIO_GPU_FILL_CMD(ss);
Expand Down Expand Up @@ -186,7 +187,8 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
g->parent_obj.scanout[ss.scanout_id].con, info.tex_id,
info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP,
info.width, info.height,
ss.r.x, ss.r.y, ss.r.width, ss.r.height);
ss.r.x, ss.r.y, ss.r.width, ss.r.height,
d3d_tex2d);
} else {
dpy_gfx_replace_surface(
g->parent_obj.scanout[ss.scanout_id].con, NULL);
Expand Down
7 changes: 5 additions & 2 deletions include/ui/console.h
Expand Up @@ -132,6 +132,7 @@ typedef struct ScanoutTexture {
uint32_t y;
uint32_t width;
uint32_t height;
void *d3d_tex2d;
} ScanoutTexture;

typedef struct DisplaySurface {
Expand Down Expand Up @@ -270,7 +271,8 @@ typedef struct DisplayChangeListenerOps {
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h);
uint32_t w, uint32_t h,
void *d3d_tex2d);
/* optional (default to true if has dpy_gl_scanout_dmabuf) */
bool (*dpy_has_dmabuf)(DisplayChangeListener *dcl);
/* optional */
Expand Down Expand Up @@ -378,7 +380,8 @@ void dpy_gl_scanout_disable(QemuConsole *con);
void dpy_gl_scanout_texture(QemuConsole *con,
uint32_t backing_id, bool backing_y_0_top,
uint32_t backing_width, uint32_t backing_height,
uint32_t x, uint32_t y, uint32_t w, uint32_t h);
uint32_t x, uint32_t y, uint32_t w, uint32_t h,
void *d3d_tex2d);
void dpy_gl_scanout_dmabuf(QemuConsole *con,
QemuDmaBuf *dmabuf);
void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
Expand Down
6 changes: 4 additions & 2 deletions include/ui/gtk.h
Expand Up @@ -175,7 +175,8 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h);
uint32_t w, uint32_t h,
void *d3d_tex2d);
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf);
void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
Expand Down Expand Up @@ -211,7 +212,8 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h);
uint32_t w, uint32_t h,
void *d3d_tex2d);
void gd_gl_area_scanout_disable(DisplayChangeListener *dcl);
void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
uint32_t x, uint32_t y, uint32_t w, uint32_t h);
Expand Down
3 changes: 2 additions & 1 deletion include/ui/sdl2.h
Expand Up @@ -90,7 +90,8 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h);
uint32_t w, uint32_t h,
void *d3d_tex2d);
void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
uint32_t x, uint32_t y, uint32_t w, uint32_t h);

Expand Down
11 changes: 7 additions & 4 deletions ui/console.c
Expand Up @@ -1223,7 +1223,8 @@ static void displaychangelistener_display_console(DisplayChangeListener *dcl,
con->scanout.texture.x,
con->scanout.texture.y,
con->scanout.texture.width,
con->scanout.texture.height);
con->scanout.texture.height,
con->scanout.texture.d3d_tex2d);
}
}

Expand Down Expand Up @@ -2115,15 +2116,16 @@ void dpy_gl_scanout_texture(QemuConsole *con,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t width, uint32_t height)
uint32_t width, uint32_t height,
void *d3d_tex2d)
{
DisplayState *s = con->ds;
DisplayChangeListener *dcl;

con->scanout.kind = SCANOUT_TEXTURE;
con->scanout.texture = (ScanoutTexture) {
backing_id, backing_y_0_top, backing_width, backing_height,
x, y, width, height
x, y, width, height, d3d_tex2d,
};
QLIST_FOREACH(dcl, &s->listeners, next) {
if (con != (dcl->con ? dcl->con : active_console)) {
Expand All @@ -2133,7 +2135,8 @@ void dpy_gl_scanout_texture(QemuConsole *con,
dcl->ops->dpy_gl_scanout_texture(dcl, backing_id,
backing_y_0_top,
backing_width, backing_height,
x, y, width, height);
x, y, width, height,
d3d_tex2d);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion ui/dbus-console.c
Expand Up @@ -98,7 +98,8 @@ dbus_gl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
DBusDisplayConsole *ddc = container_of(dcl, DBusDisplayConsole, dcl);

Expand Down
5 changes: 3 additions & 2 deletions ui/dbus-listener.c
Expand Up @@ -212,7 +212,8 @@ static void dbus_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
trace_dbus_scanout_texture(tex_id, backing_y_0_top,
backing_width, backing_height, x, y, w, h);
Expand Down Expand Up @@ -434,7 +435,7 @@ static void dbus_gl_gfx_switch(DisplayChangeListener *dcl,

/* TODO: lazy send dmabuf (there are unnecessary sent otherwise) */
dbus_scanout_texture(&ddl->dcl, ddl->ds->texture, false,
width, height, 0, 0, width, height);
width, height, 0, 0, width, height, NULL);
}
}
#endif
Expand Down
5 changes: 3 additions & 2 deletions ui/egl-headless.c
Expand Up @@ -61,7 +61,8 @@ static void egl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);

Expand Down Expand Up @@ -91,7 +92,7 @@ static void egl_scanout_dmabuf(DisplayChangeListener *dcl,

egl_scanout_texture(dcl, dmabuf->texture,
false, dmabuf->width, dmabuf->height,
0, 0, dmabuf->width, dmabuf->height);
0, 0, dmabuf->width, dmabuf->height, NULL);
}

static void egl_cursor_dmabuf(DisplayChangeListener *dcl,
Expand Down
5 changes: 3 additions & 2 deletions ui/gtk-egl.c
Expand Up @@ -224,7 +224,8 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_id, bool backing_y_0_top,
uint32_t backing_width, uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);

Expand Down Expand Up @@ -259,7 +260,7 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
gd_egl_scanout_texture(dcl, dmabuf->texture,
dmabuf->y0_top, dmabuf->width, dmabuf->height,
dmabuf->x, dmabuf->y, dmabuf->scanout_width,
dmabuf->scanout_height);
dmabuf->scanout_height, NULL);

if (dmabuf->allow_fences) {
vc->gfx.guest_fb.dmabuf = dmabuf;
Expand Down
5 changes: 3 additions & 2 deletions ui/gtk-gl-area.c
Expand Up @@ -244,7 +244,8 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);

Expand Down Expand Up @@ -300,7 +301,7 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl,
gd_gl_area_scanout_texture(dcl, dmabuf->texture,
dmabuf->y0_top, dmabuf->width, dmabuf->height,
dmabuf->x, dmabuf->y, dmabuf->scanout_width,
dmabuf->scanout_height);
dmabuf->scanout_height, NULL);

if (dmabuf->allow_fences) {
vc->gfx.guest_fb.dmabuf = dmabuf;
Expand Down
3 changes: 2 additions & 1 deletion ui/sdl2-gl.c
Expand Up @@ -205,7 +205,8 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);

Expand Down
3 changes: 2 additions & 1 deletion ui/spice-display.c
Expand Up @@ -935,7 +935,8 @@ static void qemu_spice_gl_scanout_texture(DisplayChangeListener *dcl,
uint32_t backing_width,
uint32_t backing_height,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
uint32_t w, uint32_t h,
void *d3d_tex2d)
{
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
EGLint stride = 0, fourcc = 0;
Expand Down

0 comments on commit bf41ab6

Please sign in to comment.