Fixed bug 4582 - Maximize/Resize not working on Windows 10 When viewport is set, projectionAndView changes, but ID3D11DeviceContext_UpdateSubresource was not called.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index c4345eb..ef5db84 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,