Sign in to follow this  
Asheh

DrawIndexPrimitive failed with DrawSubset (x loading)

Recommended Posts

D3D9 Helper: IDirect3DDevice9::DrawIndexedPrimitive failed: D3DERR_INVALIDCALL
Direct3D9: Decl Validator: X284: (Element Error) (Decl Element [3]) Declaration can't map to fixed function FVF because a usage+index pair (D3DDECLUSAGE_TANGENT,0) that is not valid for fixed function appears between two vertex elements that have usage+index pairs valid for fixed function. For a vertex declaration to map to fixed function, all individual elements that are valid for fixed function must appear contiguously starting from the first element.  Remaining elements at the end do not have to be valid for fixed function, as long as there are few enough that they can be aliased internally to texcoord(n), texcoord(n+1) etc. up to max. texcoord7 (thereby appearing to conform to an FVF, although the aliased values should not be used). 
Direct3D9: (ERROR) :DrawIndexedPrimitive failed.

When i try to load and render a .x file i get the above errors every time i render it. Obviously I dont call DrawIndexedPrimitive, so its somthing to do with drawsubset, any ideas?
bool CGfxEntity_Model::Render(CRenderer *pRenderer)
{
	for (DWORD i=0; i < mNumMaterials; i++)
	{
		pRenderer->GetDevice()->SetMaterial(&mMeshMaterials[i]);
		pRenderer->GetDevice()->SetTexture(0,mMeshTextures[i]);
		mMesh->DrawSubset( i );
	}

	return true;
}


Ash.

Share this post


Link to post
Share on other sites
DrawSubset() basically maps to a DrawIndexedPrimitive() call (with a bit of additional management code). So yes, you do actually call it - just indirectly [smile]

The error message is fairly self explanatory really. You're passing per-vertex attributes that are invalid for your chosen render path. Basically you need to choose to downgrade your vertex to be 'pure' Fixed Function or upgrade your render-path to use a vertex shader. The latter part of the message about using texcoord's to alias is useful if you want the same vertex data to go down both paths and need the FF to just ignore the stuff that it can't use...

hth
Jack

Share this post


Link to post
Share on other sites
According to your error message:


X284: (Element Error) (Decl Element [3])
Declaration can't map to fixed function FVF because a usage+index pair
(D3DDECLUSAGE_TANGENT,0) that is not valid for fixed function appears
between two vertex elements that have usage+index pairs valid for fixed
function. For a vertex declaration to map to fixed function, all individual
elements that are valid for fixed function must appear contiguously starting
from the first element. Remaining elements at the end do not have to be valid
for fixed function, as long as there are few enough that they can be aliased
internally to texcoord(n), texcoord(n+1) etc. up to max. texcoord7 (thereby
appearing to conform to an FVF, although the aliased values should not be used).


your mesh contains data about the vertex tangents. This vertex property apparently is not supported by the fixed function pipeline. Reading further in the error message (I'd wish I'd get such verbose error messages as this one [smile]), this is no problem is itself, but D3D sees that the declaration does define properties it can handle after this tangent element. That's what it complains about, since it seems to require that all elements it supports (position normal, uv etc) are defined contiguously before any unsupported element are defined (with a maximum of 8 ignored unsupported elements). So basically your vertex declaration looks like this:


- supported element
- supported element
* unsupported tangent
- supported element

while the FVF/fixed function pipeline requires it to look like this:


- supported element
- supported element
- supported element
* unsupported tangent


Now, as for how to fix this, you basically have 3 options:

- Use a HLSL effect/shader for your rendering
- Remove the tangent definition from the model in your modelling packages
- Write code to re-arrange or remove the tangent element


If you're not going to use the tangent information, the last option is probably just a waste of time. Now, if you want to use the tangent information (for normal mapping for example), biting the bullet and switching to shaders is probably the best way to go. If you don't need the tangent anyway, your modelling package should allow you to customize the export settings so it doesn't save out this data and it doesn't show up in the vertex declaration.

Hope this helps :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this