2015-05-24 07:55:12 +03:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-18 02:08:10 +03:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 06:29:41 +03:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-13 22:50:06 +03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-11-13 06:58:49 +02:00
|
|
|
#include <d3d11.h>
|
2017-09-03 09:33:47 +03:00
|
|
|
#include <d3d11_1.h>
|
2013-10-19 12:27:57 +03:00
|
|
|
#include <d3dcompiler.h>
|
2017-09-03 18:33:12 +03:00
|
|
|
#include <dxgi1_5.h>
|
2011-06-11 22:37:21 +03:00
|
|
|
#include <vector>
|
2010-06-13 22:50:06 +03:00
|
|
|
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "Common/Common.h"
|
2017-02-03 18:57:41 +02:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-10-07 23:55:13 +03:00
|
|
|
#include "Common/MsgHandler.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
|
2013-10-29 07:23:17 +02:00
|
|
|
namespace DX11
|
2011-01-29 22:16:51 +02:00
|
|
|
{
|
2016-06-24 11:43:46 +03:00
|
|
|
#define SAFE_RELEASE(x) \
|
|
|
|
{ \
|
|
|
|
if (x) \
|
|
|
|
(x)->Release(); \
|
|
|
|
(x) = nullptr; \
|
|
|
|
}
|
|
|
|
#define SAFE_DELETE(x) \
|
|
|
|
{ \
|
|
|
|
delete (x); \
|
|
|
|
(x) = nullptr; \
|
|
|
|
}
|
|
|
|
#define SAFE_DELETE_ARRAY(x) \
|
|
|
|
{ \
|
|
|
|
delete[](x); \
|
|
|
|
(x) = nullptr; \
|
|
|
|
}
|
|
|
|
#define CHECK(cond, Message, ...) \
|
|
|
|
if (!(cond)) \
|
|
|
|
{ \
|
2018-04-12 15:18:04 +03:00
|
|
|
PanicAlert("%s failed in %s at line %d: " Message, __func__, __FILE__, __LINE__, __VA_ARGS__); \
|
2016-06-24 11:43:46 +03:00
|
|
|
}
|
2010-06-13 22:50:06 +03:00
|
|
|
|
2019-02-15 03:59:50 +02:00
|
|
|
class DXTexture;
|
|
|
|
class DXFramebuffer;
|
2011-01-29 22:16:51 +02:00
|
|
|
|
2010-06-13 22:50:06 +03:00
|
|
|
namespace D3D
|
|
|
|
{
|
2010-11-23 21:58:02 +02:00
|
|
|
HRESULT LoadDXGI();
|
|
|
|
HRESULT LoadD3D();
|
2011-02-27 01:41:02 +02:00
|
|
|
HRESULT LoadD3DCompiler();
|
2010-11-21 17:34:04 +02:00
|
|
|
void UnloadDXGI();
|
2010-11-23 21:58:02 +02:00
|
|
|
void UnloadD3D();
|
2011-02-27 01:41:02 +02:00
|
|
|
void UnloadD3DCompiler();
|
2010-11-23 21:58:02 +02:00
|
|
|
|
2013-07-22 15:38:09 +03:00
|
|
|
D3D_FEATURE_LEVEL GetFeatureLevel(IDXGIAdapter* adapter);
|
2011-03-30 10:17:23 +03:00
|
|
|
std::vector<DXGI_SAMPLE_DESC> EnumAAModes(IDXGIAdapter* adapter);
|
2010-11-21 17:34:04 +02:00
|
|
|
|
2010-06-13 22:50:06 +03:00
|
|
|
HRESULT Create(HWND wnd);
|
|
|
|
void Close();
|
|
|
|
|
2011-06-11 22:37:21 +03:00
|
|
|
extern ID3D11Device* device;
|
2017-09-03 09:33:47 +03:00
|
|
|
extern ID3D11Device1* device1;
|
2011-06-11 22:37:21 +03:00
|
|
|
extern ID3D11DeviceContext* context;
|
2018-01-26 08:23:24 +02:00
|
|
|
extern IDXGISwapChain1* swapchain;
|
2010-06-13 22:50:06 +03:00
|
|
|
|
2018-01-26 08:23:24 +02:00
|
|
|
void Reset(HWND new_wnd);
|
|
|
|
void ResizeSwapChain();
|
2010-06-13 22:50:06 +03:00
|
|
|
void Present();
|
|
|
|
|
2019-02-15 03:59:50 +02:00
|
|
|
DXTexture* GetSwapChainTexture();
|
|
|
|
DXFramebuffer* GetSwapChainFramebuffer();
|
2010-06-17 02:25:19 +03:00
|
|
|
const char* PixelShaderVersionString();
|
2011-03-14 11:38:29 +02:00
|
|
|
const char* GeometryShaderVersionString();
|
2010-06-17 02:25:19 +03:00
|
|
|
const char* VertexShaderVersionString();
|
2018-02-09 14:59:51 +02:00
|
|
|
const char* ComputeShaderVersionString();
|
2010-06-19 04:02:43 +03:00
|
|
|
bool BGRATexturesSupported();
|
2017-09-03 18:33:12 +03:00
|
|
|
bool AllowTearingSupported();
|
2010-06-13 22:50:06 +03:00
|
|
|
|
2017-03-10 15:40:52 +02:00
|
|
|
u32 GetMaxTextureSize(D3D_FEATURE_LEVEL feature_level);
|
2010-07-11 19:26:46 +03:00
|
|
|
|
2014-07-26 14:00:49 +03:00
|
|
|
HRESULT SetFullscreenState(bool enable_fullscreen);
|
2016-11-09 02:41:38 +02:00
|
|
|
bool GetFullscreenState();
|
2014-07-26 14:00:49 +03:00
|
|
|
|
2014-11-14 21:46:49 +02:00
|
|
|
// This function will assign a name to the given resource.
|
2010-06-13 22:50:06 +03:00
|
|
|
// The DirectX debug layer will make it easier to identify resources that way,
|
|
|
|
// e.g. when listing up all resources who have unreleased references.
|
2017-09-02 21:22:18 +03:00
|
|
|
void SetDebugObjectName(ID3D11DeviceChild* resource, const char* name);
|
|
|
|
std::string GetDebugObjectName(ID3D11DeviceChild* resource);
|
2015-02-09 14:14:45 +02:00
|
|
|
|
2013-10-19 12:27:57 +03:00
|
|
|
} // namespace D3D
|
2010-06-27 17:04:49 +03:00
|
|
|
|
2016-06-24 11:43:46 +03:00
|
|
|
typedef HRESULT(WINAPI* CREATEDXGIFACTORY)(REFIID, void**);
|
2010-11-21 17:34:04 +02:00
|
|
|
extern CREATEDXGIFACTORY PCreateDXGIFactory;
|
2016-06-24 11:43:46 +03:00
|
|
|
typedef HRESULT(WINAPI* D3D11CREATEDEVICE)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT,
|
|
|
|
CONST D3D_FEATURE_LEVEL*, UINT, UINT, ID3D11Device**,
|
|
|
|
D3D_FEATURE_LEVEL*, ID3D11DeviceContext**);
|
2011-01-29 22:16:51 +02:00
|
|
|
|
2013-10-19 12:27:57 +03:00
|
|
|
extern pD3DCompile PD3DCompile;
|
2011-02-27 01:41:02 +02:00
|
|
|
|
2011-02-14 04:18:03 +02:00
|
|
|
} // namespace DX11
|