diff --git a/src/gallium/auxiliary/vl/vl_winsys.h b/src/gallium/auxiliary/vl/vl_winsys.h index a3945b67e2c..4590bbb9e2c 100644 --- a/src/gallium/auxiliary/vl/vl_winsys.h +++ b/src/gallium/auxiliary/vl/vl_winsys.h @@ -29,6 +29,10 @@ * Target makefiles directly refer to vl_winsys_dri.c to avoid DRI dependency */ +#ifdef __cplusplus +extern "C" { +#endif + #ifndef vl_winsys_h #define vl_winsys_h @@ -37,6 +41,7 @@ #endif #ifdef _WIN32 #include +#include #endif #include "pipe/p_defines.h" #include "util/format/u_formats.h" @@ -97,6 +102,7 @@ vl_dri3_screen_create(void *display, int screen) { return NULL; }; #ifdef _WIN32 struct vl_screen *vl_win32_screen_create(LUID *adapter); +struct vl_screen *vl_win32_screen_create_from_d3d12_device(IUnknown* d3d12_device); #else /* Always enable the DRM vl winsys */ struct vl_screen * @@ -116,3 +122,6 @@ vl_xlib_swrast_screen_create(void *display, int screen) { return NULL; } #endif #endif +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/gallium/auxiliary/vl/vl_winsys_win32.c b/src/gallium/auxiliary/vl/vl_winsys_win32.c index 6f12d0bb55c..b4f7aefe1a4 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_win32.c +++ b/src/gallium/auxiliary/vl/vl_winsys_win32.c @@ -28,6 +28,7 @@ #include "gallium/winsys/sw/gdi/gdi_sw_winsys.h" #include "gallium/drivers/d3d12/d3d12_public.h" +#include struct vl_win32_screen { @@ -80,3 +81,31 @@ release_pipe: vl_win32_screen_destroy(&vscreen->base); return NULL; } + +struct vl_screen * +vl_win32_screen_create_from_d3d12_device(IUnknown* d3d12_device) +{ + struct vl_win32_screen *vscreen = CALLOC_STRUCT(vl_win32_screen); + if (!vscreen) + return NULL; + + struct sw_winsys* winsys = gdi_create_sw_winsys(); + if (!winsys) + goto release_pipe; + + vscreen->base.pscreen = d3d12_create_dxcore_screen_from_d3d12_device(winsys, d3d12_device, &vscreen->adapter_luid); + + if (!vscreen->base.pscreen) + goto release_pipe; + + vscreen->base.destroy = vl_win32_screen_destroy; + vscreen->base.get_private = NULL; + vscreen->base.texture_from_drawable = NULL; + vscreen->base.get_dirty_area = NULL; + + return &vscreen->base; + +release_pipe: + vl_win32_screen_destroy(&vscreen->base); + return NULL; +}