Fix #9390, also unbreak D3D11 screenshots

This commit is contained in:
Henrik Rydgard 2017-03-05 20:30:39 +01:00
parent 37646d67b7
commit 042d09a049
7 changed files with 17 additions and 11 deletions

View file

@ -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;

View file

@ -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() {

View file

@ -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();

View file

@ -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;

View file

@ -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)

View file

@ -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);

View file

@ -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
}