CMake support added for building with MinGW (#275)

This commit is contained in:
Chuck Walbourn
2022-05-05 14:50:13 -07:00
committed by GitHub
parent 24c1415c9a
commit 9c72f2c6cd
26 changed files with 229 additions and 151 deletions

View File

@@ -135,16 +135,18 @@ namespace
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
#if defined(_DEBUG) || defined(PROFILE)
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept
{
#if defined(_DEBUG) || defined(PROFILE)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
#else
UNREFERENCED_PARAMETER(resource);
UNREFERENCED_PARAMETER(name);
#endif
}
#else
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept
{
}
#endif
//--------------------------------------------------------------------------------------
HRESULT LoadTextureDataFromMemory(

View File

@@ -21,7 +21,7 @@
#include <memory>
#include <new>
#ifndef WIN32
#ifndef _WIN32
#include <fstream>
#include <filesystem>
#endif
@@ -47,10 +47,10 @@
#define D3DX12_NO_STATE_OBJECT_HELPERS
#define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS
#ifdef WIN32
#include "d3dx12.h"
#else
#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS)
#include "directx/d3dx12.h"
#else
#include "d3dx12.h"
#endif
using namespace DirectX;
@@ -157,7 +157,7 @@ struct DDS_HEADER_DXT10
//--------------------------------------------------------------------------------------
namespace
{
#ifdef WIN32
#ifdef _WIN32
struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } };
using ScopedHandle = std::unique_ptr<void, handle_closer>;
@@ -165,16 +165,18 @@ namespace
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
#endif
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength]) noexcept
{
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
resource->SetName(name);
#else
UNREFERENCED_PARAMETER(resource);
UNREFERENCED_PARAMETER(name);
#endif
}
#else
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D12DeviceChild*, _In_z_ const wchar_t(&)[TNameLength]) noexcept
{
}
#endif
inline uint32_t CountMips(uint32_t width, uint32_t height) noexcept
{
@@ -274,7 +276,7 @@ namespace
*bitSize = 0;
#ifdef WIN32
#ifdef _WIN32
// open the file
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,

View File

@@ -16,13 +16,21 @@
#pragma once
#if defined(WIN32) || defined(_WIN32)
#include <d3d12.h>
#pragma comment(lib,"dxguid.lib")
#else
#ifdef __MINGW32__
#include <unknwn.h>
#endif
#ifndef _WIN32
#include <wsl/winadapter.h>
#include <wsl/wrladapter.h>
#endif
#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS)
#include <directx/d3d12.h>
#include <dxguids/dxguids.h>
#else
#include <d3d12.h>
#pragma comment(lib,"dxguid.lib")
#endif
#include <cstddef>