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