mirror of
https://github.com/minetest/irrlicht.git
synced 2025-06-30 15:20:25 +02:00
Fix SMaterialLayer operator!= and optimize operator=
SMaterialLayers are now identical when both have identity matrices. Before it didn't consider them identical when one layer had set the identity matrix explicitly and the other didn't. Generally didn't matter, just caused very rarely some extra state switches in the drivers. And just as rarely had a cheaper comparison. Just seems more correct this way. operator= no longer releases texture memory which was allocated at one point. Unless explicitly requested such memory is now always released later in the destructor. This can avoid quite a few memory allocations/released in the driver. Usually not a noticeable performance difference on most platforms. But it can help avoid memory fragmentation. We instead use an extra bool now to tell if the texture memory is used. So slight increase in SMaterialLayer and SMaterial size. But I did a quick performance test and this had no negative influence here, while it did improve speed in the case where it switched between material layers using/not using texture matrices a bit. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6488 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@ -71,9 +71,41 @@ static bool polygonOffset(video::E_DRIVER_TYPE type)
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool testSMaterial()
|
||||
{
|
||||
irr::video::SMaterial a;
|
||||
irr::video::SMaterial b;
|
||||
|
||||
// Same by default?
|
||||
if ( !(a == b) )
|
||||
return false;
|
||||
if ( a != b )
|
||||
return false;
|
||||
|
||||
// getting (creating) one texture matrix shouldn't change things
|
||||
b.TextureLayer[0].getTextureMatrix();
|
||||
if ( a != b )
|
||||
return false;
|
||||
|
||||
// no longer same now
|
||||
b.TextureLayer[0].getTextureMatrix().setTextureScale(5.f, 0.5f);
|
||||
if ( a == b )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool material()
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
TestWithAllDrivers(polygonOffset);
|
||||
|
||||
if ( !testSMaterial() )
|
||||
{
|
||||
logTestString("testSMaterial failed\n\n");
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
Tests finished. 72 tests of 72 passed.
|
||||
Compiled as DEBUG
|
||||
Test suite pass at GMT Fri May 05 18:39:44 2023
|
||||
Test suite pass at GMT Sun May 07 14:26:39 2023
|
||||
|
||||
|
Reference in New Issue
Block a user