direct3d: be more aggressive about resetting invalidated cached state.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 03 Dec 2018 09:26:05 -0500
changeset 12448f167f874ae55
parent 12447 0844007ea1c2
child 12449 17cb4ff70507
direct3d: be more aggressive about resetting invalidated cached state.

Fixes Bugzilla #4402.
src/render/direct3d/SDL_render_d3d.c
     1.1 --- a/src/render/direct3d/SDL_render_d3d.c	Mon Dec 03 02:06:17 2018 -0500
     1.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Mon Dec 03 09:26:05 2018 -0500
     1.3 @@ -690,7 +690,7 @@
     1.4  static void
     1.5  D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
     1.6  {
     1.7 -    /*D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;*/
     1.8 +    D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
     1.9      D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
    1.10  
    1.11      if (!texturedata) {
    1.12 @@ -706,6 +706,9 @@
    1.13      } else {
    1.14          IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0);
    1.15          texturedata->texture.dirty = SDL_TRUE;
    1.16 +        if (data->drawstate.texture == texture) {
    1.17 +            data->drawstate.texture = NULL;
    1.18 +        }
    1.19     }
    1.20  }
    1.21  
    1.22 @@ -1098,13 +1101,6 @@
    1.23      SDL_Texture *texture = cmd->data.draw.texture;
    1.24      const SDL_BlendMode blend = cmd->data.draw.blend;
    1.25  
    1.26 -    if (texture) {
    1.27 -        D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
    1.28 -        if (texturedata) {
    1.29 -            UpdateDirtyTexture(data->device, &texturedata->texture);
    1.30 -        }
    1.31 -    }
    1.32 -
    1.33      if (texture != data->drawstate.texture) {
    1.34          D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *) data->drawstate.texture->driverdata : NULL;
    1.35          D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *) texture->driverdata : NULL;
    1.36 @@ -1558,6 +1554,7 @@
    1.37  D3D_Reset(SDL_Renderer * renderer)
    1.38  {
    1.39      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    1.40 +    const Float4X4 d3dmatrix = MatrixIdentity();
    1.41      HRESULT result;
    1.42      SDL_Texture *texture;
    1.43      int i;
    1.44 @@ -1610,6 +1607,13 @@
    1.45      D3D_InitRenderState(data);
    1.46      D3D_SetRenderTargetInternal(renderer, renderer->target);
    1.47      data->drawstate.viewport_dirty = SDL_TRUE;
    1.48 +    data->drawstate.cliprect_dirty = SDL_TRUE;
    1.49 +    data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
    1.50 +    data->drawstate.texture = NULL;
    1.51 +    data->drawstate.shader = NULL;
    1.52 +    data->drawstate.blend = SDL_BLENDMODE_INVALID;
    1.53 +    data->drawstate.is_copy_ex = SDL_FALSE;
    1.54 +    IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&d3dmatrix);
    1.55  
    1.56      /* Let the application know that render targets were reset */
    1.57      {