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