| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <d3d11_4.h> |
| 7 |
#include <d3dcompiler.h> |
| 8 |
#include <dxgi1_6.h> |
| 9 |
#include <fmt/format.h> |
| 10 |
#include <vector> |
| 11 |
#include <wrl/client.h> |
| 12 |
|
| 13 |
#include "Common/CommonTypes.h" |
| 14 |
#include "Common/HRWrap.h" |
| 15 |
|
| 16 |
namespace DX11 |
| 17 |
{ |
| 18 |
using Microsoft::WRL::ComPtr; |
| 19 |
class SwapChain; |
| 20 |
|
| 21 |
namespace D3D |
| 22 |
{ |
| 23 |
extern ComPtr<IDXGIFactory> dxgi_factory; |
| 24 |
extern ComPtr<ID3D11Device> device; |
| 25 |
extern ComPtr<ID3D11Device1> device1; |
| 26 |
extern ComPtr<ID3D11DeviceContext> context; |
| 27 |
extern D3D_FEATURE_LEVEL feature_level; |
| 28 |
|
| 29 |
bool Create(u32 adapter_index, bool enable_debug_layer); |
| 30 |
void Destroy(); |
| 31 |
|
| 32 |
|
| 33 |
std::vector<u32> GetAAModes(u32 adapter_index); |
| 34 |
|
| 35 |
|
| 36 |
bool SupportsTextureFormat(DXGI_FORMAT format); |
| 37 |
|
| 38 |
|
| 39 |
bool SupportsLogicOp(u32 adapter_index); |
| 40 |
|
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
struct DX11HRWrap |
| 47 |
{ |
| 48 |
constexpr explicit DX11HRWrap(HRESULT hr) : m_hr(hr) {} |
| 49 |
const HRESULT m_hr; |
| 50 |
}; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
template <> |
| 55 |
struct fmt::formatter<DX11::DX11HRWrap> |
| 56 |
{ |
| 57 |
constexpr auto parse(fmt::format_parse_context& ctx) { return ctx.begin(); } |
| 58 |
template <typename FormatContext> |
| 59 |
auto format(const DX11::DX11HRWrap& hr, FormatContext& ctx) const |
| 60 |
{ |
| 61 |
if (hr.m_hr == DXGI_ERROR_DEVICE_REMOVED && DX11::D3D::device != nullptr) |
| 62 |
{ |
| 63 |
return fmt::format_to(ctx.out(), "{}\nDevice removal reason: {}", Common::HRWrap(hr.m_hr), |
| 64 |
Common::HRWrap(DX11::D3D::device->GetDeviceRemovedReason())); |
| 65 |
} |
| 66 |
else |
| 67 |
{ |
| 68 |
return fmt::format_to(ctx.out(), "{}", Common::HRWrap(hr.m_hr)); |
| 69 |
} |
| 70 |
} |
| 71 |
}; |