From d68e501db4bdf4dcdc06456572ab70f44f43125e Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Mon, 8 Apr 2019 13:43:48 +0200 Subject: [PATCH] Fixed bug 4582 - Maximize/Resize not working on Windows 10 When viewport is set, projectionAndView changes, but ID3D11DeviceContext_UpdateSubresource was not called. --- src/render/direct3d11/SDL_render_d3d11.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index c4345eb9c..ef5db8497 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -1897,7 +1897,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer) * with a non-empty viewport. */ /* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */ - return 0; + return -1; } /* Make sure the SDL viewport gets rotated to that of the physical display's rotation. @@ -1997,6 +1997,7 @@ D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11 ID3D11ShaderResourceView *shaderResource; const SDL_BlendMode blendMode = cmd->data.draw.blend; ID3D11BlendState *blendState = NULL; + SDL_bool updateSubresource = SDL_FALSE; if (renderTargetView != rendererData->currentRenderTargetView) { ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext, @@ -2008,7 +2009,10 @@ D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11 } if (rendererData->viewportDirty) { - D3D11_UpdateViewport(renderer); + if (D3D11_UpdateViewport(renderer) == 0) { + /* vertexShaderConstantsData.projectionAndView has changed */ + updateSubresource = SDL_TRUE; + } } if (rendererData->cliprectDirty) { @@ -2073,7 +2077,7 @@ D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11 rendererData->currentSampler = sampler; } - if (SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) { + if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) { SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)); ID3D11DeviceContext_UpdateSubresource(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexShaderConstants,