Commit f41e314f authored by hybrid's avatar hybrid

Fixed some missing unlocks and the missing point size setting in D3D drivers/textures.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@810 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 4e4c393d
...@@ -234,8 +234,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd ...@@ -234,8 +234,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
// enable anti alias if possible and whished // enable anti alias if possible and whished
if (antiAlias) if (antiAlias)
{ {
DWORD qualityLevels = 0;
if (!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, if (!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
devtype , present.BackBufferFormat, !fullScreen, devtype , present.BackBufferFormat, !fullScreen,
D3DMULTISAMPLE_2_SAMPLES))) D3DMULTISAMPLE_2_SAMPLES)))
...@@ -1341,6 +1339,12 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1341,6 +1339,12 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals);
} }
// thickness
if (resetAllRenderstates || lastmaterial.Thickness != material.Thickness)
{
pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&material.Thickness));
}
// texture address mode // texture address mode
for (u32 st=0; st<MaxTextureUnits; ++st) for (u32 st=0; st<MaxTextureUnits; ++st)
{ {
......
...@@ -399,6 +399,8 @@ bool CD3D8Texture::createMipMaps(u32 level) ...@@ -399,6 +399,8 @@ bool CD3D8Texture::createMipMaps(u32 level)
if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0)))
{ {
os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING);
upperSurface->Release();
lowerSurface->Release();
return false; return false;
} }
...@@ -406,6 +408,9 @@ bool CD3D8Texture::createMipMaps(u32 level) ...@@ -406,6 +408,9 @@ bool CD3D8Texture::createMipMaps(u32 level)
if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0)))
{ {
os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING);
upperSurface->UnlockRect();
upperSurface->Release();
lowerSurface->Release();
return false; return false;
} }
...@@ -428,18 +433,19 @@ bool CD3D8Texture::createMipMaps(u32 level) ...@@ -428,18 +433,19 @@ bool CD3D8Texture::createMipMaps(u32 level)
os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING);
} }
bool result=true;
// unlock // unlock
if (FAILED(upperSurface->UnlockRect())) if (FAILED(upperSurface->UnlockRect()))
return false; result=false;
if (FAILED(lowerSurface->UnlockRect())) if (FAILED(lowerSurface->UnlockRect()))
return false; result=false;
// release // release
upperSurface->Release(); upperSurface->Release();
lowerSurface->Release(); lowerSurface->Release();
if (upperDesc.Width <= 2 || upperDesc.Height <= 2) if (!result || upperDesc.Width < 3 || upperDesc.Height < 3)
return true; // stop generating levels return result; // stop generating levels
// generate next level // generate next level
return createMipMaps(level+1); return createMipMaps(level+1);
......
...@@ -1335,6 +1335,12 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1335,6 +1335,12 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals);
} }
// thickness
if (resetAllRenderstates || lastmaterial.Thickness != material.Thickness)
{
pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&material.Thickness));
}
// texture address mode // texture address mode
for (u32 st=0; st<MaxTextureUnits; ++st) for (u32 st=0; st<MaxTextureUnits; ++st)
{ {
......
...@@ -204,13 +204,14 @@ bool CD3D9Texture::createMipMaps(u32 level) ...@@ -204,13 +204,14 @@ bool CD3D9Texture::createMipMaps(u32 level)
upperSurface->GetDesc(&upperDesc); upperSurface->GetDesc(&upperDesc);
lowerSurface->GetDesc(&lowerDesc); lowerSurface->GetDesc(&lowerDesc);
D3DLOCKED_RECT upperlr; D3DLOCKED_RECT upperlr;
D3DLOCKED_RECT lowerlr; D3DLOCKED_RECT lowerlr;
// lock upper surface // lock upper surface
if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0)))
{ {
upperSurface->Release();
lowerSurface->Release();
os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING);
return false; return false;
} }
...@@ -218,6 +219,9 @@ bool CD3D9Texture::createMipMaps(u32 level) ...@@ -218,6 +219,9 @@ bool CD3D9Texture::createMipMaps(u32 level)
// lock lower surface // lock lower surface
if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0)))
{ {
upperSurface->UnlockRect();
upperSurface->Release();
lowerSurface->Release();
os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING);
return false; return false;
} }
...@@ -241,18 +245,19 @@ bool CD3D9Texture::createMipMaps(u32 level) ...@@ -241,18 +245,19 @@ bool CD3D9Texture::createMipMaps(u32 level)
os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING);
} }
bool result=true;
// unlock // unlock
if (FAILED(upperSurface->UnlockRect())) if (FAILED(upperSurface->UnlockRect()))
return false; result=false;
if (FAILED(lowerSurface->UnlockRect())) if (FAILED(lowerSurface->UnlockRect()))
return false; result=false;
// release // release
upperSurface->Release(); upperSurface->Release();
lowerSurface->Release(); lowerSurface->Release();
if (upperDesc.Width <= 2 || upperDesc.Height <= 2) if (!result || upperDesc.Width < 3 || upperDesc.Height < 3)
return true; // stop generating levels return result; // stop generating levels
// generate next level // generate next level
return createMipMaps(level+1); return createMipMaps(level+1);
...@@ -573,18 +578,20 @@ void CD3D9Texture::copy16BitMipMap(char* src, char* tgt, ...@@ -573,18 +578,20 @@ void CD3D9Texture::copy16BitMipMap(char* src, char* tgt,
s32 a=0, r=0, g=0, b=0; s32 a=0, r=0, g=0, b=0;
for (int dx=0; dx<2; ++dx) for (int dx=0; dx<2; ++dx)
{
for (int dy=0; dy<2; ++dy) for (int dy=0; dy<2; ++dy)
{ {
int tgx = (x*2)+dx; int tgx = (x*2)+dx;
int tgy = (y*2)+dy; int tgy = (y*2)+dy;
c = *(u16*)((void*)&src[(tgx*2)+(tgy*pitchsrc)]); c = *(u16*)(&src[(tgx*2)+(tgy*pitchsrc)]);
a += getAlpha(c); a += getAlpha(c);
r += getRed(c); r += getRed(c);
g += getGreen(c); g += getGreen(c);
b += getBlue(c); b += getBlue(c);
} }
}
a /= 4; a /= 4;
r /= 4; r /= 4;
...@@ -595,7 +602,7 @@ void CD3D9Texture::copy16BitMipMap(char* src, char* tgt, ...@@ -595,7 +602,7 @@ void CD3D9Texture::copy16BitMipMap(char* src, char* tgt,
c = RGBA16(r,g,b,a); c = RGBA16(r,g,b,a);
else else
c = A8R8G8B8toR5G6B5(SColor(a,r,g,b).color); c = A8R8G8B8toR5G6B5(SColor(a,r,g,b).color);
*(u16*)((void*)&tgt[(x*2)+(y*pitchtgt)]) = c; *(u16*)(&tgt[(x*2)+(y*pitchtgt)]) = c;
} }
} }
...@@ -619,7 +626,7 @@ void CD3D9Texture::copy32BitMipMap(char* src, char* tgt, ...@@ -619,7 +626,7 @@ void CD3D9Texture::copy32BitMipMap(char* src, char* tgt,
int tgx = (x*2)+dx; int tgx = (x*2)+dx;
int tgy = (y*2)+dy; int tgy = (y*2)+dy;
c = *(u32*)((void*)&src[(tgx<<2)+(tgy*pitchsrc)]); c = *(u32*)(&src[(tgx*4)+(tgy*pitchsrc)]);
a += c.getAlpha(); a += c.getAlpha();
r += c.getRed(); r += c.getRed();
...@@ -628,13 +635,13 @@ void CD3D9Texture::copy32BitMipMap(char* src, char* tgt, ...@@ -628,13 +635,13 @@ void CD3D9Texture::copy32BitMipMap(char* src, char* tgt,
} }
} }
a >>= 2; a /= 4;
r >>= 2; r /= 4;
g >>= 2; g /= 4;
b >>= 2; b /= 4;
c = ((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff); c.set(a, r, g, b);
*(u32*)((void*)&tgt[(x*4)+(y*pitchtgt)]) = c.color; *(u32*)(&tgt[(x*4)+(y*pitchtgt)]) = c.color;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment