From b5697421bbc73ed17ef3a8bc003571d1b6351b5c Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Wed, 19 Nov 2025 19:42:04 -0800 Subject: Rename dxcommon -> dxg --- CMakeLists.txt | 2 +- dxcommon/CMakeLists.txt | 20 ------------------- dxcommon/dxcommon.h | 17 ---------------- dxcommon/dxcommon.ixx | 53 ------------------------------------------------- dxg/CMakeLists.txt | 20 +++++++++++++++++++ dxg/dxcommon.h | 17 ++++++++++++++++ dxg/dxcommon.ixx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ hello/CMakeLists.txt | 2 +- 8 files changed, 92 insertions(+), 92 deletions(-) delete mode 100644 dxcommon/CMakeLists.txt delete mode 100644 dxcommon/dxcommon.h delete mode 100644 dxcommon/dxcommon.ixx create mode 100644 dxg/CMakeLists.txt create mode 100644 dxg/dxcommon.h create mode 100644 dxg/dxcommon.ixx diff --git a/CMakeLists.txt b/CMakeLists.txt index 631e1e3..ca8b0ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ add_subdirectory(contrib/DirectX-Headers) add_subdirectory(contrib/glfw) # Common libraries. -add_subdirectory(dxcommon) +add_subdirectory(dxg) add_subdirectory(dxwindow) # Applications. diff --git a/dxcommon/CMakeLists.txt b/dxcommon/CMakeLists.txt deleted file mode 100644 index dfb52bf..0000000 --- a/dxcommon/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -project(dxcommon) - -add_library(dxcommon) - -target_sources(dxcommon PUBLIC - dxcommon.h) - -target_sources(dxcommon PUBLIC - FILE_SET cxx_modules TYPE CXX_MODULES FILES - dxcommon.ixx) - -target_include_directories(dxcommon PUBLIC - .) - -target_link_libraries(dxcommon PUBLIC - DirectX-Headers - D3D12.lib - DXGI.lib) diff --git a/dxcommon/dxcommon.h b/dxcommon/dxcommon.h deleted file mode 100644 index addb8c3..0000000 --- a/dxcommon/dxcommon.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#include -#include - -#define THROW(error) throw exception(error, __FILE__, __LINE__) - -#define ThrowIfFailed(result) \ -{\ - if (result != S_OK) \ - {\ - THROW(result);\ - }\ -} - -//#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), static_cast(ppType) diff --git a/dxcommon/dxcommon.ixx b/dxcommon/dxcommon.ixx deleted file mode 100644 index b06ae95..0000000 --- a/dxcommon/dxcommon.ixx +++ /dev/null @@ -1,53 +0,0 @@ -module; - -#include -#include - -export module dxcommon; - -using Microsoft::WRL::ComPtr; - -namespace dx { - -export { - -class exception : public std::exception -{ -public: - exception() noexcept = default; - - exception(HRESULT result, const char* file, int line) noexcept - { - sprintf_s(m_error, sizeof(m_error), "%s:%d Failed with HRESULT = %08X", - file, line, static_cast(result)); - } - - exception(const char* error, const char* file, int line) noexcept - { - sprintf_s(m_error, sizeof(m_error), "%s:%d %s", file, line, error); - } - - [[nodiscard]] const char* what() const noexcept final - { - return m_error; - } - -private: - static thread_local char m_error[1024]; -}; - -template -void SafeRelease(ComPtr& ptr) -{ - if (ptr) - { - ptr->Release(); - ptr = nullptr; - } -} - -} // export - -thread_local char exception::m_error[1024]; - -} // dx diff --git a/dxg/CMakeLists.txt b/dxg/CMakeLists.txt new file mode 100644 index 0000000..6fa5401 --- /dev/null +++ b/dxg/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.25) + +project(dxg) + +add_library(dxg) + +target_sources(dxg PUBLIC + dxcommon.h) + +target_sources(dxg PUBLIC + FILE_SET cxx_modules TYPE CXX_MODULES FILES + dxcommon.ixx) + +target_include_directories(dxg PUBLIC + .) + +target_link_libraries(dxg PUBLIC + DirectX-Headers + D3D12.lib + DXGI.lib) diff --git a/dxg/dxcommon.h b/dxg/dxcommon.h new file mode 100644 index 0000000..addb8c3 --- /dev/null +++ b/dxg/dxcommon.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include + +#define THROW(error) throw exception(error, __FILE__, __LINE__) + +#define ThrowIfFailed(result) \ +{\ + if (result != S_OK) \ + {\ + THROW(result);\ + }\ +} + +//#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), static_cast(ppType) diff --git a/dxg/dxcommon.ixx b/dxg/dxcommon.ixx new file mode 100644 index 0000000..b06ae95 --- /dev/null +++ b/dxg/dxcommon.ixx @@ -0,0 +1,53 @@ +module; + +#include +#include + +export module dxcommon; + +using Microsoft::WRL::ComPtr; + +namespace dx { + +export { + +class exception : public std::exception +{ +public: + exception() noexcept = default; + + exception(HRESULT result, const char* file, int line) noexcept + { + sprintf_s(m_error, sizeof(m_error), "%s:%d Failed with HRESULT = %08X", + file, line, static_cast(result)); + } + + exception(const char* error, const char* file, int line) noexcept + { + sprintf_s(m_error, sizeof(m_error), "%s:%d %s", file, line, error); + } + + [[nodiscard]] const char* what() const noexcept final + { + return m_error; + } + +private: + static thread_local char m_error[1024]; +}; + +template +void SafeRelease(ComPtr& ptr) +{ + if (ptr) + { + ptr->Release(); + ptr = nullptr; + } +} + +} // export + +thread_local char exception::m_error[1024]; + +} // dx diff --git a/hello/CMakeLists.txt b/hello/CMakeLists.txt index ac9f285..2804b24 100644 --- a/hello/CMakeLists.txt +++ b/hello/CMakeLists.txt @@ -6,5 +6,5 @@ add_executable(hello main.cc) target_link_libraries(hello PRIVATE - dxcommon + dxg dxwindow) -- cgit v1.2.3