more .X much more decrease FPS.

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

sio2,
I have the directx 9.0 sdk ( MSDN March 2003 ).. could not find the source to mview:( Could I possibly get you to send it to me?
brett (DOT) r (DOT) jones (AT) gmail ( DOT) com
Espanol
Posts: 40
Joined: Sun Oct 22, 2006 3:28 am

Post by Espanol »

Luke, thank you for your kind. It is actually interested me. Would you please send your patch and .b3d for test?

Is there any option I should do for working with your patch?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Making progress on the loaders( X mesh and DDS textures ), here's a screenshot in IrrSpintz of the dwarf mesh from the DX Dec 2006 SDK( without normal mapping )

Image

DDS Loader can load R8G8B8, B8G8R8, A8R8G8B8, A8B8G8R8 and DXT1 formats so far, is all I needed, I'll add more to it as I come across the need to. It also loads 8-bit volume/3d textures, but as I mentioned, those texture types aren't supported in Irrlicht.
Image
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

SWEEEEEEEEEEEEEET.. UMM when do you think IrrSpintz will be updated with the new code?
Ки&am
Posts: 5
Joined: Fri Feb 16, 2007 10:00 am

Bug for this topic

Post by Ки&am »

Hello! I am using Irrlicht SVN (last).
Without .x model (tyny.x and it's optimized to 2K poly's version) FPS~=160. With model, FPS ~=40.
I'm fix some leaks in modifySkin() and animateSkeleton(), but FPS stil be very slow (~50). Two matrix transform in modifySkin() executed many (~7000) times at one call. It' dificult to reduce/

P/S/
I think that another fast order of weights are exists.
Ки&am
Posts: 5
Joined: Fri Feb 16, 2007 10:00 am

Post by Ки&am »

Some optimizations increase FPS to (max, in Debug) 70 (+30).
CXAnimationPlayer.cpp:

Code: Select all

void CXAnimationPlayer::modifySkin()
{
	// set animated vertices to zero
#ifdef _XREADER_DEBUG
	for (s32 k=0; k<(s32)Joints.size(); ++k)
	{
		for (s32 w=0; w<(s32)Joints[k].Weights.size(); ++w)
		{
			SWeightData& wd = Joints[k].Weights[w];

			if (wd.buffer >= AnimatedMesh->getMeshBufferCount() ||
				wd.vertex >= AnimatedMesh->getMeshBuffer(wd.buffer)->getVertexCount())
				os::Printer::log("CXAnimationPlayer: Invalid Weights");
			
			video::S3DVertex* nv = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(wd.buffer)->getVertices();
			nv[wd.vertex].Pos.set(0,0,0);
/*This two code lines in xreader-debug only! */
		}
	}
#endif


#ifdef _XREADER_DEBUG
	bool somethingIsWrong = false;

	// check if all vertices are set to zero
	for (u32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
	{
		video::S3DVertex* v = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices();
		s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount();
		for (s32 vt=0; vt<c; ++vt)
			if (v[vt].Pos != core::vector3df(0,0,0))
			{
				char tmp[255];
				sprintf(tmp, "CXAnimationPlayer: Vertex not null. Buf:%d Vtx:%d", mb, vt);
				// this can happen if something is wrong with the vertex weights,
				// not all vertices have a weight attached.
				os::Printer::log(tmp);
				somethingIsWrong = true;
			}
	}

	if (somethingIsWrong)
	{
		// write out mesh informations
		char tmp[255];
		sprintf(tmp, "CXAnimationPlayer: Meshbuffers:%d", AnimatedMesh->getMeshBufferCount());
		os::Printer::log(tmp);

		for (u32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
		{
			sprintf(tmp, "CXAnimationPlayer: Meshbuffer #%d: %d vertices", mb, AnimatedMesh->getMeshBuffer(mb)->getVertexCount());	
			os::Printer::log(tmp);
		}
	}
#endif
	
core::vector3df orig;
core::matrix4   mat;
			s32 w;
	for (s32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
	{
		video::S3DVertex* av = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices();
		video::S3DVertex* ov = (video::S3DVertex*)OriginalMesh.getMeshBuffer(mb)->getVertices();
		const s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount();
		for (s32 vt=0; vt<c; ++vt)
		{
			orig = ov[vt].Pos;
			const SVertexWeight& weight = Weights[mb].pointer()[vt];

			memset(mat.M,0,16*4);

			for (w=0; w<weight.weightCount; ++w)
			{
            //mat += combined*weight
				mat.set_summ_with_weight
				 (Joints[weight.joint[w]].CombinedAnimationMatrix,weight.weight[w]);
			}

			mat.transformVect(av[vt].Pos,orig);
			// yin nadie: let's modify the normals
			orig += ov[vt].Normal;
			mat.transformVect(av[vt].Normal,orig);
			av[vt].Normal -= av[ vt ].Pos;
			av[vt].Normal.normalize();
		}
	}
}
matrix4.h:

Code: Select all

			//! multiply by scalar
			matrix4 operator*(const f32 scalar) const;

			//! summ to another matrix
			matrix4 operator+(const matrix4& other) const;

			//! add this to another matrix
			inline void operator+=(const matrix4& other);

			//! add to another with weight
			inline void set_summ_with_weight(const matrix4& other, const f32 weight); 

Code: Select all

	//! multiply by scalar
	inline matrix4 matrix4::operator*(const f32 scalar) const
	{
		matrix4 tmtrx ( EM4CONST_NOTHING );

		const f32 *m1 = M;
		f32 *m3 = tmtrx.M;

		m3[0] = m1[0]*scalar; m3[1] = m1[1]*scalar;
		m3[2] = m1[2]*scalar; m3[3] = m1[3]*scalar;
		m3[4] = m1[4]*scalar; m3[5] = m1[5]*scalar;
		m3[6] = m1[6]*scalar; m3[7] = m1[7]*scalar;
		m3[8] = m1[8]*scalar; m3[9] = m1[9]*scalar;
		m3[10] = m1[10]*scalar; m3[11] = m1[11]*scalar;
		m3[12] = m1[12]*scalar; m3[13] = m1[13]*scalar;
		m3[14] = m1[14]*scalar; m3[15] = m1[15]*scalar;

		return tmtrx;
	}

	//! summ to another matrix
	inline matrix4 matrix4::operator+(const matrix4& other) const
	{
		matrix4 tmtrx ( EM4CONST_NOTHING );

		const f32 *m1 = M;
		const f32 *m2 = other.M;
		f32 *m3 = tmtrx.M;

		m3[0] = m1[0] + m2[0]; m3[1] = m1[1] + m2[1];
		m3[2] = m1[2] + m2[2]; m3[3] = m1[3] + m2[3];
		m3[4] = m2[4] + m1[4]; m3[5] = m1[5] + m2[5];
		m3[6] = m1[6] + m2[6]; m3[7] = m1[7] + m2[7];
		m3[8] = m2[8] + m1[8]; m3[9] = m2[9] + m1[9];
		m3[10] = m1[10] + m2[10]; m3[11] = m1[11] + m2[11];
		m3[12] = m2[12] + m1[12]; m3[13] = m2[13] + m1[13];
		m3[14] = m2[14] + m1[14]; m3[15] = m1[15] + m2[15];

		return tmtrx;
	}
	//! add this to another matrix
	inline void matrix4::operator+=(const matrix4& other)
	{
		const f32 *m2 = other.M;

		M[0] += m2[0]; M[1] += m2[1];
		M[2] += m2[2]; M[3] += m2[3];
		M[4] += m2[4]; M[5] += m2[5];
		M[6] += m2[6]; M[7] += m2[7];
		M[8] += m2[8]; M[9] += m2[9];
		M[10] += m2[10]; M[11] += m2[11];
		M[12] += m2[12]; M[13] += m2[13];
		M[14] += m2[14]; M[15] += m2[15];
	}
	//! add to another with weight
	inline void matrix4::set_summ_with_weight(const matrix4& other, const f32 weight) 
	{
		const f32 *m2 = other.M;

		M[0] += m2[0]*weight; M[1] += m2[1]*weight;
		M[2] += m2[2]*weight; M[3] += m2[3]*weight;
		M[4] += m2[4]*weight; M[5] += m2[5]*weight;
		M[6] += m2[6]*weight; M[7] += m2[7]*weight;
		M[8] += m2[8]*weight; M[9] += m2[9]*weight;
		M[10] += m2[10]*weight; M[11] += m2[11]*weight;
		M[12] += m2[12]*weight; M[13] += m2[13]*weight;
		M[14] += m2[14]*weight; M[15] += m2[15]*weight;
	}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The .x enhancements looks interesting, I'll have to check it (or bitplane will). But what do you need the matrix ops for? They seem to be useful, but is there any need in the current example?
&#1050;&#1080;&am
Posts: 5
Joined: Fri Feb 16, 2007 10:00 am

Post by &#1050;&#1080;&am »

operator*(scalar) и operator+(matrix4) is typical matrix operations.


Threefold count of verices :shock:
it's error in CXAnimationPlayer::addFacesToBuffer

Code: Select all

 buf->Vertices.linear_reverse_search(v); 
always return -1
Last edited by &#1050;&#1080;&am on Tue Mar 06, 2007 7:05 pm, edited 4 times in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

That'S for sure, I was just asking if you need it for the enhanced .x code. I'll add the matrix methods anyway, I was just curious why you made the two things together in this post.
&#1050;&#1080;&am
Posts: 5
Joined: Fri Feb 16, 2007 10:00 am

Post by &#1050;&#1080;&am »

To fix threefold count of verices remove
irrMath.h:

Code: Select all

	inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
	{
		return (a + tolerance > b) && (a - tolerance < b);
	}
by

Code: Select all

	inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
	{
		return (a + tolerance >= b) && (a - tolerance <= b);
	}
// (-tolerance;+tolerance) -> [-tolerance;+tolerance]

------
:) max 110 FPS in Debug!
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Just made these changes it IRRspintz. There was no change in FPS after the changes....
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Anyway, it should be correct!? Although most implementations I've seen uses the strict comparisons...
Maybe the effect depends on the compiler and optimizations set. If you get some more rounding errors the comparisons might work.
&#1050;&#1080;&am
Posts: 5
Joined: Fri Feb 16, 2007 10:00 am

Post by &#1050;&#1080;&am »

It's correct. Tolerance can be 0, also rounding errors of tolerance does not influence result.

Spintz:
It depends on model (from average quantity of weights on one vertex). And uselessness of the first nulling cycle on all vertices in not a debugging mode is obvious.

P.S. I'm use VC++6.0 (SP5), DX9 SDK feb.
I test results of the optimization in a debugging mode, i.e. by the switched off machine optimization.
Post Reply