Archived

This topic is now archived and is closed to further replies.

Sheep

Annoying problem with meshs

Recommended Posts

Sheep    152
Hello everyone. I had given up on models for a while, but decided to go at it again. I made an object class which inherited from microsofts CD3DMesh class. However, when I run my program, I get an access violation in Test.exe. I am extremely confused because the debugger gives me no information at all. Any ideas on where to look for the problem? I get the error when I call the Create() method, so I am assuming that the problem is there, but I cant pinpoint anything. I am not asking for any answer but rather how to go around debugging this. Thanks. [edited by - Sheep on June 8, 2002 7:04:22 PM]

Share this post


Link to post
Share on other sites
Sheep    152
Hmmm...what exactly am I looking for in the trace stack? It looks like all the functions I am calling. In any case, it looks pretty cool

[edited by - Sheep on June 8, 2002 6:19:51 PM]

Share this post


Link to post
Share on other sites
IndirectX    122
You''re looking for your function that causes the segfault. Hit enter on the uppermost such function. Then, use variables and watch windows (Alt-4 & Alt-3) to examine variable values. You can also point your mouse to a variable, and its value will be displayed as a tooltip.

Also make sure you''re using the debug runtime.

Share this post


Link to post
Share on other sites
Sheep    152
Using the variable watch, I noticed that the device being passed into my Create() function is red instead of black (the color of the variable in the little watch window). Could this be the source of the problem?

Share this post


Link to post
Share on other sites
IndirectX    122
Red color indicates that the value has changed from the last time it was displayed. For instance:

int x = 10;
int y = 20;
// x will be black now, because the last instruction didn''t change it
x = 11;
// x will be red now, because the last instruction did change it

You should look for uninitialized variables, out-of-range indices, strange variable values, etc.

A predefined variable ''err'' will give you the GetLastError value, which you can look up in winerror.h header file. This is useful if you have a failing Win32 call.

Share this post


Link to post
Share on other sites
Sheep    152
Well, I rewrote the object class and the error went away. wierd. However, now I have another problem. The mesh wasn't drawing, so I assumed that it was some stupid little problem, but after I checked the debugger, I got this:


  
D3DX: (INFO) Using SSE2 Instructions
Miss rate before optimization: 2.346535
Miss rate after optimization: 1.402640
Direct3D8: (WARN) :Indexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe.
Direct3D8: (INFO) :Failed to create driver indexbuffer
Direct3D8: (WARN) :Vertexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe.
Direct3D8: (WARN) :Ignoring redundant SetRenderState 8




followed by thousands of these assorted warnings:


  
Direct3D8: (WARN) :Ignoring redundant SetRenderState 52

Direct3D8: (WARN) :Ignoring redundant SetRenderState 136

Direct3D8: (WARN) :Ignoring redundant SetRenderState 40

Direct3D8: (WARN) :Ignoring redundant SetRenderState 152

Direct3D8: (WARN) :Ignoring redundant SetRenderState 151

Direct3D8: (WARN) :Ignoring redundant SetRenderState 167

Direct3D8: (WARN) :Ignoring redundant SetRenderState 28

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 1

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 2

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 5

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 17

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 16

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 18

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 11

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 24

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 1, State: 1

Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 1, State: 4



[edited by - Sheep on June 9, 2002 9:11:45 PM]

[edited by - jim adams on June 9, 2002 11:03:51 PM]

Share this post


Link to post
Share on other sites
IndirectX    122
quote:
Original post by Anonymous Poster
(as stated by inderectX)...


You can''t even spell my handle right, and I don''t like people who can''t copy and paste it if their memory is too short-lived. As for the rest of your post, there are languages (Russian being one) in which you spell almost the same way you speak, so, tough luck for you, the ever-present Anonymous Poster.

Sheep: the warnings mean that you, or some other code, is trying to SetRenderState or SetTextureStageState that has already been set. It''s redundant and wastes some CPU cycles. I wouldn''t worry about them right now, because most of the warnings probably aren''t in your code anyway.

The POOL_DEFAULT and WRITEONLY warning is something you should pay attention to. Basically, if a buffer is created in video memory then reads from it will be very slow. You set WRITEONLY flag to tell D3D that you don''t intend on reading from the buffer, which will allow D3D to optimize its usage and enforce your assertion (for instance, when you execute Lock(), you will be given read-only memory and if you try to write it your code will fail). Usually if you want to have read access you specify SYSTEMMEM flag to put your mesh in system memory, modify it, and then CloneMesh it with WRITEONLY flag, which may place the resulting mesh in video memory.

Share this post


Link to post
Share on other sites
Jim Adams    440
EXCUSE ME - this forum is for DirectX discussion - not English and grammar lessons or whatever this thread spun way off into . All inappropriate messages deleted.

On Topic -

You might want to try using managed memory pools as well, as it allows you to access memory, while allowing the driver to best place the resources into video memory as it needs them. The SDK recommends using managed memory pools.



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

Share this post


Link to post
Share on other sites
Sheep    152
Well, I still haven''t gotten it to work, so I guess I will just rewrite everything tomorrow. Thanks alot for the info about memory pools along with the debugging tips.

Share this post


Link to post
Share on other sites
Sheep    152
Argh. Still no luck. The mesh draws, but I am totally at loss about why I get the VB + IB creation errors. I am not directly handling them, but instead I am letting the CD3DMesh class handle everything. I thought I could use that class to get meshes up quickly, but I guess not...

[edited by - Sheep on June 13, 2002 7:53:35 PM]

Share this post


Link to post
Share on other sites
wazoo69    157
I thought I''d bump this one up, as I''m experiencing the same thing..

I saw the same debug spew as posted above, and so in the DXFile.cpp, in the Mesh class, check the SetFVF function.

I got the errors to disappear if I modified the clone of the
mesh fvf


  
if( m_pSysMemMesh )
{
if( FAILED( m_pSysMemMesh->CloneMeshFVF
(D3DXMESH_SYSTEMMEM | D3DXMESH_WRITEONLY,
dwFVF,
pd3dDevice,
&pTempSysMemMesh ) ) )
return E_FAIL;
}


My only problem is that when I recompiled the "Donuts3D" sample, the terrain disappears..

oops!

hth,

Share this post


Link to post
Share on other sites