direct3d: be more aggressive about resetting invalidated cached state. Fixes Bugzilla #4402.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 20e4cc0..76f1499 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -690,7 +690,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
static void
D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
- /*D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;*/
+ D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
if (!texturedata) {
@@ -706,6 +706,9 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
} else {
IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0);
texturedata->texture.dirty = SDL_TRUE;
+ if (data->drawstate.texture == texture) {
+ data->drawstate.texture = NULL;
+ }
}
}
@@ -1098,13 +1101,6 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
SDL_Texture *texture = cmd->data.draw.texture;
const SDL_BlendMode blend = cmd->data.draw.blend;
- if (texture) {
- D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
- if (texturedata) {
- UpdateDirtyTexture(data->device, &texturedata->texture);
- }
- }
-
if (texture != data->drawstate.texture) {
D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *) data->drawstate.texture->driverdata : NULL;
D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *) texture->driverdata : NULL;
@@ -1558,6 +1554,7 @@ static int
D3D_Reset(SDL_Renderer * renderer)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+ const Float4X4 d3dmatrix = MatrixIdentity();
HRESULT result;
SDL_Texture *texture;
int i;
@@ -1610,6 +1607,13 @@ D3D_Reset(SDL_Renderer * renderer)
D3D_InitRenderState(data);
D3D_SetRenderTargetInternal(renderer, renderer->target);
data->drawstate.viewport_dirty = SDL_TRUE;
+ data->drawstate.cliprect_dirty = SDL_TRUE;
+ data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
+ data->drawstate.texture = NULL;
+ data->drawstate.shader = NULL;
+ data->drawstate.blend = SDL_BLENDMODE_INVALID;
+ data->drawstate.is_copy_ex = SDL_FALSE;
+ IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&d3dmatrix);
/* Let the application know that render targets were reset */
{