• 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
Tubos

CreateDevice D3DERR_INVALIDCALL - How to solve without debug runtime?

11 posts in this topic

Hi!

For some users of my game, CreateDevice fails with D3DERR_INVALIDCALL.

I initialize the device like this:
Windowed
DepthStencil: True, D16
Multisampling: None Quality 0
Present Flags: None
Backbuffer format: Unknown

If that doesn't work, my software tries the same parameters with software vertex processing.
If that doesn't work, it tries to initialize the device without depth buffer.

For a significant number of users, all three attempts fail.

What could cause this problem?
I cannot use the debug runtime as I have no machine where I can reproduce the problem.

I appreciate any ideas! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
* Check for device support. For example, if you want a HAL device, and D3DFMT_D16 for depthbuffer and D3DFMT_R5G6B5 for backbuffer and the device don't support them, device creation will fail.

* Check D3DPRESENT_PARAMETERS object you filled. Don't forget to zeroe the object first, then begin filling. Like this:
[code]D3DPRESENT_PARAMETERS pp;
::RtlZeroMemory (&pp, sizeof (pp));

bool _windowed = true; //I suppose
pp.AutoDepthStencilFormat = D3DFMT_D24X8;
pp.EnableAutoDepthStencil = true;
pp.BackBufferCount = 1;
pp.BackBufferFormat = D3DFMT_X8R8G8B8;
pp.BackBufferHeight = 0;
pp.BackBufferWidth = 0;
pp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
pp.FullScreen_RefreshRateInHz = 0;
pp.hDeviceWindow = 0;
pp.MultiSampleQuality = 0;
pp.MultiSampleType = D3DMULTISAMPLE_NONE;;
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pp.Windowed = _windowed;
[/code]

If you don't zeroe pp object and don't fill some members, those members will get random values (e.g. pp.MultisampleQuality = 135438734 or pp.BackBufferCount = 87684543). So, IDirect3D9::CreateDevice() will fail.

hth.
-R
1

Share this post


Link to post
Share on other sites
Can we see your device setup code? A windowed device with the backbuffer format set to D3DFMT_UNKNOWN and no Z-buffer should almost never fail.
0

Share this post


Link to post
Share on other sites
[quote]If you don't zeroe pp object and don't fill some members, those members will get random values (e.g. pp.MultisampleQuality = 135438734 or pp.BackBufferCount = 87684543). So, IDirect3D9::CreateDevice() will fail.[/quote]Sorry, I forgot to mention that this is SlimDX. I think this situation is impossible .NET, data members are always initialized.

[quote]Check for device support. For example, if you want a HAL device, and D3DFMT_D16 for depthbuffer and D3DFMT_R5G6B5 for backbuffer and the device don't support them, device creation will fail.[/quote]
The backbuffer format is D3DFMT_UNKNOWN since I'm in windowed mode. This should always work.
The depthbuffer format cannot be the reason, since the call fails even without any depthbuffer.

Here is my code:
[code]


PresentParameters parameters = new PresentParameters();
parameters.Windowed = true;
parameters.SwapEffect = SwapEffect.Discard;
parameters.BackBufferCount = 1;

if (windowed)
{
parameters.BackBufferWidth = backbufferSize.Width;
parameters.BackBufferHeight = backbufferSize.Height;
}
else
{
Rectangle screenSize = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
parameters.BackBufferWidth = screenSize.Width;
parameters.BackBufferHeight = screenSize.Height;
}

var currentDisplayFormat = Direct3D.GetAdapterDisplayMode(adapterToUse).Format;
Result result;
bool checkdeviceFormat = Direct3D.CheckDeviceFormat(adapterToUse, deviceType, currentDisplayFormat, Usage.DepthStencil, ResourceType.Surface, depthStencilFormat, out result);

// check whether 24bit is supported
// note: info from gamedev.net: you should both use CheckDeviceFormat AND CheckDepthStencilMatch
if (checkdeviceFormat && Direct3D.CheckDepthStencilMatch(adapterToUse, deviceType, currentDisplayFormat, currentDisplayFormat, depthStencilFormat))
parameters.AutoDepthStencilFormat = depthStencilFormat;
else
parameters.AutoDepthStencilFormat = Format.D16; // fallback

parameters.EnableAutoDepthStencil = true;

if (vSync)
parameters.PresentationInterval = PresentInterval.Default;
else
parameters.PresentationInterval = PresentInterval.Immediate;

parameters.BackBufferFormat = Format.Unknown; // for windowed mode, this takes the current display format.
if (multiSampling)
parameters.Multisample = MyDevice.GetMaximumMultisampleLevel(0, deviceType, parameters);


bool failure = false;
MyDevice device = null;

try
{
device = Create(adapterToUse, deviceType, control, CreateFlags.HardwareVertexProcessing | CreateFlags.FpuPreserve, parameters);
}
catch (Direct3D9Exception exc)
{ failure = true; }

if (failure)
{
failure = false;
try
{
// Hardware vertex processing not available. Trying software...
device = MyDevice.Create(adapterToUse, DeviceType.Hardware, control, CreateFlags.SoftwareVertexProcessing| CreateFlags.FpuPreserve, parameters);
}
catch (Direct3D9Exception)
{ failure = true; }

if (failure || Result.Last.IsFailure)
{
// Both hardware and vertex processing failed.
// Try it without depth buffer.
bool itWorksWithoutDepthBuffer = true;
try{
var paramWithoutDepth = parameters.Clone();
paramWithoutDepth.EnableAutoDepthStencil=false;
device=MyDevice.Create(adapterToUse, DeviceType.Hardware, control, CreateFlags.HardwareVertexProcessing, paramWithoutDepth);}
catch(Direct3D9Exception) { withoutDepthBuffer=false;}

throw new SlimException("Cannot initialize Graphics Card. Without depth buffer = "+itWorksWithoutDepthBuffer);
}
}
[/code]
Note the exception in the last line. This exception gets sent to me via the internet automatically, no matter whether the last init worked or not. So far, all error reports say "Without depth buffer = false".
0

Share this post


Link to post
Share on other sites
What are the values of vsync, multiSampling, adapterToUse, and deviceType? Using a v-sync type of anything other than "Default" and a multisampling type of anything other than "None" will fail in Windowed mode. Your adapterToUse should be whateverthe SlimDX equivalent of D3DADPATER_DEFAULT is, and deviceType should be the SlimDX equivalent of D3DDEVTYPE_HAL.
0

Share this post


Link to post
Share on other sites
The vast majority of users have this parameters:
vsync = true, PresentInterval = PresentInterval.Default
Multisampling = None, Quality 0
Present Flags = None
adapterToUse = 0. I checked the source code, this value is passed directly to DirectX. And D3DADAPTER_DEFAULT=0 in DirectX.


Overall, the problem affects about 2-4% of all users. This is quite significant and I don't think it's some random driver error.

[quote]Using a v-sync type of anything other than "Default" [..] will fail in Windowed mode.[/quote]You mean that vsync other than Default _can_ fail or _will_ fail? Because PresentInterval.Immediate works just fine on my machine in windowed mode. However, most users with the problem will have vsync=true because it's the default setting.
0

Share this post


Link to post
Share on other sites
Err - you're right, for some reason I thought it was only valid to use "default" in windowed mode. So ignore what I said about the presentation interval :)

Is there any way you can get a build to run on one of the machines that fails using a fixed set of parameters to MyDevice.Create()? So get rid of all variables and so on, and just hard code the PresentParameters and device creation flags? Just to rule out as much as possible.
1

Share this post


Link to post
Share on other sites
It might be worth making your crash reporter send you more info about their system, for example what video card do they have? What operating system?

Maybe they don't have a card that supports DX9, or don't have drivers for it?

I also noticed that the "try it without depth buffer" code uses CreateFlags.HardwareVertexProcessing. I'd go with software processing for maximum compatibility.
1

Share this post


Link to post
Share on other sites
Thanks for your excellent suggestions!

I implemented all of them to get better error reports. I'll post what I found out after receiving a few more of them.
0

Share this post


Link to post
Share on other sites
I have some results!

The users with the above problem have the following graphics cards, as reported by DirectX:
"Standard VGA Adapter": 20 users
Graphics Adapter just shows up as empty string: 7 users
Intel onboard: 6 users
Some modern graphics card (ATI or NVidia): 3 users <-- let's ignore those few.

I think "Standard VGA ADapter" could mean that no graphics card driver is installed. It might also mean that no graphics card is installed and it's just onboard.
I will probably write those users and ask them to look at their computer case and see whether there's an ATI or NVidia sticker and then install their respective graphics card driver (NVidia or ATi).

What are your thoughts on the "Standard VGA Adapter" issue? :)
0

Share this post


Link to post
Share on other sites
Generally even onboard graphics cards need some sort of driver. It's certainly possible that the graphics card they do have doesn't have the correct driver installed. The other possibility is that there is no D3D9 supporting driver available because the graphics card is ancient, or they are using a virtual machine that doesn't do 3D acceleration.

The Intel ones may simply have an out of date driver, or be such old hardware that they don't support D3D9. Same goes for the ATI and NVidia ones.

Possible code based solutions:
- Tell the user something like "Direct3D initialization failed. Make sure you have a DirectX 9 compatible graphics card and an up to date driver installed. Or contact technical support".
- If any of them are running Vista or 7 then supporting D3D11 would allow you to fix it automatically by falling back on the software renderer (WARP). This will obviously be much slower than hardware rendering though. Of course adding D3D11 support isn't a small task either.
0

Share this post


Link to post
Share on other sites
Sounds like a good idea. I will give them instructions how to get the correct graphics card driver, or to contact me.
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