Fixed bug 4582 - Maximize/Resize not working on Windows 10
authorSylvain Becker <sylvain.becker@gmail.com>
Mon, 08 Apr 2019 13:43:48 +0200
changeset 12699c6356921b02b
parent 12698 0cc2592ed0f4
child 12700 1223f50edde3
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
     1.1 --- a/src/render/direct3d11/SDL_render_d3d11.c	Sat Apr 06 21:52:51 2019 +0200
     1.2 +++ b/src/render/direct3d11/SDL_render_d3d11.c	Mon Apr 08 13:43:48 2019 +0200
     1.3 @@ -1897,7 +1897,7 @@
     1.4           * with a non-empty viewport.
     1.5           */
     1.6          /* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */
     1.7 -        return 0;
     1.8 +        return -1;
     1.9      }
    1.10  
    1.11      /* Make sure the SDL viewport gets rotated to that of the physical display's rotation.
    1.12 @@ -1997,6 +1997,7 @@
    1.13      ID3D11ShaderResourceView *shaderResource;
    1.14      const SDL_BlendMode blendMode = cmd->data.draw.blend;
    1.15      ID3D11BlendState *blendState = NULL;
    1.16 +    SDL_bool updateSubresource = SDL_FALSE;
    1.17  
    1.18      if (renderTargetView != rendererData->currentRenderTargetView) {
    1.19          ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext,
    1.20 @@ -2008,7 +2009,10 @@
    1.21      }
    1.22  
    1.23      if (rendererData->viewportDirty) {
    1.24 -        D3D11_UpdateViewport(renderer);
    1.25 +        if (D3D11_UpdateViewport(renderer) == 0) {
    1.26 +            /* vertexShaderConstantsData.projectionAndView has changed */
    1.27 +            updateSubresource = SDL_TRUE;
    1.28 +        }
    1.29      }
    1.30  
    1.31      if (rendererData->cliprectDirty) {
    1.32 @@ -2073,7 +2077,7 @@
    1.33          rendererData->currentSampler = sampler;
    1.34      }
    1.35  
    1.36 -    if (SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) {
    1.37 +    if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) {
    1.38          SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix));
    1.39          ID3D11DeviceContext_UpdateSubresource(rendererData->d3dContext,
    1.40              (ID3D11Resource *)rendererData->vertexShaderConstants,