diff options
| author | Marc Sunet <marc.sunet@amd.com> | 2025-11-19 11:24:21 -0800 |
|---|---|---|
| committer | Marc Sunet <marc.sunet@amd.com> | 2025-11-19 11:24:21 -0800 |
| commit | 556cf073d61875368fe8511b75f5cb7db04ccb52 (patch) | |
| tree | 356c3cfdfa926b7e3b11767dc76ab981610a463b /dxcommon | |
| parent | 5516490fd5bea08d253dcaed59c430c2dada5c2d (diff) | |
Use C++ modules
Diffstat (limited to 'dxcommon')
| -rw-r--r-- | dxcommon/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | dxcommon/dxcommon.h | 17 | ||||
| -rw-r--r-- | dxcommon/dxcommon.ixx (renamed from dxcommon/include/dxcommon.h) | 25 | ||||
| -rw-r--r-- | dxcommon/src/dxcommon.cc | 8 |
4 files changed, 39 insertions, 27 deletions
diff --git a/dxcommon/CMakeLists.txt b/dxcommon/CMakeLists.txt index 08fa178..dfb52bf 100644 --- a/dxcommon/CMakeLists.txt +++ b/dxcommon/CMakeLists.txt | |||
| @@ -1,10 +1,18 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.20) | 1 | cmake_minimum_required(VERSION 3.25) |
| 2 | 2 | ||
| 3 | add_library(dxcommon | 3 | project(dxcommon) |
| 4 | src/dxcommon.cc) | 4 | |
| 5 | add_library(dxcommon) | ||
| 6 | |||
| 7 | target_sources(dxcommon PUBLIC | ||
| 8 | dxcommon.h) | ||
| 9 | |||
| 10 | target_sources(dxcommon PUBLIC | ||
| 11 | FILE_SET cxx_modules TYPE CXX_MODULES FILES | ||
| 12 | dxcommon.ixx) | ||
| 5 | 13 | ||
| 6 | target_include_directories(dxcommon PUBLIC | 14 | target_include_directories(dxcommon PUBLIC |
| 7 | ${CMAKE_CURRENT_SOURCE_DIR}/include) | 15 | .) |
| 8 | 16 | ||
| 9 | target_link_libraries(dxcommon PUBLIC | 17 | target_link_libraries(dxcommon PUBLIC |
| 10 | DirectX-Headers | 18 | DirectX-Headers |
diff --git a/dxcommon/dxcommon.h b/dxcommon/dxcommon.h new file mode 100644 index 0000000..addb8c3 --- /dev/null +++ b/dxcommon/dxcommon.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <d3d12.h> | ||
| 4 | #include <dxgi1_4.h> | ||
| 5 | #include <directx/d3dx12.h> | ||
| 6 | |||
| 7 | #define THROW(error) throw exception(error, __FILE__, __LINE__) | ||
| 8 | |||
| 9 | #define ThrowIfFailed(result) \ | ||
| 10 | {\ | ||
| 11 | if (result != S_OK) \ | ||
| 12 | {\ | ||
| 13 | THROW(result);\ | ||
| 14 | }\ | ||
| 15 | } | ||
| 16 | |||
| 17 | //#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), static_cast<void**>(ppType) | ||
diff --git a/dxcommon/include/dxcommon.h b/dxcommon/dxcommon.ixx index 35ec0e2..b06ae95 100644 --- a/dxcommon/include/dxcommon.h +++ b/dxcommon/dxcommon.ixx | |||
| @@ -1,14 +1,15 @@ | |||
| 1 | #pragma once | 1 | module; |
| 2 | 2 | ||
| 3 | #include <wrl.h> | 3 | #include <wrl.h> |
| 4 | |||
| 5 | #include <stdexcept> | 4 | #include <stdexcept> |
| 6 | 5 | ||
| 7 | //#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), static_cast<void**>(ppType) | 6 | export module dxcommon; |
| 7 | |||
| 8 | using Microsoft::WRL::ComPtr; | ||
| 8 | 9 | ||
| 9 | namespace dx { | 10 | namespace dx { |
| 10 | 11 | ||
| 11 | using Microsoft::WRL::ComPtr; | 12 | export { |
| 12 | 13 | ||
| 13 | class exception : public std::exception | 14 | class exception : public std::exception |
| 14 | { | 15 | { |
| @@ -35,16 +36,6 @@ private: | |||
| 35 | static thread_local char m_error[1024]; | 36 | static thread_local char m_error[1024]; |
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | #define THROW(error) throw exception(error, __FILE__, __LINE__) | ||
| 39 | |||
| 40 | #define ThrowIfFailed(result) \ | ||
| 41 | {\ | ||
| 42 | if (result != S_OK) \ | ||
| 43 | {\ | ||
| 44 | THROW(result);\ | ||
| 45 | }\ | ||
| 46 | } | ||
| 47 | |||
| 48 | template <typename T> | 39 | template <typename T> |
| 49 | void SafeRelease(ComPtr<T>& ptr) | 40 | void SafeRelease(ComPtr<T>& ptr) |
| 50 | { | 41 | { |
| @@ -55,4 +46,8 @@ void SafeRelease(ComPtr<T>& ptr) | |||
| 55 | } | 46 | } |
| 56 | } | 47 | } |
| 57 | 48 | ||
| 58 | } // dx | 49 | } // export |
| 50 | |||
| 51 | thread_local char exception::m_error[1024]; | ||
| 52 | |||
| 53 | } // dx | ||
diff --git a/dxcommon/src/dxcommon.cc b/dxcommon/src/dxcommon.cc deleted file mode 100644 index 2139136..0000000 --- a/dxcommon/src/dxcommon.cc +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #include "dxcommon.h" | ||
| 2 | |||
| 3 | namespace dx | ||
| 4 | { | ||
| 5 | |||
| 6 | thread_local char exception::m_error[1024]; | ||
| 7 | |||
| 8 | } // namespace dx | ||
