Mesa (main): d3d12: Move shared code that include d3d12 headers into d3d12_common.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 3 17:14:15 UTC 2022


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

Author: Yonggang Luo <luoyonggang at gmail.com>
Date:   Sat Apr 30 03:10:47 2022 +0800

d3d12: Move shared code that include d3d12 headers into d3d12_common.h

Signed-off-by: Yonggang Luo <luoyonggang at gmail.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16767>

---

 src/gallium/drivers/d3d12/D3D12ResourceState.h     |  7 ++---
 src/gallium/drivers/d3d12/d3d12_batch.h            |  7 +----
 src/gallium/drivers/d3d12/d3d12_bufmgr.cpp         |  1 -
 src/gallium/drivers/d3d12/d3d12_bufmgr.h           |  6 +---
 src/gallium/drivers/d3d12/d3d12_common.h           | 36 ++++++++++++++++++++++
 src/gallium/drivers/d3d12/d3d12_compiler.cpp       |  1 -
 src/gallium/drivers/d3d12/d3d12_context.h          |  2 --
 .../drivers/d3d12/d3d12_descriptor_pool.cpp        |  1 -
 src/gallium/drivers/d3d12/d3d12_descriptor_pool.h  |  7 +----
 src/gallium/drivers/d3d12/d3d12_fence.h            |  6 +---
 src/gallium/drivers/d3d12/d3d12_pipeline_state.h   |  7 +----
 src/gallium/drivers/d3d12/d3d12_resource.cpp       |  1 -
 src/gallium/drivers/d3d12/d3d12_resource.h         |  2 +-
 src/gallium/drivers/d3d12/d3d12_screen.h           |  7 +----
 src/gallium/drivers/d3d12/d3d12_surface.h          |  2 --
 .../d3d12_video_array_of_textures_dpb_manager.cpp  |  6 +---
 src/gallium/drivers/d3d12/d3d12_video_enc.cpp      |  7 +----
 src/gallium/drivers/d3d12/d3d12_video_screen.h     |  6 +---
 .../d3d12_video_texture_array_dpb_manager.cpp      |  7 +----
 19 files changed, 49 insertions(+), 70 deletions(-)

diff --git a/src/gallium/drivers/d3d12/D3D12ResourceState.h b/src/gallium/drivers/d3d12/D3D12ResourceState.h
index e4d84f049f1..6312cd1ff04 100644
--- a/src/gallium/drivers/d3d12/D3D12ResourceState.h
+++ b/src/gallium/drivers/d3d12/D3D12ResourceState.h
@@ -24,16 +24,13 @@
 #ifndef D3D12_RESOURCE_STATE_H
 #define D3D12_RESOURCE_STATE_H
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
 #include <vector>
 #include <assert.h>
-#include <directx/d3d12.h>
 
 #include "util/list.h"
 
+#include "d3d12_common.h"
+
 #if defined(__GNUC__)
 #pragma GCC diagnostic ignored "-Winvalid-offsetof"
 #endif
diff --git a/src/gallium/drivers/d3d12/d3d12_batch.h b/src/gallium/drivers/d3d12/d3d12_batch.h
index 65ce7f35315..191fa69978b 100644
--- a/src/gallium/drivers/d3d12/d3d12_batch.h
+++ b/src/gallium/drivers/d3d12/d3d12_batch.h
@@ -28,12 +28,7 @@
 #include "util/hash_table.h"
 #include <stdint.h>
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 struct d3d12_bo;
 struct d3d12_descriptor_heap;
diff --git a/src/gallium/drivers/d3d12/d3d12_bufmgr.cpp b/src/gallium/drivers/d3d12/d3d12_bufmgr.cpp
index d5ea1951c76..a2c3994fc11 100644
--- a/src/gallium/drivers/d3d12/d3d12_bufmgr.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_bufmgr.cpp
@@ -33,7 +33,6 @@
 #include "util/format/u_format.h"
 #include "util/u_memory.h"
 
-#include <directx/d3d12.h>
 #include <dxguids/dxguids.h>
 
 struct d3d12_bufmgr {
diff --git a/src/gallium/drivers/d3d12/d3d12_bufmgr.h b/src/gallium/drivers/d3d12/d3d12_bufmgr.h
index 27e7031c321..d19ae82fa0b 100644
--- a/src/gallium/drivers/d3d12/d3d12_bufmgr.h
+++ b/src/gallium/drivers/d3d12/d3d12_bufmgr.h
@@ -28,11 +28,7 @@
 #include "util/u_atomic.h"
 #include "util/list.h"
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 struct d3d12_bufmgr;
 struct d3d12_screen;
diff --git a/src/gallium/drivers/d3d12/d3d12_common.h b/src/gallium/drivers/d3d12/d3d12_common.h
new file mode 100644
index 00000000000..12f6aee7c85
--- /dev/null
+++ b/src/gallium/drivers/d3d12/d3d12_common.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright © Yonggang Luo
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef D3D12_COMMON_STATE_H
+#define D3D12_COMMON_STATE_H
+
+#pragma once
+
+#ifndef _WIN32
+#include <wsl/winadapter.h>
+#endif
+
+#define D3D12_IGNORE_SDK_LAYERS
+#include <directx/d3d12.h>
+
+#endif
diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index ec968cb7f88..cef712712e3 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -44,7 +44,6 @@
 #include "util/u_simple_shaders.h"
 #include "util/u_dl.h"
 
-#include <directx/d3d12.h>
 #include <dxguids/dxguids.h>
 
 extern "C" {
diff --git a/src/gallium/drivers/d3d12/d3d12_context.h b/src/gallium/drivers/d3d12/d3d12_context.h
index c7501b5b07a..c76999191bb 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.h
+++ b/src/gallium/drivers/d3d12/d3d12_context.h
@@ -37,8 +37,6 @@
 #include "util/u_suballoc.h"
 #include "util/u_threaded_context.h"
 
-#include <directx/d3d12.h>
-
 #define D3D12_GFX_SHADER_STAGES (PIPE_SHADER_TYPES - 1)
 
 enum d3d12_dirty_flags
diff --git a/src/gallium/drivers/d3d12/d3d12_descriptor_pool.cpp b/src/gallium/drivers/d3d12/d3d12_descriptor_pool.cpp
index 1dfbf644dd4..3a7986cf372 100644
--- a/src/gallium/drivers/d3d12/d3d12_descriptor_pool.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_descriptor_pool.cpp
@@ -32,7 +32,6 @@
 #include "util/u_dynarray.h"
 #include "util/u_memory.h"
 
-#include <directx/d3d12.h>
 #include <dxguids/dxguids.h>
 
 struct d3d12_descriptor_pool {
diff --git a/src/gallium/drivers/d3d12/d3d12_descriptor_pool.h b/src/gallium/drivers/d3d12/d3d12_descriptor_pool.h
index 9339ced160b..158709d98c8 100644
--- a/src/gallium/drivers/d3d12/d3d12_descriptor_pool.h
+++ b/src/gallium/drivers/d3d12/d3d12_descriptor_pool.h
@@ -24,12 +24,7 @@
 #ifndef D3D12_DESCRIPTOR_POOL_H
 #define D3D12_DESCRIPTOR_POOL_H
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 struct d3d12_descriptor_pool;
 struct d3d12_descriptor_heap;
diff --git a/src/gallium/drivers/d3d12/d3d12_fence.h b/src/gallium/drivers/d3d12/d3d12_fence.h
index b1938b04f42..00c117f0911 100644
--- a/src/gallium/drivers/d3d12/d3d12_fence.h
+++ b/src/gallium/drivers/d3d12/d3d12_fence.h
@@ -26,11 +26,7 @@
 
 #include "util/u_inlines.h"
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 struct pipe_screen;
 struct d3d12_screen;
diff --git a/src/gallium/drivers/d3d12/d3d12_pipeline_state.h b/src/gallium/drivers/d3d12/d3d12_pipeline_state.h
index 6b14ac2742a..42d702371e7 100644
--- a/src/gallium/drivers/d3d12/d3d12_pipeline_state.h
+++ b/src/gallium/drivers/d3d12/d3d12_pipeline_state.h
@@ -26,12 +26,7 @@
 
 #include "pipe/p_state.h"
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 struct d3d12_context;
 struct d3d12_root_signature;
diff --git a/src/gallium/drivers/d3d12/d3d12_resource.cpp b/src/gallium/drivers/d3d12/d3d12_resource.cpp
index e3f247669de..545f81160d8 100644
--- a/src/gallium/drivers/d3d12/d3d12_resource.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_resource.cpp
@@ -38,7 +38,6 @@
 
 #include "frontend/sw_winsys.h"
 
-#include <directx/d3d12.h>
 #include <dxguids/dxguids.h>
 #include <memory>
 
diff --git a/src/gallium/drivers/d3d12/d3d12_resource.h b/src/gallium/drivers/d3d12/d3d12_resource.h
index 54c60fbd29a..4dee943d72e 100644
--- a/src/gallium/drivers/d3d12/d3d12_resource.h
+++ b/src/gallium/drivers/d3d12/d3d12_resource.h
@@ -30,7 +30,7 @@ struct pipe_screen;
 #include "util/u_transfer.h"
 #include "util/u_threaded_context.h"
 
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 enum d3d12_resource_binding_type {
    D3D12_RESOURCE_BINDING_TYPE_SRV,
diff --git a/src/gallium/drivers/d3d12/d3d12_screen.h b/src/gallium/drivers/d3d12/d3d12_screen.h
index cb4575986e0..73eb68f3119 100644
--- a/src/gallium/drivers/d3d12/d3d12_screen.h
+++ b/src/gallium/drivers/d3d12/d3d12_screen.h
@@ -31,12 +31,7 @@
 
 #include "nir.h"
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 struct pb_manager;
 
diff --git a/src/gallium/drivers/d3d12/d3d12_surface.h b/src/gallium/drivers/d3d12/d3d12_surface.h
index f958d32e96b..e8f26889152 100644
--- a/src/gallium/drivers/d3d12/d3d12_surface.h
+++ b/src/gallium/drivers/d3d12/d3d12_surface.h
@@ -26,8 +26,6 @@
 
 #include "pipe/p_state.h"
 
-#include <directx/d3d12.h>
-
 struct d3d12_descriptor_handle;
 struct pipe_context;
 
diff --git a/src/gallium/drivers/d3d12/d3d12_video_array_of_textures_dpb_manager.cpp b/src/gallium/drivers/d3d12/d3d12_video_array_of_textures_dpb_manager.cpp
index f230036c536..fd24f5ee83f 100644
--- a/src/gallium/drivers/d3d12/d3d12_video_array_of_textures_dpb_manager.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_video_array_of_textures_dpb_manager.cpp
@@ -30,12 +30,8 @@
 // Uses an std::vector with individual D3D resources as backing storage instead of an D3D12 Texture Array
 // Supports dynamic pool capacity extension (by pushing back a new D3D12Resource) of the pool
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
+#include "d3d12_common.h"
 
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
 #include "d3d12_util.h"
 
 void
diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc.cpp b/src/gallium/drivers/d3d12/d3d12_video_enc.cpp
index 0bf72b7debe..8093298a04c 100644
--- a/src/gallium/drivers/d3d12/d3d12_video_enc.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_video_enc.cpp
@@ -21,12 +21,7 @@
  * IN THE SOFTWARE.
  */
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 #include "d3d12_util.h"
 #include "d3d12_context.h"
diff --git a/src/gallium/drivers/d3d12/d3d12_video_screen.h b/src/gallium/drivers/d3d12/d3d12_video_screen.h
index b0ba56abae2..5da76496fca 100644
--- a/src/gallium/drivers/d3d12/d3d12_video_screen.h
+++ b/src/gallium/drivers/d3d12/d3d12_video_screen.h
@@ -26,11 +26,7 @@
 
 #include "util/u_inlines.h"
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 void
 d3d12_screen_video_init(struct pipe_screen *pscreen);
diff --git a/src/gallium/drivers/d3d12/d3d12_video_texture_array_dpb_manager.cpp b/src/gallium/drivers/d3d12/d3d12_video_texture_array_dpb_manager.cpp
index 199c678a25f..5564454a437 100644
--- a/src/gallium/drivers/d3d12/d3d12_video_texture_array_dpb_manager.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_video_texture_array_dpb_manager.cpp
@@ -23,12 +23,7 @@
 
 #include "d3d12_video_texture_array_dpb_manager.h"
 
-#ifndef _WIN32
-#include <wsl/winadapter.h>
-#endif
-
-#define D3D12_IGNORE_SDK_LAYERS
-#include <directx/d3d12.h>
+#include "d3d12_common.h"
 
 #include "d3d12_util.h"
 



More information about the mesa-commit mailing list