forked from Mirrorlandia_minetest/irrlicht
Merging r6488 through r6491 from trunk to ogl-es branch
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6492 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
1670db617b
commit
1de0ec5459
@ -11,6 +11,10 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point)
|
|||||||
--------------------------
|
--------------------------
|
||||||
Changes in 1.9 (not yet released)
|
Changes in 1.9 (not yet released)
|
||||||
|
|
||||||
|
- Bugfix: SMaterialLayer::operator!= no longer returns true when comparing a layer without texture matrix with one with a set identity texture matrix. Those are the same.
|
||||||
|
- SMaterialLayer no longer releases allocated texture memory before destructor unless explicitly requested.
|
||||||
|
This can avoid constantly allocation/releasing memory in the active driver material when setting materials.
|
||||||
|
Note that it does not copy texture memory when it's unused. This is still optimized.
|
||||||
- Add IMeshSceneNode::setNodeRegistration to allow registering MeshSceneNodes to the SceneManager per buffer instead of per node
|
- Add IMeshSceneNode::setNodeRegistration to allow registering MeshSceneNodes to the SceneManager per buffer instead of per node
|
||||||
- Add SMaterialLayer::hasSetTextureMatrix and SMaterialLayer::resetTextureMatrix
|
- Add SMaterialLayer::hasSetTextureMatrix and SMaterialLayer::resetTextureMatrix
|
||||||
- Add IShaderConstantSetCallBack::OnCreate to allow earlier access to IMaterialRendererServices
|
- Add IShaderConstantSetCallBack::OnCreate to allow earlier access to IMaterialRendererServices
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
#include "plane3d.h"
|
#include "plane3d.h"
|
||||||
#include "dimension2d.h"
|
#include "dimension2d.h"
|
||||||
#include "position2d.h"
|
#include "position2d.h"
|
||||||
#include "IMeshBuffer.h"
|
|
||||||
#include "triangle3d.h"
|
#include "triangle3d.h"
|
||||||
#include "EDriverTypes.h"
|
#include "EDriverTypes.h"
|
||||||
#include "EDriverFeatures.h"
|
#include "EDriverFeatures.h"
|
||||||
|
#include "EPrimitiveTypes.h"
|
||||||
#include "SExposedVideoData.h"
|
#include "SExposedVideoData.h"
|
||||||
#include "SOverrideMaterial.h"
|
#include "S3DVertex.h"
|
||||||
|
#include "SVertexIndex.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
@ -43,6 +44,8 @@ namespace video
|
|||||||
struct S3DVertex2TCoords;
|
struct S3DVertex2TCoords;
|
||||||
struct S3DVertexTangents;
|
struct S3DVertexTangents;
|
||||||
struct SLight;
|
struct SLight;
|
||||||
|
struct SOverrideMaterial;
|
||||||
|
class SMaterial;
|
||||||
class IImageLoader;
|
class IImageLoader;
|
||||||
class IImageWriter;
|
class IImageWriter;
|
||||||
class IMaterialRenderer;
|
class IMaterialRenderer;
|
||||||
|
@ -51,7 +51,8 @@ namespace video
|
|||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
SMaterialLayer() : Texture(0), TextureWrapU(ETC_REPEAT), TextureWrapV(ETC_REPEAT), TextureWrapW(ETC_REPEAT),
|
SMaterialLayer() : Texture(0), TextureWrapU(ETC_REPEAT), TextureWrapV(ETC_REPEAT), TextureWrapW(ETC_REPEAT),
|
||||||
BilinearFilter(true), TrilinearFilter(false), AnisotropicFilter(0), LODBias(0), TextureMatrix(0)
|
BilinearFilter(true), TrilinearFilter(false), AnisotropicFilter(0), LODBias(0),
|
||||||
|
TextureMatrix(0), TextureMatrixUsed(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,26 +85,22 @@ namespace video
|
|||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
Texture = other.Texture;
|
Texture = other.Texture;
|
||||||
|
if (other.TextureMatrixUsed)
|
||||||
|
{
|
||||||
if (TextureMatrix)
|
if (TextureMatrix)
|
||||||
{
|
{
|
||||||
if (other.TextureMatrix)
|
|
||||||
*TextureMatrix = *other.TextureMatrix;
|
*TextureMatrix = *other.TextureMatrix;
|
||||||
else
|
|
||||||
{
|
|
||||||
MatrixAllocator.destruct(TextureMatrix);
|
|
||||||
MatrixAllocator.deallocate(TextureMatrix);
|
|
||||||
TextureMatrix = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (other.TextureMatrix)
|
|
||||||
{
|
{
|
||||||
TextureMatrix = MatrixAllocator.allocate(1);
|
TextureMatrix = MatrixAllocator.allocate(1);
|
||||||
MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
|
MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
|
||||||
}
|
}
|
||||||
|
TextureMatrixUsed = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
TextureMatrix = 0;
|
{
|
||||||
|
TextureMatrixUsed = false;
|
||||||
}
|
}
|
||||||
TextureWrapU = other.TextureWrapU;
|
TextureWrapU = other.TextureWrapU;
|
||||||
TextureWrapV = other.TextureWrapV;
|
TextureWrapV = other.TextureWrapV;
|
||||||
@ -124,6 +121,12 @@ namespace video
|
|||||||
{
|
{
|
||||||
TextureMatrix = MatrixAllocator.allocate(1);
|
TextureMatrix = MatrixAllocator.allocate(1);
|
||||||
MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
|
MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
|
||||||
|
TextureMatrixUsed = true;
|
||||||
|
}
|
||||||
|
else if ( !TextureMatrixUsed )
|
||||||
|
{
|
||||||
|
*TextureMatrix = core::IdentityMatrix;
|
||||||
|
TextureMatrixUsed = true;
|
||||||
}
|
}
|
||||||
return *TextureMatrix;
|
return *TextureMatrix;
|
||||||
}
|
}
|
||||||
@ -132,7 +135,7 @@ namespace video
|
|||||||
/** \return Texture matrix of this layer. */
|
/** \return Texture matrix of this layer. */
|
||||||
const core::matrix4& getTextureMatrix() const
|
const core::matrix4& getTextureMatrix() const
|
||||||
{
|
{
|
||||||
if (TextureMatrix)
|
if (TextureMatrixUsed)
|
||||||
return *TextureMatrix;
|
return *TextureMatrix;
|
||||||
else
|
else
|
||||||
return core::IdentityMatrix;
|
return core::IdentityMatrix;
|
||||||
@ -151,25 +154,27 @@ namespace video
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
*TextureMatrix = mat;
|
*TextureMatrix = mat;
|
||||||
|
TextureMatrixUsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check if we have set a custom texture matrix
|
//! Check if we have set a custom texture matrix
|
||||||
//! Note that otherwise we get an IdentityMatrix as default
|
//! Note that otherwise we get an IdentityMatrix as default
|
||||||
inline bool hasSetTextureMatrix() const
|
inline bool hasSetTextureMatrix() const
|
||||||
{
|
{
|
||||||
return TextureMatrix != 0;
|
return TextureMatrixUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Reset texture matrix to identity matrix
|
//! Reset texture matrix to identity matrix
|
||||||
//! Releases memory, which is expensive, but ver rarely useful for optimizations
|
/** \param releaseMemory Releases also texture memory. Otherwise done in destructor */
|
||||||
void resetTextureMatrix()
|
void resetTextureMatrix(bool releaseMemory=true)
|
||||||
{
|
{
|
||||||
if ( TextureMatrix )
|
if ( TextureMatrix && releaseMemory)
|
||||||
{
|
{
|
||||||
MatrixAllocator.destruct(TextureMatrix);
|
MatrixAllocator.destruct(TextureMatrix);
|
||||||
MatrixAllocator.deallocate(TextureMatrix);
|
MatrixAllocator.deallocate(TextureMatrix);
|
||||||
TextureMatrix = 0;
|
TextureMatrix = 0;
|
||||||
}
|
}
|
||||||
|
TextureMatrixUsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Inequality operator
|
//! Inequality operator
|
||||||
@ -189,8 +194,11 @@ namespace video
|
|||||||
if (different)
|
if (different)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
different |= (TextureMatrix != b.TextureMatrix) &&
|
{
|
||||||
(!TextureMatrix || !b.TextureMatrix || (*TextureMatrix != *(b.TextureMatrix)));
|
different = (TextureMatrixUsed && b.TextureMatrixUsed && (*TextureMatrix != *b.TextureMatrix))
|
||||||
|
|| (TextureMatrixUsed && !b.TextureMatrixUsed && (*TextureMatrix != core::IdentityMatrix))
|
||||||
|
|| (!TextureMatrixUsed && b.TextureMatrixUsed && (core::IdentityMatrix != *b.TextureMatrix));
|
||||||
|
}
|
||||||
return different;
|
return different;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +249,7 @@ namespace video
|
|||||||
/** Do not access this element directly as the internal
|
/** Do not access this element directly as the internal
|
||||||
resource management has to cope with Null pointers etc. */
|
resource management has to cope with Null pointers etc. */
|
||||||
core::matrix4* TextureMatrix;
|
core::matrix4* TextureMatrix;
|
||||||
|
bool TextureMatrixUsed; // TextureMatrix memory stays until destructor even when unused to avoid unnecessary allocation/de-allocations
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace video
|
} // end namespace video
|
||||||
|
@ -179,6 +179,7 @@
|
|||||||
#include "SKeyMap.h"
|
#include "SKeyMap.h"
|
||||||
#include "SLight.h"
|
#include "SLight.h"
|
||||||
#include "SMaterial.h"
|
#include "SMaterial.h"
|
||||||
|
#include "SOverrideMaterial.h"
|
||||||
#include "SMesh.h"
|
#include "SMesh.h"
|
||||||
#include "SMeshBuffer.h"
|
#include "SMeshBuffer.h"
|
||||||
#include "SMeshBufferLightMap.h"
|
#include "SMeshBufferLightMap.h"
|
||||||
|
@ -76,6 +76,11 @@ public:
|
|||||||
driver->setMaterial(material);
|
driver->setMaterial(material);
|
||||||
driver->drawMeshBuffer(mb);
|
driver->drawMeshBuffer(mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resetting after each rendering so direct calls to render() for parent node continue to work
|
||||||
|
// Assuming each pass only runs once
|
||||||
|
RenderPass = ESNRP_NONE;
|
||||||
|
ParentDoesRender = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Renders the node.
|
//! Renders the node.
|
||||||
@ -84,10 +89,6 @@ public:
|
|||||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||||
driver->setTransform(video::ETS_WORLD, MeshNodeParent.getAbsoluteTransformation());
|
driver->setTransform(video::ETS_WORLD, MeshNodeParent.getAbsoluteTransformation());
|
||||||
renderBuffer(driver);
|
renderBuffer(driver);
|
||||||
|
|
||||||
// resetting each time so direct calls to render() for parent node continue to work
|
|
||||||
RenderPass = ESNRP_NONE;
|
|
||||||
ParentDoesRender = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const core::aabbox3d<f32>& getBoundingBox() const IRR_OVERRIDE
|
virtual const core::aabbox3d<f32>& getBoundingBox() const IRR_OVERRIDE
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "IVideoDriver.h"
|
#include "IVideoDriver.h"
|
||||||
#include "IAnimatedMesh.h"
|
#include "IAnimatedMesh.h"
|
||||||
#include "IMesh.h"
|
#include "IMesh.h"
|
||||||
|
#include "IMeshBuffer.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "IGUISkin.h"
|
#include "IGUISkin.h"
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "IWriteFile.h"
|
#include "IWriteFile.h"
|
||||||
#include "IXMLWriter.h"
|
#include "IXMLWriter.h"
|
||||||
#include "IMesh.h"
|
#include "IMesh.h"
|
||||||
|
#include "IMeshBuffer.h"
|
||||||
#include "IAttributes.h"
|
#include "IAttributes.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
|
@ -219,7 +219,7 @@ void CMeshSceneNode::render()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bufRenderNode->getRenderPass() == renderPass )
|
if ( bufRenderNode->getRenderPass() == renderPass || renderPass == ESNRP_NONE)
|
||||||
bufRenderNode->renderBuffer(driver);
|
bufRenderNode->renderBuffer(driver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "SVertexIndex.h"
|
#include "SVertexIndex.h"
|
||||||
#include "SLight.h"
|
#include "SLight.h"
|
||||||
#include "SExposedVideoData.h"
|
#include "SExposedVideoData.h"
|
||||||
|
#include "SOverrideMaterial.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning( disable: 4996)
|
#pragma warning( disable: 4996)
|
||||||
|
@ -573,10 +573,14 @@ void COpenGLSLMaterialRenderer::startUseProgram()
|
|||||||
|
|
||||||
void COpenGLSLMaterialRenderer::stopUseProgram()
|
void COpenGLSLMaterialRenderer::stopUseProgram()
|
||||||
{
|
{
|
||||||
// Not going to reset irrGlUseProgram/extGlUseProgramObject as it shouldn't really matter
|
// Necessary as fixed function pipeline breaks if programs are not reset to 0
|
||||||
|
if (Program)
|
||||||
|
Driver->extGlUseProgramObject(0);
|
||||||
|
if (Program2)
|
||||||
|
Driver->irrGlUseProgram(0);
|
||||||
|
|
||||||
// Force reset of material to ensure OnSetMaterial will be called or we can miss
|
// Force reset of material to ensure OnSetMaterial will be called or we can miss
|
||||||
// the next UseProgram call
|
// the next UseProgram call as stopUseProgram can be called from anywhere
|
||||||
Driver->DoResetRenderStates();
|
Driver->DoResetRenderStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "CParticleAnimatedMeshSceneNodeEmitter.h"
|
#include "CParticleAnimatedMeshSceneNodeEmitter.h"
|
||||||
#include "IAnimatedMeshSceneNode.h"
|
#include "IAnimatedMeshSceneNode.h"
|
||||||
#include "IMesh.h"
|
#include "IMesh.h"
|
||||||
|
#include "IMeshBuffer.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "IVideoDriver.h"
|
#include "IVideoDriver.h"
|
||||||
#include "IFileSystem.h"
|
#include "IFileSystem.h"
|
||||||
#include "SAnimatedMesh.h"
|
#include "SAnimatedMesh.h"
|
||||||
|
#include "SOverrideMaterial.h"
|
||||||
#include "CMeshCache.h"
|
#include "CMeshCache.h"
|
||||||
#include "IXMLWriter.h"
|
#include "IXMLWriter.h"
|
||||||
#include "ISceneUserDataSerializer.h"
|
#include "ISceneUserDataSerializer.h"
|
||||||
|
@ -71,9 +71,41 @@ static bool polygonOffset(video::E_DRIVER_TYPE type)
|
|||||||
return result;
|
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 material()
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
TestWithAllDrivers(polygonOffset);
|
TestWithAllDrivers(polygonOffset);
|
||||||
|
|
||||||
|
if ( !testSMaterial() )
|
||||||
|
{
|
||||||
|
logTestString("testSMaterial failed\n\n");
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Tests finished. 72 tests of 72 passed.
|
Tests finished. 72 tests of 72 passed.
|
||||||
Compiled as DEBUG
|
Compiled as DEBUG
|
||||||
Test suite pass at GMT Fri May 05 18:39:44 2023
|
Test suite pass at GMT Tue May 09 10:09:52 2023
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user