diff --git a/GPU/D3D11/FramebufferManagerD3D11.cpp b/GPU/D3D11/FramebufferManagerD3D11.cpp index bc3af19710..41bcfab7b9 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.cpp +++ b/GPU/D3D11/FramebufferManagerD3D11.cpp @@ -1126,6 +1126,10 @@ bool FramebufferManagerD3D11::GetStencilbuffer(u32 fb_address, int fb_stride, GP bool FramebufferManagerD3D11::GetOutputFramebuffer(GPUDebugBuffer &buffer) { ID3D11Texture2D *backbuffer = (ID3D11Texture2D *)draw_->GetNativeObject(Draw::NativeObject::BACKBUFFER_COLOR_TEX); + if (!backbuffer) { + ERROR_LOG(G3D, "Failed to get backbuffer from draw context"); + return false; + } D3D11_TEXTURE2D_DESC desc; backbuffer->GetDesc(&desc); int w = desc.Width; diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 33368e4c7c..0811e02141 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -216,7 +216,7 @@ void D3D11Context::GotBackbuffer() { hr = device_->CreateRenderTargetView(bbRenderTargetTex_, nullptr, &bbRenderTargetView_); if (FAILED(hr)) return; - draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, width, height, bbRenderTargetView_); + draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, width, height, bbRenderTargetView_, bbRenderTargetTex_); } void D3D11Context::Resize() { diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index 306810a7dd..338ed9b889 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -645,7 +645,7 @@ public: virtual std::string GetInfoString(InfoField info) const = 0; virtual uintptr_t GetNativeObject(NativeObject obj) const = 0; - virtual void HandleEvent(Event ev, int width, int height, void *param) = 0; + virtual void HandleEvent(Event ev, int width, int height, void *param1 = nullptr, void *param2 = nullptr) = 0; protected: void CreatePresets(); diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index a260cbc419..c6c3d0cda4 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -126,7 +126,7 @@ public: case NativeObject::CONTEXT_EX: return (uintptr_t)context1_; case NativeObject::BACKBUFFER_COLOR_TEX: - return (uintptr_t)0; + return (uintptr_t)bbRenderTargetTex_; case NativeObject::BACKBUFFER_DEPTH_TEX: return (uintptr_t)bbDepthStencilTex_; case NativeObject::BACKBUFFER_COLOR_VIEW: @@ -140,7 +140,7 @@ public: } } - void HandleEvent(Event ev, int width, int height, void *param) override; + void HandleEvent(Event ev, int width, int height, void *param1, void *param2) override; private: struct FRect { @@ -156,6 +156,7 @@ private: ID3D11Device1 *device1_; ID3D11DeviceContext1 *context1_; + ID3D11Texture2D *bbRenderTargetTex_ = nullptr; // NOT OWNED ID3D11RenderTargetView *bbRenderTargetView_ = nullptr; // Strictly speaking we don't need a depth buffer for the backbuffer. ID3D11Texture2D *bbDepthStencilTex_ = nullptr; @@ -229,7 +230,7 @@ D3D11DrawContext::~D3D11DrawContext() { context_->PSSetShaderResources(0, 2, srv); } -void D3D11DrawContext::HandleEvent(Event ev, int width, int height, void *param) { +void D3D11DrawContext::HandleEvent(Event ev, int width, int height, void *param1, void *param2) { switch (ev) { case Event::LOST_BACKBUFFER: { if (curRenderTargetView_ == bbRenderTargetView_ || curDepthStencilView_ == bbDepthStencilView_) { @@ -247,7 +248,8 @@ void D3D11DrawContext::HandleEvent(Event ev, int width, int height, void *param) break; } case Event::GOT_BACKBUFFER: { - bbRenderTargetView_ = (ID3D11RenderTargetView *)param; + bbRenderTargetView_ = (ID3D11RenderTargetView *)param1; + bbRenderTargetTex_ = (ID3D11Texture2D *)param2; bbWidth_ = width; bbHeight_ = height; diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index dae2ec1f2c..96704a1362 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -551,7 +551,7 @@ public: } } - void HandleEvent(Event ev, int width, int height, void *param) override; + void HandleEvent(Event ev, int width, int height, void *param1, void *param2) override; private: LPDIRECT3D9 d3d_; @@ -1124,7 +1124,7 @@ bool D3D9Context::BlitFramebuffer(Framebuffer *srcfb, int srcX1, int srcY1, int return SUCCEEDED(device_->StretchRect(srcSurf, &srcRect, dstSurf, &dstRect, filter == FB_BLIT_LINEAR ? D3DTEXF_LINEAR : D3DTEXF_POINT)); } -void D3D9Context::HandleEvent(Event ev, int width, int height, void *param) { +void D3D9Context::HandleEvent(Event ev, int width, int height, void *param1, void *param2) { switch (ev) { case Event::LOST_BACKBUFFER: if (deviceRTsurf) diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index 5cb640eee1..c5e363a433 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -553,7 +553,7 @@ public: return 0; } - void HandleEvent(Event ev, int width, int height, void *param) override {} + void HandleEvent(Event ev, int width, int height, void *param1, void *param2) override {} private: OpenGLFramebuffer *fbo_ext_create(const FramebufferDesc &desc); diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 41e4ce0da8..3cd63d067f 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -413,7 +413,7 @@ public: return 0; } - void HandleEvent(Event ev, int width, int height, void *param) override; + void HandleEvent(Event ev, int width, int height, void *param1, void *param2) override; private: void ApplyDynamicState(); @@ -1316,7 +1316,7 @@ void VKContext::GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) { *h = fb->height; } -void VKContext::HandleEvent(Event ev, int width, int height, void *param) { +void VKContext::HandleEvent(Event ev, int width, int height, void *param1, void *param2) { // Noop }