aboutsummaryrefslogtreecommitdiff
path: root/dxcommon
diff options
context:
space:
mode:
authorMarc Sunet <marc.sunet@amd.com>2025-11-19 11:24:21 -0800
committerMarc Sunet <marc.sunet@amd.com>2025-11-19 11:24:21 -0800
commit556cf073d61875368fe8511b75f5cb7db04ccb52 (patch)
tree356c3cfdfa926b7e3b11767dc76ab981610a463b /dxcommon
parent5516490fd5bea08d253dcaed59c430c2dada5c2d (diff)
Use C++ modules
Diffstat (limited to 'dxcommon')
-rw-r--r--dxcommon/CMakeLists.txt16
-rw-r--r--dxcommon/dxcommon.h17
-rw-r--r--dxcommon/dxcommon.ixx (renamed from dxcommon/include/dxcommon.h)25
-rw-r--r--dxcommon/src/dxcommon.cc8
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 @@
1cmake_minimum_required(VERSION 3.20) 1cmake_minimum_required(VERSION 3.25)
2 2
3add_library(dxcommon 3project(dxcommon)
4 src/dxcommon.cc) 4
5add_library(dxcommon)
6
7target_sources(dxcommon PUBLIC
8 dxcommon.h)
9
10target_sources(dxcommon PUBLIC
11 FILE_SET cxx_modules TYPE CXX_MODULES FILES
12 dxcommon.ixx)
5 13
6target_include_directories(dxcommon PUBLIC 14target_include_directories(dxcommon PUBLIC
7 ${CMAKE_CURRENT_SOURCE_DIR}/include) 15 .)
8 16
9target_link_libraries(dxcommon PUBLIC 17target_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 1module;
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) 6export module dxcommon;
7
8using Microsoft::WRL::ComPtr;
8 9
9namespace dx { 10namespace dx {
10 11
11using Microsoft::WRL::ComPtr; 12export {
12 13
13class exception : public std::exception 14class 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
48template <typename T> 39template <typename T>
49void SafeRelease(ComPtr<T>& ptr) 40void 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
51thread_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
3namespace dx
4{
5
6thread_local char exception::m_error[1024];
7
8} // namespace dx