dx: don't resize main framebuffer when rendering to texture

dx9 and dx11 renderers were wrongly resizing main framebuffer to 0,0
when rendering to a texture.

Fix for MINIDUMP-1W
This commit is contained in:
Flyinghead 2023-01-14 12:48:56 +01:00
parent 3441a9ccf0
commit a8c5af8425
3 changed files with 7 additions and 4 deletions

View File

@ -411,14 +411,13 @@ void DX11Renderer::setupPixelShaderConstants()
bool DX11Renderer::Render()
{
resize(pvrrc.framebufferWidth, pvrrc.framebufferHeight);
// make sure to unbind the framebuffer view before setting it as render target
ID3D11ShaderResourceView *nullView = nullptr;
deviceContext->PSSetShaderResources(0, 1, &nullView);
bool is_rtt = pvrrc.isRTT;
if (!is_rtt)
{
resize(pvrrc.framebufferWidth, pvrrc.framebufferHeight);
deviceContext->OMSetRenderTargets(1, &fbRenderTarget.get(), depthTexView);
deviceContext->ClearDepthStencilView(depthTexView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 0.f, 0);
}

View File

@ -945,7 +945,6 @@ bool D3DRenderer::Render()
{
if (!theDXContext.isReady())
return false;
resize(pvrrc.framebufferWidth, pvrrc.framebufferHeight);
bool is_rtt = pvrrc.isRTT;
@ -959,6 +958,7 @@ bool D3DRenderer::Render()
}
else
{
resize(pvrrc.framebufferWidth, pvrrc.framebufferHeight);
rc = SUCCEEDED(device->SetRenderTarget(0, framebufferSurface));
verify(rc);
D3DVIEWPORT9 viewport;
@ -1105,6 +1105,8 @@ void D3DRenderer::resize(int w, int h)
{
if (width == (u32)w && height == (u32)h)
return;
if (!config::EmulateFramebuffer)
// TODO use different surfaces in full fb emulation to avoid resizing twice per frame
NOTICE_LOG(RENDERER, "D3DRenderer::resize: %d x %d -> %d x %d", width, height, w, h);
width = w;
height = h;

View File

@ -31,6 +31,7 @@ DXContext theDXContext;
bool DXContext::init(bool keepCurrentWindow)
{
NOTICE_LOG(RENDERER, "DX9 Context initializing");
GraphicsContext::instance = this;
#ifdef USE_SDL
if (!keepCurrentWindow && !sdl_recreate_window(0))
@ -95,6 +96,7 @@ bool DXContext::init(bool keepCurrentWindow)
void DXContext::term()
{
NOTICE_LOG(RENDERER, "DX9 Context terminating");
GraphicsContext::instance = nullptr;
overlay.term();
imguiDriver.reset();