From 68eac1a1e7ac931576a8b59dd159a7961189ca48 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Thu, 7 Sep 2017 20:18:06 +1000 Subject: vo_gpu: d3d11: initial implementation This is a new RA/vo_gpu backend that uses Direct3D 11. The GLSL generated by vo_gpu is cross-compiled to HLSL with SPIRV-Cross. What works: - All of mpv's internal shaders should work, including compute shaders. - Some external shaders have been tested and work, including RAVU and adaptive-sharpen. - Non-dumb mode works, even on very old hardware. Most features work at feature level 9_3 and all features work at feature level 10_0. Some features also work at feature level 9_1 and 9_2, but without high-bit- depth FBOs, it's not very useful. (Hardware this old is probably not fast enough for advanced features anyway.) Note: This is more compatible than ANGLE, which requires 9_3 to work at all (GLES 2.0,) and 10_1 for non-dumb-mode (GLES 3.0.) - Hardware decoding with D3D11VA, including decoding of 10-bit formats without truncation to 8-bit. What doesn't work / can be improved: - PBO upload and direct rendering does not work yet. Direct rendering requires persistent-mapped PBOs because the decoder needs to be able to read data from images that have already been decoded and uploaded. Unfortunately, it seems like persistent-mapped PBOs are fundamentally incompatible with D3D11, which requires all resources to use driver- managed memory and requires memory to be unmapped (and hence pointers to be invalidated) when a resource is used in a draw or copy operation. However it might be possible to use D3D11's limited multithreading capabilities to emulate some features of PBOs, like asynchronous texture uploading. - The blit() and clear() operations don't have equivalents in the D3D11 API that handle all cases, so in most cases, they have to be emulated with a shader. This is currently done inside ra_d3d11, but ideally it would be done in generic code, so it can take advantage of mpv's shader generation utilities. - SPIRV-Cross is used through a NIH C-compatible wrapper library, since it does not expose a C interface itself. The library is available here: https://github.com/rossy/crossc - The D3D11 context could be made to support more modern DXGI features in future. For example, it should be possible to add support for high-bit-depth and HDR output with DXGI 1.5/1.6. --- wscript | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'wscript') diff --git a/wscript b/wscript index ad17012bec..50cbccf2ce 100644 --- a/wscript +++ b/wscript @@ -753,6 +753,19 @@ video_output_features = [ 'desc': 'Direct3D support', 'deps': 'win32-desktop && gpl', 'func': check_cc(header_name='d3d9.h'), + }, { + 'name': '--shaderc', + 'desc': 'libshaderc SPIR-V compiler', + 'func': check_cc(header_name='shaderc/shaderc.h', lib='shaderc_shared'), + }, { + 'name': '--crossc', + 'desc': 'libcrossc SPIR-V translator', + 'func': check_pkg_config('crossc'), + }, { + 'name': '--d3d11', + 'desc': 'Direct3D 11 video output', + 'deps': 'win32-desktop && shaderc && crossc', + 'func': check_cc(header_name=['d3d11_1.h', 'dxgi1_2.h']), }, { # We need MMAL/bcm_host/dispmanx APIs. Also, most RPI distros require # every project to hardcode the paths to the include directories. Also, @@ -806,10 +819,6 @@ video_output_features = [ 'name': '--vulkan', 'desc': 'Vulkan context support', 'func': check_pkg_config('vulkan'), - }, { - 'name': '--shaderc', - 'desc': 'libshaderc SPIR-V compiler', - 'func': check_cc(header_name='shaderc/shaderc.h', lib='shaderc_shared'), }, { 'name': 'egl-helpers', 'desc': 'EGL helper functions', -- cgit v1.2.3