#pragma once
#include "ppsspp_config.h"
#include "Common/CommonWindows.h"
#include "Windows/GPU/WindowsGraphicsContext.h"
#include <d3d11.h>
#include <d3d11_1.h>
#include <wrl/client.h>
class DrawContext;
class D3D11Context : public WindowsGraphicsContext {
public:
bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override;
void Shutdown() override;
void Resize() override;
Draw::DrawContext *GetDrawContext() override { return draw_; }
private:
HRESULT CreateTheDevice(IDXGIAdapter *adapter);
void LostBackbuffer();
void GotBackbuffer();
Draw::DrawContext *draw_ = nullptr;
Microsoft::WRL::ComPtr<IDXGISwapChain> swapChain_;
DXGI_SWAP_CHAIN_DESC swapChainDesc_ = {};
Microsoft::WRL::ComPtr<ID3D11Device> device_;
Microsoft::WRL::ComPtr<ID3D11Device1> device1_;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context_;
Microsoft::WRL::ComPtr<ID3D11DeviceContext1> context1_;
Microsoft::WRL::ComPtr<ID3D11Texture2D> bbRenderTargetTex_;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> bbRenderTargetView_;
#ifdef _DEBUG
Microsoft::WRL::ComPtr<ID3D11Debug> d3dDebug_;
Microsoft::WRL::ComPtr<ID3D11InfoQueue> d3dInfoQueue_;
#endif
D3D_FEATURE_LEVEL featureLevel_ = D3D_FEATURE_LEVEL_11_0;
int adapterId = -1;
HDC hDC = nullptr;
HWND hWnd_ = nullptr;
HMODULE hD3D11 = nullptr;
int width = 0;
int height = 0;
int swapInterval_ = 0;
};