Sign in to follow this  
Graham

Terrain no longer renders when using debug libraries

Recommended Posts

My terrain renders fine when Im using the retail version of D3D. When I go to the control panel and switch to debug, other things render but the terrain does not. I get the following debug output. Direct3D9: (ERROR) :Current vertex shader declaration doesn't match VB's FVF Direct3D9: (ERROR) :DrawPrimitive failed. I am not using any vertex shaders.This is my vertex: struct VertexTex2 { float x, y, z; float tu, tv; float tu2, tv2; }; #define D3DFVF_VertexTex2 ( D3DFVF_XYZ|D3DFVF_TEX2) And where I get ready to Draw: Graphics.m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(VertexTex2)); Graphics.m_pd3dDevice->SetFVF(D3DFVF_VertexTex2); Anyone know how I go about fixing this.

Share this post


Link to post
Share on other sites
Quote:
Original post by Graham
And where I get ready to Draw:
Graphics.m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(VertexTex2));
Graphics.m_pd3dDevice->SetFVF(D3DFVF_VertexTex2);

Anyone know how I go about fixing this.


What is the FVF format used when m_pVB is created?

Share this post


Link to post
Share on other sites
Your right thats where the error was. Wierd that it worked fine on retail.

It was:

// Create the vertex buffer.
if( FAILED( Graphics.m_pd3dDevice->CreateVertexBuffer( m_zCells*(m_xCells+1)*2*sizeof(VertexTex2),
0, D3DFVF_Vertex, D3DPOOL_MANAGED, &m_pVB, NULL ) ) )
{
return E_FAIL;
}



And I changed it to:

// Create the vertex buffer.
if( FAILED( Graphics.m_pd3dDevice->CreateVertexBuffer( m_zCells*(m_xCells+1)*2*sizeof(VertexTex2),
0, D3DFVF_VertexTex2, D3DPOOL_MANAGED, &m_pVB, NULL ) ) )
{
return E_FAIL;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by Graham
Wierd that it worked fine on retail.

I've seen some similar things happen before... I always put it down to having a very tolerant driver [smile] That is, it would automagically correct what you were doing by assuming that you actually meant the correct FVF..

Little things like this make graphics programming full of excitement - and also why it's often worth running against the debug runtime [grin]

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by Graham
Wierd that it worked fine on retail.


The debug D3D runtime checks & validates a ton of things (such as the FVF) before handing them off to the graphics device driver. If there's a problem with what you pass, D3D will produce an error rather than passing the bad data to the device driver.

With the retail D3D runtime, it's assumed the code making the calls to D3D is free of errors, so most of those debug validation checks aren't done and the data/parameters you passed to the API is handed straight to the driver regardless of whether or not they're right.

Drivers for some graphics cards don't need all of what the D3D API passes to them to be able to get the job done - for example some don't really care about the format the VB was created in, all they care about is the FVF specified when you come to draw some primitives and the fact that the VB is a chunk of memory with a specific stride; in that case, the driver for your card probably doesn't even bother checking the FVF used to create the VB and happily uses the data. Even if the data was blatantly wrong, the graphics hardware and driver don't really have many ways to complain.

The reason you should always aim for 0 errors with the debug runtime before using the retail runtime, *even when things seem to render correctly*, is some drivers do require all of the data D3D pass to them, so although a particular thing like a mismatched FVF might work on your graphics card, it might fail miserably (or just run slow or look wrong) on somebody elses graphics card.


[EDIT: too late, heh, what Jack more concisely said [smile]]

[Edited by - S1CA on June 2, 2005 4:18:08 PM]

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