Sign in to follow this  
e5431

DX10: CDXUTSDKMesh::Render bug???

Recommended Posts

e5431    122

Hello.

Tried to render a mesh using its default method. It works fine until you add text rendering using CDXUTTextHelper...At first I thought that I did something wrong, I took Tutorial 10 and changed it a bit. Well, the problem persists.

I left the following rendering calls in OnD3D10FrameRender():

//the mesh class also had a render method that allows rendering the mesh with the most common options g_Mesh.Render( pd3dDevice, g_pTechnique, g_ptxDiffuseVariable ); g_HUD.OnRender( fElapsedTime ); g_SampleUI.OnRender( fElapsedTime ); RenderText();

So, it resulted in the following picture:

we can see that it is dark and the mesh looks corrupted and no texture mapping is performed... Close-up of the head:

Well, lets comment out RenderText() function:

//the mesh class also had a render method that allows rendering the mesh with the most common options g_Mesh.Render( pd3dDevice, g_pTechnique, g_ptxDiffuseVariable ); // Render the UI g_HUD.OnRender( fElapsedTime ); g_SampleUI.OnRender( fElapsedTime ); //RenderText();

And the result is the following image:

Isn't the difference obvious? The same frame, different look! :)

I wanted to ask: is there any way to fix it?

Share this post


Link to post
Share on other sites
Supernat02    604
I would guess that your render state or texture stage setup for rendering Tiny is just using defaults, but the text render changes a state. You may just need to define the render states specifically before rendering Tiny.

Share this post


Link to post
Share on other sites
e5431    122
Thanks for replies to everyone !

colinolivant: it's the same as in the Tutorial, nothing special or exotic, IMHO:
//-------------------------------------------------------------------------
// Render the help and statistics text
//-------------------------------------------------------------------------
void RenderText()
{
g_pTxtHelper->Begin();
g_pTxtHelper->SetInsertionPos( 2, 0 );
g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );
g_pTxtHelper->End();
}

51mon:
Yes, of course vertex layout is set, it is a tutorial code. ;) I've just changed mesh rendering part.

Supernat02:
Thanks. I will give it a try..

Share this post


Link to post
Share on other sites
jollyjeffers    1570
You should check using PIX - use D3DPERF_SetMarker() and do a single-frame capture. Compare the pipeline state before/after and you should be able to determine if a state is leaking.

I forget the details, but there were some changes to ID3DXFont that buggered stuff up recently - to the extent that you needed to put a DepthStencilState object directly into FX files as the DXUT framework disabled depth buffering ([oh]).

hth
Jack

Share this post


Link to post
Share on other sites
e5431    122
51mon:

You were right. :)
I accidetly commented out the line where vertex layout was set.
So, the bug was in my braunware :) Feeling so stupid now...
Thank you very much.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Quote:
Original post by e5431
why do we have to set vertex layout every frame?
You don't. All you need to do is ensure that the pipeline is configured correctly when a Draw() call is issued. Removing redundant state changes is a simple and common optimization - if you can guarantee the vertex layout never changes then yes, you can skip re-setting it.

hth
Jack

Share this post


Link to post
Share on other sites
e5431    122
Well how to ensure correct pipeline configuration when working with DXUT?
DXUT samples call
pd3dDevice->IASetInputLayout( g_pVertexLayout );
every frame..

Share this post


Link to post
Share on other sites
MinkyMead    122
that DXUT text helper changes the vertex layout and sets the primitive topology to pointlists or something, so you have to change back to whatever your mesh rendering needs after using it. i had the same problem

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Quote:
Original post by e5431
Well how to ensure correct pipeline configuration when working with DXUT?
You don't. DXUT might be open-source but it's still seperate 3rd party code that you don't necessarily have control over.

If you cannot guarantee that the state remains the same because of some 3rd party function you need to take steps to ensure that you re-configure accordingly. Either by re-setting everything or by using some state manager or state block library...

hth
Jack

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