virtio-gpu-virgl: use D3D11_SHARE_TEXTURE when available
Enable D3D texture sharing when possible, and pass it to the texture display callbacks. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230606115658.677673-21-marcandre.lureau@redhat.com>
This commit is contained in:
parent
bf41ab6190
commit
c1600f84ce
@ -153,8 +153,6 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
|||||||
struct virtio_gpu_ctrl_command *cmd)
|
struct virtio_gpu_ctrl_command *cmd)
|
||||||
{
|
{
|
||||||
struct virtio_gpu_set_scanout ss;
|
struct virtio_gpu_set_scanout ss;
|
||||||
struct virgl_renderer_resource_info info;
|
|
||||||
void *d3d_tex2d = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
VIRTIO_GPU_FILL_CMD(ss);
|
VIRTIO_GPU_FILL_CMD(ss);
|
||||||
@ -169,10 +167,20 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
|||||||
}
|
}
|
||||||
g->parent_obj.enable = 1;
|
g->parent_obj.enable = 1;
|
||||||
|
|
||||||
memset(&info, 0, sizeof(info));
|
|
||||||
|
|
||||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||||
|
struct virgl_renderer_resource_info info;
|
||||||
|
void *d3d_tex2d = NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_VIRGL_D3D_INFO_EXT
|
||||||
|
struct virgl_renderer_resource_info_ext ext;
|
||||||
|
memset(&ext, 0, sizeof(ext));
|
||||||
|
ret = virgl_renderer_resource_get_info_ext(ss.resource_id, &ext);
|
||||||
|
info = ext.base;
|
||||||
|
d3d_tex2d = ext.d3d_tex2d;
|
||||||
|
#else
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||||
|
#endif
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
qemu_log_mask(LOG_GUEST_ERROR,
|
qemu_log_mask(LOG_GUEST_ERROR,
|
||||||
"%s: illegal resource specified %d\n",
|
"%s: illegal resource specified %d\n",
|
||||||
@ -617,6 +625,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
|
|||||||
int virtio_gpu_virgl_init(VirtIOGPU *g)
|
int virtio_gpu_virgl_init(VirtIOGPU *g)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
uint32_t flags = 0;
|
||||||
|
|
||||||
#if VIRGL_RENDERER_CALLBACKS_VERSION >= 4
|
#if VIRGL_RENDERER_CALLBACKS_VERSION >= 4
|
||||||
if (qemu_egl_display) {
|
if (qemu_egl_display) {
|
||||||
@ -624,8 +633,13 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
|
|||||||
virtio_gpu_3d_cbs.get_egl_display = virgl_get_egl_display;
|
virtio_gpu_3d_cbs.get_egl_display = virgl_get_egl_display;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE
|
||||||
|
if (qemu_egl_angle_d3d) {
|
||||||
|
flags |= VIRGL_RENDERER_D3D11_SHARE_TEXTURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs);
|
ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
error_report("virgl could not be initialized: %d", ret);
|
error_report("virgl could not be initialized: %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1072,6 +1072,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
|
|||||||
virgl = dependency('virglrenderer',
|
virgl = dependency('virglrenderer',
|
||||||
method: 'pkg-config',
|
method: 'pkg-config',
|
||||||
required: get_option('virglrenderer'))
|
required: get_option('virglrenderer'))
|
||||||
|
if virgl.found()
|
||||||
|
config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT',
|
||||||
|
cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d',
|
||||||
|
prefix: '#include <virglrenderer.h>',
|
||||||
|
dependencies: virgl))
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
blkio = not_found
|
blkio = not_found
|
||||||
if not get_option('blkio').auto() or have_block
|
if not get_option('blkio').auto() or have_block
|
||||||
|
Loading…
Reference in New Issue
Block a user