1d3d11_sources = [ 2 'gstd3d11bufferpool.cpp', 3 'gstd3d11device.cpp', 4 'gstd3d11format.cpp', 5 'gstd3d11memory.cpp', 6 'gstd3d11utils.cpp', 7] 8 9dxgi_headers = [ 10 ['dxgi1_6.h', 6], 11 ['dxgi1_5.h', 5], 12 ['dxgi1_4.h', 4], 13 ['dxgi1_3.h', 3], 14 ['dxgi1_2.h', 2], 15 ['dxgi.h', 1] 16] 17 18d3d11_headers = [ 19 ['d3d11_4.h', 4], 20 ['d3d11_3.h', 3], 21 ['d3d11_2.h', 2], 22 ['d3d11_1.h', 1], 23 ['d3d11.h', 0] 24] 25 26gstd3d11_dep = dependency('', required : false) 27 28d3d11_option = get_option('d3d11') 29if host_system != 'windows' or d3d11_option.disabled() 30 subdir_done() 31endif 32 33have_d3d11 = false 34extra_c_args = [ 35 '-DCOBJMACROS', 36] 37extra_comm_args = [ 38 '-DGST_USE_UNSTABLE_API', 39 '-DBUILDING_GST_D3D11', 40 '-DG_LOG_DOMAIN="GStreamer-D3D11"', 41] 42 43have_dxgi_header = false 44have_d3d11_header = false 45have_d3d11sdk_h = false 46have_dxgidebug_h = false 47winapi_desktop = false 48winapi_app = false 49d3d11_conf = configuration_data() 50d3d11_conf_options = [ 51 'GST_D3D11_DXGI_HEADER_VERSION', 52 'GST_D3D11_HEADER_VERSION', 53 'GST_D3D11_WINAPI_ONLY_APP', 54] 55 56foreach option : d3d11_conf_options 57 d3d11_conf.set10(option, false) 58endforeach 59 60d3d11_lib = cc.find_library('d3d11', required : d3d11_option) 61dxgi_lib = cc.find_library('dxgi', required : d3d11_option) 62d3dcompiler_lib = cc.find_library('d3dcompiler', required: d3d11_option) 63runtimeobject_lib = cc.find_library('runtimeobject', required : false) 64 65foreach dxgi_h: dxgi_headers 66 if not have_dxgi_header and cc.has_header(dxgi_h[0]) 67 d3d11_conf.set('GST_D3D11_DXGI_HEADER_VERSION', dxgi_h[1]) 68 have_dxgi_header = true 69 endif 70endforeach 71 72foreach d3d11_h: d3d11_headers 73 if not have_d3d11_header and cc.has_header(d3d11_h[0]) 74 d3d11_conf.set('GST_D3D11_HEADER_VERSION', d3d11_h[1]) 75 have_d3d11_header = true 76 endif 77endforeach 78 79have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and have_d3d11_header and have_dxgi_header 80if not have_d3d11 81 if d3d11_option.enabled() 82 error('The d3d11 was enabled explicitly, but required dependencies were not found.') 83 endif 84 subdir_done() 85endif 86 87d3d11_winapi_desktop = cxx.compiles('''#include <winapifamily.h> 88 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 89 #error "not win32" 90 #endif''', 91 dependencies: [d3d11_lib, dxgi_lib], 92 name: 'building for Win32') 93 94if runtimeobject_lib.found() and d3dcompiler_lib.found() 95 d3d11_winapi_app = cxx.compiles('''#include <winapifamily.h> 96 #include <windows.applicationmodel.core.h> 97 #include <wrl.h> 98 #include <wrl/wrappers/corewrappers.h> 99 #include <d3d11.h> 100 #include <dxgi1_2.h> 101 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 102 #error "not winrt" 103 #endif 104 #if (WINVER < 0x0A00) 105 #error "Windows 10 API is not guaranteed" 106 #endif''', 107 dependencies: [d3d11_lib, dxgi_lib, runtimeobject_lib], 108 name: 'building for WinRT') 109endif 110 111if not d3d11_winapi_desktop and not d3d11_winapi_app 112 error('Neither Desktop partition nor App partition') 113endif 114 115d3d11_winapi_only_app = d3d11_winapi_app and not d3d11_winapi_desktop 116d3d11_conf.set10('GST_D3D11_WINAPI_ONLY_APP', d3d11_winapi_only_app) 117d3d11_conf.set10('GST_D3D11_WINAPI_APP', d3d11_winapi_app) 118 119# for enabling debug layer 120# NOTE: Disable d3d11/dxgi debug layer in case of [UWP build + release CRT] 121# WACK (Windows App Certification Kit) doesn't seem to be happy with 122# the DXGIGetDebugInterface1 symbol. 123 124# FIXME: Probably DXGIGetDebugInterface1 might be used on UWP app for development 125# purpose. So, I suspect one possible reason why WACK is complaining about 126# DXGIGetDebugInterface1 is that debugging APIs couldn't be used for 127# Windows store app, but couldn't find any reference about that. 128# 129# [IDXGIDebug1] 130# https://docs.microsoft.com/en-us/windows/win32/api/dxgidebug/nn-dxgidebug-idxgidebug1 131# is saying that the IDXGIDebug1 interface is available for both desktop app and 132# UWP. And then the *DXGIGetDebugInterface1* method need to be called to obtain 133# the IDXGIDebug1 interface. 134# 135# [DXGIGetDebugInterface1] 136# https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_3/nf-dxgi1_3-dxgigetdebuginterface1 137# is mentioning that DXGIGetDebugInterface1 is desktop app only. 138# 139# PLEASE LET US KNOW A CORRECT WAY TO OBTAIN IDXGIDebug1 ON UWP, MICROSOFT 140if get_option('debug') and not (d3d11_winapi_only_app and get_option('b_vscrt') == 'md') 141 d3d11_debug_libs = [ 142 ['d3d11sdklayers.h', 'ID3D11Debug', 'ID3D11InfoQueue', 'have_d3d11sdk_h'], 143 ['dxgidebug.h', 'IDXGIDebug', 'IDXGIInfoQueue', 'have_dxgidebug_h'], 144 ] 145 146 foreach f : d3d11_debug_libs 147 header = f.get(0) 148 debug_obj = f.get(1) 149 info_obj = f.get(2) 150 compile_code = ''' 151 #include <d3d11.h> 152 #include <dxgi.h> 153 #include <@0@> 154 int main(int arc, char ** argv) { 155 @1@ *debug = NULL; 156 @2@ *info_queue = NULL; 157 return 0; 158 }'''.format(header, debug_obj, info_obj) 159 if cc.compiles(compile_code, dependencies: [d3d11_lib, dxgi_lib], name: debug_obj) 160 set_variable(f.get(3), true) 161 endif 162 endforeach 163else 164 message('Disable D3D11Debug and DXGIDebug layers') 165endif 166 167# don't need to be defined in gstd3d11config.h since it's gstd3d11device internal 168if have_d3d11sdk_h 169 extra_comm_args += ['-DHAVE_D3D11SDKLAYERS_H'] 170endif 171 172if have_dxgidebug_h 173 extra_comm_args += ['-DHAVE_DXGIDEBUG_H'] 174endif 175 176# MinGW 32bits compiler seems to be complaining about redundant-decls 177# when ComPtr is in use. Let's just disable the warning 178if cc.get_id() != 'msvc' 179 extra_args = cc.get_supported_arguments([ 180 '-Wno-redundant-decls', 181 ]) 182 183 extra_comm_args += extra_args 184endif 185 186configure_file( 187 output: 'gstd3d11config.h', 188 configuration: d3d11_conf, 189) 190 191pkg_name = 'gstreamer-d3d11-' + api_version 192gstd3d11 = library('gstd3d11-' + api_version, 193 d3d11_sources, 194 c_args : gst_plugins_bad_args + extra_c_args + extra_comm_args, 195 cpp_args : gst_plugins_bad_args + extra_comm_args, 196 include_directories : [configinc, libsinc], 197 version : libversion, 198 soversion : soversion, 199 install : true, 200 dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, d3d11_lib, dxgi_lib] 201) 202 203library_def = {'lib': gstd3d11} 204libraries += [[pkg_name, library_def]] 205 206# Still non-public api, should not install headers 207gstd3d11_dep = declare_dependency(link_with : gstd3d11, 208 include_directories : [libsinc], 209 dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, d3d11_lib, dxgi_lib]) 210