Mesa (main): meson: Add build option for gallium-d3d12-video feature

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 24 17:01:21 UTC 2022


Module: Mesa
Branch: main
Commit: e5ddd8ad941d224f4abf64403e0bb8762950b9a2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5ddd8ad941d224f4abf64403e0bb8762950b9a2

Author: Sil Vilerino <sivileri at microsoft.com>
Date:   Mon May 23 07:10:36 2022 -0700

meson: Add build option for gallium-d3d12-video feature

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6511
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16597>

---

 meson.build                                 | 39 +++++++++++++++++------------
 meson_options.txt                           |  6 +++++
 src/gallium/drivers/d3d12/d3d12_context.cpp |  8 ++++--
 src/gallium/drivers/d3d12/d3d12_context.h   |  3 ++-
 src/gallium/drivers/d3d12/d3d12_screen.cpp  |  4 +++
 src/gallium/drivers/d3d12/meson.build       | 31 +++++++++++++----------
 src/gallium/targets/va/meson.build          |  2 +-
 src/gallium/targets/vdpau/meson.build       |  2 +-
 8 files changed, 61 insertions(+), 34 deletions(-)

diff --git a/meson.build b/meson.build
index facb16c40b6..d6b49c8dd02 100644
--- a/meson.build
+++ b/meson.build
@@ -625,6 +625,25 @@ if with_gallium_kmsro and (with_platform_x11 and not with_dri3)
   error('kmsro requires dri3 for X11 support')
 endif
 
+dep_dxheaders = null_dep
+if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk
+  dep_dxheaders = dependency('directx-headers', required : false)
+  if not dep_dxheaders.found()
+    dep_dxheaders = dependency('DirectX-Headers',
+      version : '>= 1.602.0',
+      fallback : ['DirectX-Headers', 'dep_dxheaders'],
+      required : with_gallium_d3d12 or with_microsoft_vk
+    )
+  endif
+endif
+
+_with_gallium_d3d12_video = get_option('gallium-d3d12-video')
+with_gallium_d3d12_video = false
+if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled()
+  with_gallium_d3d12_video = true
+  pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO'
+endif
+
 _vdpau = get_option('gallium-vdpau')
 if _vdpau == 'true'
   _vdpau = 'enabled'
@@ -646,9 +665,9 @@ elif not with_platform_x11
     _vdpau = 'disabled'
   endif
 elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
-          with_gallium_nouveau or with_gallium_d3d12)
+          with_gallium_nouveau or with_gallium_d3d12_video)
   if _vdpau == 'enabled'
-    error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12.')
+    error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video).')
   else
     _vdpau = 'disabled'
   endif
@@ -671,18 +690,6 @@ if vdpau_drivers_path == ''
   vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
 endif
 
-dep_dxheaders = null_dep
-if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk
-  dep_dxheaders = dependency('directx-headers', required : false)
-  if not dep_dxheaders.found()
-    dep_dxheaders = dependency('DirectX-Headers',
-      version : '>= 1.602.0',
-      fallback : ['DirectX-Headers', 'dep_dxheaders'],
-      required : with_gallium_d3d12 or with_microsoft_vk
-    )
-  endif
-endif
-
 if with_vulkan_overlay_layer or with_aco_tests or with_amd_vk
   prog_glslang = find_program('glslangValidator')
   if run_command(prog_glslang, [ '--quiet', '--version' ], check : false).returncode() == 0
@@ -827,9 +834,9 @@ if not system_has_kms_drm
   else
     _va = 'disabled'
   endif
-elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau or with_gallium_d3d12)
+elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau or with_gallium_d3d12_video)
   if _va == 'enabled'
-    error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12.')
+    error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video).')
   else
     _va = 'disabled'
   endif
diff --git a/meson_options.txt b/meson_options.txt
index 83b5ea941be..b223bbc798d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -536,3 +536,9 @@ option(
   ],
   description : 'List of patent encumbered codecs to build support for. Distros might want to consult their legal department before enabling these. This is used for all video APIs (vaapi, vdpau, vulkan). Non-patent encumbered codecs will be enabled by default.'
 )
+option(
+  'gallium-d3d12-video',
+  type : 'feature',
+  value : 'auto',
+  description : 'build gallium d3d12 with video support.',
+)
diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index 75780c64548..6911f816e4e 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -34,10 +34,11 @@
 #include "d3d12_root_signature.h"
 #include "d3d12_screen.h"
 #include "d3d12_surface.h"
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
 #include "d3d12_video_dec.h"
 #include "d3d12_video_enc.h"
 #include "d3d12_video_buffer.h"
-
+#endif
 #include "util/u_atomic.h"
 #include "util/u_blitter.h"
 #include "util/u_dual_blend.h"
@@ -2378,6 +2379,7 @@ d3d12_get_reset_status(struct pipe_context *pctx)
    }
 }
 
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
 struct pipe_video_codec*
 d3d12_video_create_codec(struct pipe_context *context,
                          const struct pipe_video_codec *templat)
@@ -2391,6 +2393,7 @@ d3d12_video_create_codec(struct pipe_context *context,
         return nullptr;
     }
 }
+#endif
 
 struct pipe_context *
 d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
@@ -2506,10 +2509,11 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    d3d12_context_query_init(&ctx->base);
    d3d12_context_blit_init(&ctx->base);
 
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
    // Add d3d12 video functions entrypoints
    ctx->base.create_video_codec = d3d12_video_create_codec;
    ctx->base.create_video_buffer = d3d12_video_buffer_create;
-
+#endif
    slab_create_child(&ctx->transfer_pool, &d3d12_screen(pscreen)->transfer_pool);
    slab_create_child(&ctx->transfer_pool_unsync, &d3d12_screen(pscreen)->transfer_pool);
 
diff --git a/src/gallium/drivers/d3d12/d3d12_context.h b/src/gallium/drivers/d3d12/d3d12_context.h
index 42d8b0c51b8..c7501b5b07a 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.h
+++ b/src/gallium/drivers/d3d12/d3d12_context.h
@@ -355,8 +355,9 @@ d3d12_need_zero_one_depth_range(struct d3d12_context *ctx);
 void
 d3d12_init_sampler_view_descriptor(struct d3d12_sampler_view *sampler_view);
 
-
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
 struct pipe_video_codec* d3d12_video_create_codec( struct pipe_context *context,
                                                 const struct pipe_video_codec *t);
+#endif
 
 #endif
diff --git a/src/gallium/drivers/d3d12/d3d12_screen.cpp b/src/gallium/drivers/d3d12/d3d12_screen.cpp
index 04d1ebc388b..2b7dd3aae71 100644
--- a/src/gallium/drivers/d3d12/d3d12_screen.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_screen.cpp
@@ -28,7 +28,9 @@
 #include "d3d12_context.h"
 #include "d3d12_debug.h"
 #include "d3d12_fence.h"
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
 #include "d3d12_video_screen.h"
+#endif
 #include "d3d12_format.h"
 #include "d3d12_residency.h"
 #include "d3d12_resource.h"
@@ -1240,7 +1242,9 @@ d3d12_init_screen(struct d3d12_screen *screen, IUnknown *adapter)
 
    d3d12_screen_fence_init(&screen->base);
    d3d12_screen_resource_init(&screen->base);
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
    d3d12_screen_video_init(&screen->base);
+#endif
    slab_create_parent(&screen->transfer_pool, sizeof(struct d3d12_transfer), 16);
 
    struct pb_desc desc;
diff --git a/src/gallium/drivers/d3d12/meson.build b/src/gallium/drivers/d3d12/meson.build
index a67d8410558..72f8ae2cd31 100644
--- a/src/gallium/drivers/d3d12/meson.build
+++ b/src/gallium/drivers/d3d12/meson.build
@@ -47,21 +47,26 @@ files_libd3d12 = files(
   'd3d12_surface.cpp',
   'd3d12_tcs_variant.cpp',
   'D3D12ResourceState.cpp',
-  'd3d12_video_dec.cpp',
-  'd3d12_video_dec_references_mgr.cpp',
-  'd3d12_video_dec_h264.cpp',
-  'd3d12_video_buffer.cpp',
-  'd3d12_video_enc.cpp',
-  'd3d12_video_enc_h264.cpp',
-  'd3d12_video_encoder_references_manager_h264.cpp',
-  'd3d12_video_encoder_nalu_writer_h264.cpp',
-  'd3d12_video_encoder_bitstream_builder_h264.cpp',
-  'd3d12_video_encoder_bitstream.cpp',
-  'd3d12_video_texture_array_dpb_manager.cpp',
-  'd3d12_video_array_of_textures_dpb_manager.cpp',
-  'd3d12_video_screen.cpp',
 )
 
+if with_gallium_d3d12_video
+  files_libd3d12 += [
+    'd3d12_video_dec.cpp',
+    'd3d12_video_dec_references_mgr.cpp',
+    'd3d12_video_dec_h264.cpp',
+    'd3d12_video_buffer.cpp',
+    'd3d12_video_enc.cpp',
+    'd3d12_video_enc_h264.cpp',
+    'd3d12_video_encoder_references_manager_h264.cpp',
+    'd3d12_video_encoder_nalu_writer_h264.cpp',
+    'd3d12_video_encoder_bitstream_builder_h264.cpp',
+    'd3d12_video_encoder_bitstream.cpp',
+    'd3d12_video_texture_array_dpb_manager.cpp',
+    'd3d12_video_array_of_textures_dpb_manager.cpp',
+    'd3d12_video_screen.cpp',
+  ]
+endif
+
 if host_machine.system() == 'windows'
   files_libd3d12 += files('d3d12_dxgi_screen.cpp')
 endif
diff --git a/src/gallium/targets/va/meson.build b/src/gallium/targets/va/meson.build
index 249bafff6ab..10f94951ecc 100644
--- a/src/gallium/targets/va/meson.build
+++ b/src/gallium/targets/va/meson.build
@@ -64,7 +64,7 @@ libva_gallium = shared_library(
 foreach d : [[with_gallium_r600, 'r600'],
              [with_gallium_radeonsi, 'radeonsi'],
              [with_gallium_nouveau, 'nouveau'],
-             [with_gallium_d3d12, 'd3d12']]
+             [with_gallium_d3d12_video, 'd3d12']]
   if d[0]
     va_drivers += '@0 at _drv_video.so'.format(d[1])
   endif
diff --git a/src/gallium/targets/vdpau/meson.build b/src/gallium/targets/vdpau/meson.build
index 5fe457dfe81..1e793ebf9c9 100644
--- a/src/gallium/targets/vdpau/meson.build
+++ b/src/gallium/targets/vdpau/meson.build
@@ -69,7 +69,7 @@ foreach d : [[with_gallium_r300, 'r300'],
              [with_gallium_r600, 'r600'],
              [with_gallium_radeonsi, 'radeonsi'],
              [with_gallium_nouveau, 'nouveau'],
-             [with_gallium_d3d12, 'd3d12']]
+             [with_gallium_d3d12_video, 'd3d12']]
   if d[0]
     vdpau_drivers += 'libvdpau_ at 0@.so. at 1@. at 2@.0'.format(d[1], VDPAU_MAJOR, VDPAU_MINOR)
   endif



More information about the mesa-commit mailing list