Page 1 of 1

Texture transform crashes with vertex shaders in D3D

Posted: Wed Oct 29, 2008 9:52 am
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...