• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Spidey

D3D9 CreateDevice crash with D3DCREATE_HARDWARE_VERTEXPROCESSING

8 posts in this topic

Hi,

 

I'm seeing a crash inside CreateDevice in an old code base when initializing a d3d device with the D3DCREATE_HARDWARE_VERTEXPROCESSING flag. The d3d initialization is contained in its own thread which is contained in a native dll being called from managed code. I am able to run with D3DCREATE_SOFTWARE_VERTEXPROCESSING or D3DCREATE_MIXED_VERTEXPROCESSING but D3DCREATE_HARDWARE_VERTEXPROCESSING always crashes inside CreateDevice. These flags are always OR'd with D3DCREATE_MULTITHREADED.

 

There are no error messages returned as the code crashes inside the function. Sometimes in gdi32.dll (and a few times in nvd3dum.dll). It is always a stack overflow exception caught by a chckstck in the thread running the dll. I don't have source for these so don't know whats going on. I'm on the latest NVIDIA drivers and have tried both debug and release d3d9 runtimes (Note: This used to work on older/last year's drivers).

 

I know the card (GTX 460 SE) supports hardware vertex processing and I am able to get the code with the same creation parameters to work inside the d3d sample demo app. I tried increasing the thread stack size from the default 1mb on windows but this had no effect on the crash either.

 

Anyone seen anything like this before or know what could be causing this ? or anything else I can do to track the problem ?

 

Thanks!

 

0

Share this post


Link to post
Share on other sites

Did you anyway (even if you know the card should support HW vertex processing) try to verify it by checking for D3DDEVCAPS_HWTRANSFORMANDLIGHT in GetDeviceCaps? Just for sure ;)

0

Share this post


Link to post
Share on other sites

Thanks for the suggestion. Yup, just tried it:

D3DCAPS9 Caps;
sys->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &Caps);
if( Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT )
     return true
return false;

returns true.

 

What is D3DCREATE_HARDWARE_VERTEXPROCESSING anyway ? Does this mean the entire geometry stage (vertex fetch, vertex shader etc) runs in software or just the old fixed function stages ? I can even get it to work with D3DCREATE_MIXED_VERTEXPROCESSING which makes the CPU run a lot faster so I'm assuming its doing all the heavy lifting on the gpu. I just don't know why its crashing with D3DCREATE_HARDWARE_VERTEXPROCESSING. 

0

Share this post


Link to post
Share on other sites

Hm that's a good question :) I also don't know what exactly does HARDWARE_VERTEXPROCESSING include. Vertex transformations and fixed-function lighting for sure, that's the good old HW T&L, I remember when this came out and some games then started to require GPUs capable of it :)

Probably if you use D3DCREATE_SOFTWARE_VERTEXPROCESSING with a vertex shader, then the shader is executed on the CPU?

0

Share this post


Link to post
Share on other sites

Yeah, that's what I'm assuming. Software VP would mean vertex shader emulated on the CPU whereas mixed picks hardware if it can otherwise fall backs to software ?

 

Maybe that's why it fixed my crash, by delaying some initialization to happen sometime later which causes the crash to not happen.

0

Share this post


Link to post
Share on other sites

If you are getting a stack overflow, increase the size of the stack.

-2

Share this post


Link to post
Share on other sites

If you are getting a stack overflow, increase the size of the stack.

 

And then the next time you get an overflow you'll also increase it, and you'll find youself in an arms race with your code.

 

Better to find out what's causing the overflow and fix it, such as by running your code in a debugger, which will break on the overflow and let you see the call stack, inspect variables, etc in order to determine the cause.

 

OP - you've determined that the overflow happens inside either GDI or a driver DLL; that doesn't mean that they're the direct cause of this bug (otherwise it would affect every program) - far more likely is that you've built up such a huge stack in your own code that by the time it comes to call into these it's triggering the overflow.  The fix is to not build up such a huge stack in your own code.

 

Two common causes of stack overflows are recursion gone wild or declaring excessively large local variables.  For example, declaring "float stuff[512 * 512]" as a local variable will cause a stack overflow with the default 1mb stack.  I'd advise that you check your code up to device creation point for these two.

 

A third possible cause is passing large structs by value, but that's less frequently seen as most people know that they should be passed by reference or const reference.

 

So the first thing to do is set a breakpoint on the first line of your device creation function, run in the debugger, see the call stack up to that point, and check the functions in that call stack for anything that may be contributing to excessive stack usage.

1

Share this post


Link to post
Share on other sites

Thanks for the reply mhagain. I did take a quick look and the code around the device creation looked ok, but I'll check again ( I also tried increasing the thread stack just as a test but I still got the crash, so I was thinking something might just be blowing the stack somewhere (infinite recursion, or huge allocation on the stack) ). Yeah, I'm assuming the fault is in our code and not in the drivers. I got the sample app to work correctly, however I haven't tried spawning a thread from a native dll called from managed code and creating a device from there yet.

 

I was curious if the CreateDevice function might have some callbacks into user code ? If so, what would these callbacks be. for eg: the d3dxeffect system has user callbacks which get called from inside the d3d dll's. Maybe create device is calling such a callback which is causing the stack overflow. If so what kind of usage would trigger a callback from inside CreateDevice ? I can't step into this function so I'm not sure how to find out.

0

Share this post


Link to post
Share on other sites

actually its probably not a callback blowing the stack as I would see it in the callstack, still could be a stomp though.

0

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  
Followers 0