From 28641d210000c550270bce080ba265ea155aa6c8 Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Sat, 30 Jan 2010 21:24:37 +0100 Subject: [PATCH] Fix texture in D3D9 after reset --- overlay/d3d9.cpp | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/overlay/d3d9.cpp b/overlay/d3d9.cpp index 82c89c9ef..31976ebb7 100644 --- a/overlay/d3d9.cpp +++ b/overlay/d3d9.cpp @@ -104,15 +104,21 @@ void DevState::blit(unsigned int x, unsigned int y, unsigned int w, unsigned int return; D3DLOCKED_RECT lr; - RECT r; + + if ((x == 0) && (y == 0) && (w == uiWidth) && (h == uiHeight)) { + if (texTexture->LockRect(0, &lr, NULL, D3DLOCK_DISCARD) != D3D_OK) + return; + } else { + RECT r; - r.left = x; - r.top = y; - r.right = x + w; - r.bottom = y + h; + r.left = x; + r.top = y; + r.right = x + w; + r.bottom = y + h; - if (texTexture->LockRect(0, &lr, &r, 0) != D3D_OK) - return; + if (texTexture->LockRect(0, &lr, &r, 0) != D3D_OK) + return; + } for (unsigned int r=0;r < h;++r) { unsigned char *dptr = reinterpret_cast(lr.pBits) + r * lr.Pitch; @@ -191,8 +197,24 @@ void DevState::draw() { checkMessage(vp.Width, vp.Height); - if (! a_ucTexture || !texTexture || (uiLeft == uiRight)) + if (! a_ucTexture || (uiLeft == uiRight)) return; + + if (! texTexture) { + unsigned int l, r, t, b; + l = uiLeft; + r = uiRight; + t = uiTop; + b = uiBottom; + newTexture(uiWidth, uiHeight); + blit(0, 0, uiWidth, uiHeight); + + uiLeft = l; + uiRight = r; + uiTop = t; + uiBottom = b; + setRect(); + } dev->SetTexture(0, texTexture); dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, vertices, sizeof(D3DTLVERTEX)); @@ -297,7 +319,7 @@ static void doPresent(IDirect3DDevice9 *idd) { pRenderTarget->Release(); pTarget->Release(); - ods("Finished ref is %d %d", ds->myRefCount, ds->refCount); +// ods("Finished ref is %d %d", ds->myRefCount, ds->refCount); ds->dwMyThread = dwOldThread; } }