mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
overlay: implement dx11 backend (#707)
## Link to GitHub Issue or related Pull Request, if one exists Fixes #134 ## Description of change Add ImGui DX11 backend implementation, and integrate into the spice overlay. The tricky part is that some of the Unity games: 1. Launch multiple windows, and 2. Can be resized (even full screen games launch at a certain resolution and then expand to fit desktop resolution) 3. lazy load DX11 DLLs This PR also adds screenshot functionality, but screen resize is not implemented. ## Testing Seems to be working for most games. Need to do final tests for: - [x] CCJ (attract movie plays as well) - [x] Busou Shinki (title movie plays) - [x] MFG - [x] QuizKnock - [x] Polaris Chord - [x] check dx9 for regression
This commit is contained in:
@@ -10,11 +10,22 @@
|
||||
|
||||
#include "external/imgui/imgui.h"
|
||||
|
||||
#ifdef SPICE_D3D11
|
||||
// forward decls for D3D11 (avoid pulling d3d11.h into every TU)
|
||||
struct ID3D11Device;
|
||||
struct ID3D11DeviceContext;
|
||||
struct ID3D11RenderTargetView;
|
||||
struct IDXGISwapChain;
|
||||
#endif
|
||||
|
||||
namespace overlay {
|
||||
class Window;
|
||||
|
||||
enum class OverlayRenderer {
|
||||
D3D9,
|
||||
#ifdef SPICE_D3D11
|
||||
D3D11,
|
||||
#endif
|
||||
SOFTWARE,
|
||||
};
|
||||
|
||||
@@ -62,6 +73,10 @@ namespace overlay {
|
||||
Window *window_log = nullptr;
|
||||
|
||||
explicit SpiceOverlay(HWND hWnd, IDirect3D9 *d3d, IDirect3DDevice9 *device);
|
||||
#ifdef SPICE_D3D11
|
||||
explicit SpiceOverlay(HWND hWnd, ID3D11Device *d3d11_device,
|
||||
ID3D11DeviceContext *d3d11_context, IDXGISwapChain *d3d11_swapchain);
|
||||
#endif
|
||||
explicit SpiceOverlay(HWND hWnd);
|
||||
~SpiceOverlay();
|
||||
|
||||
@@ -92,6 +107,14 @@ namespace overlay {
|
||||
inline bool uses_device(IDirect3DDevice9 *other) {
|
||||
return this->device == other;
|
||||
}
|
||||
#ifdef SPICE_D3D11
|
||||
inline bool uses_device(ID3D11Device *other) {
|
||||
return this->d3d11_device == other;
|
||||
}
|
||||
inline bool uses_swapchain(IDXGISwapChain *other) {
|
||||
return this->d3d11_swapchain == other;
|
||||
}
|
||||
#endif
|
||||
inline IDirect3DDevice9 *get_device() {
|
||||
return this->device;
|
||||
}
|
||||
@@ -124,6 +147,14 @@ namespace overlay {
|
||||
IDirect3D9 *d3d = nullptr;
|
||||
IDirect3DDevice9 *device = nullptr;
|
||||
|
||||
#ifdef SPICE_D3D11
|
||||
// D3D11
|
||||
ID3D11Device *d3d11_device = nullptr;
|
||||
ID3D11DeviceContext *d3d11_context = nullptr;
|
||||
IDXGISwapChain *d3d11_swapchain = nullptr;
|
||||
ID3D11RenderTargetView *d3d11_rtv = nullptr;
|
||||
#endif
|
||||
|
||||
// software
|
||||
std::vector<uint32_t> pixel_data;
|
||||
size_t pixel_data_width = 0;
|
||||
@@ -156,6 +187,10 @@ namespace overlay {
|
||||
|
||||
// synchronized helpers
|
||||
void create_d3d9(HWND hWnd, IDirect3D9 *d3d, IDirect3DDevice9 *device);
|
||||
#ifdef SPICE_D3D11
|
||||
void create_d3d11(HWND hWnd, ID3D11Device *device, ID3D11DeviceContext *context,
|
||||
IDXGISwapChain *swapchain);
|
||||
#endif
|
||||
void create_software(HWND hWnd);
|
||||
void destroy(HWND hWnd = nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user