Annoying problem with meshs

Started by
10 comments, last by Sheep 21 years, 8 months ago
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]
Advertisement
Try the stack trace (Alt-7).
---visit #directxdev on afternet <- not just for directx, despite the name
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]
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.
---visit #directxdev on afternet <- not just for directx, despite the name
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?
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.
---visit #directxdev on afternet <- not just for directx, despite the name
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 InstructionsMiss rate before optimization: 2.346535Miss rate after optimization: 1.402640Direct3D8: (WARN) :Indexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe.Direct3D8: (INFO) :Failed to create driver indexbufferDirect3D8: (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 52Direct3D8: (WARN) :Ignoring redundant SetRenderState 136Direct3D8: (WARN) :Ignoring redundant SetRenderState 40Direct3D8: (WARN) :Ignoring redundant SetRenderState 152Direct3D8: (WARN) :Ignoring redundant SetRenderState 151Direct3D8: (WARN) :Ignoring redundant SetRenderState 167Direct3D8: (WARN) :Ignoring redundant SetRenderState 28Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 1Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 2Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 5Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 17Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 16Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 18Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 11Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 24Direct3D8: (WARN) :Ignoring redundant SetTextureStageState Stage: 1, State: 1Direct3D8: (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]
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.
---visit #directxdev on afternet <- not just for directx, despite the name
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
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.

This topic is closed to new replies.

Advertisement