Texture transform crashes with vertex shaders in D3D

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.
Post Reply
Piraaate
Posts: 18
Joined: Wed Feb 21, 2007 3:04 pm
Location: Valence, France
Contact:

Texture transform crashes with vertex shaders in D3D

Post by Piraaate »

Hi guys, I ran into a crash(or at least blank screen) when using programmable pipeline with D3D(OGL was working fine).

The D3D debug drivers gave me this explanation:
Direct3D9: (ERROR) :Stage 0 - Count in D3DTSS_TEXTURETRANSFORMFLAGS must be 0 when programmable pipeline is used

I found it amusing to see the bug elsewhere (here) and it made me think that it was happening only on certain configurations.

In order to fix it I changed the setMaterial bit of code into this:

Code: Select all

//! sets a material
void CD3D9Driver::setMaterial(const SMaterial& material)
{
	Material = material;

	bool bEnableTransform = Material.MaterialType < (s32)MaterialRenderers.size();

	for (u32 i=0; i<MaxTextureUnits; ++i)
	{
		setTexture(i, Material.getTexture(i));
		if(bEnableTransform)
			setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), material.getTextureMatrix(i));
		else
			pID3DDevice->SetTextureStageState( i, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
	}
}
Of course if you want texture transformations anyway you'll have to do it directly into your vertex shader. Anyone think of another possible patch ? Otherwise I'll update it to the database...
Post Reply