Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/GPU/D3D11Context.h
3186 views
1
// Copyright (c) 2015- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include "ppsspp_config.h"
21
22
#include "Common/CommonWindows.h"
23
#include "Windows/GPU/WindowsGraphicsContext.h"
24
#include <d3d11.h>
25
#include <d3d11_1.h>
26
#include <wrl/client.h>
27
28
class DrawContext;
29
30
class D3D11Context : public WindowsGraphicsContext {
31
public:
32
bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override;
33
void Shutdown() override;
34
35
void Resize() override;
36
37
Draw::DrawContext *GetDrawContext() override { return draw_; }
38
39
private:
40
HRESULT CreateTheDevice(IDXGIAdapter *adapter);
41
42
void LostBackbuffer();
43
void GotBackbuffer();
44
45
Draw::DrawContext *draw_ = nullptr;
46
Microsoft::WRL::ComPtr<IDXGISwapChain> swapChain_;
47
DXGI_SWAP_CHAIN_DESC swapChainDesc_ = {};
48
Microsoft::WRL::ComPtr<ID3D11Device> device_;
49
Microsoft::WRL::ComPtr<ID3D11Device1> device1_;
50
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context_;
51
Microsoft::WRL::ComPtr<ID3D11DeviceContext1> context1_;
52
53
Microsoft::WRL::ComPtr<ID3D11Texture2D> bbRenderTargetTex_;
54
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> bbRenderTargetView_;
55
56
#ifdef _DEBUG
57
Microsoft::WRL::ComPtr<ID3D11Debug> d3dDebug_;
58
Microsoft::WRL::ComPtr<ID3D11InfoQueue> d3dInfoQueue_;
59
#endif
60
D3D_FEATURE_LEVEL featureLevel_ = D3D_FEATURE_LEVEL_11_0;
61
int adapterId = -1;
62
HDC hDC = nullptr; // Private GDI Device Context
63
HWND hWnd_ = nullptr; // Holds Our Window Handle
64
HMODULE hD3D11 = nullptr;
65
int width = 0;
66
int height = 0;
67
int swapInterval_ = 0;
68
};
69
70