Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am developping an application using SharpDX and on one of my machines the call

_swapChain = new SwapChain(factory, _device, desc);

fails with the error message

HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: Unknown

When I googled the error I found this where it states:

DXGI_ERROR_INVALID_CALL (0x887A0001)

The application provided invalid parameter data; this must be debugged and fixed before the application is released.

But how?

The error message does not give me any indication whatsoever to why the creation failed.

I checked the debug layer output but that only shows Info. No Warning, no Error, nothing. The factory and the device are created just fine and I tried several combinations of parameters in my SwapChainDescription but the error always remains the same.

How am I supposed to find out what triggers the error?

Just to be clear: I am not so much looking for a solution for my specific problem as I am wondering how I would go about debugging such a problem in general.

This is the boiled down code:

const int MAXFPS = 60;
const Format PIXELFORMAT = Format.R8G8B8A8_UNorm;

// Create device
_device = new Device(DriverType.Hardware, DeviceCreationFlags.None); // Or DeviceCreationFlags.Debug

// SwapChain description
var desc = new SwapChainDescription()
{
    BufferCount = 2, // I tried 1 too
    ModeDescription = new ModeDescription(_renderSize.Width, _renderSize.Height,
                                          new Rational(MAXFPS, 1), PIXELFORMAT),
    IsWindowed = true,
    OutputHandle = _hwnd,
    SampleDescription = _samples,
    SwapEffect = SwapEffect.Discard,
    Usage = Usage.RenderTargetOutput
};

// Create SwapChain
var factory = new SharpDX.DXGI.Factory();
_swapChain = new SwapChain(factory, _device, desc);

I confirmed the sample description is valid using

_device.CheckMultisampleQualityLevels(PIXELFORMAT, _samples.Count) > _samples.Quality

(though, those are 1 and 0 anyway), that the format is supported using

_device.CheckFormatSupport(PIXELFORMAT).HasFlag(FormatSupport.RenderTarget)

and also checked that

_hwnd != IntPtr.Zero
_renderSize.Width > 0
_renderSize.Height > 0

What else to check?


Update: I was able to fix the problem following the advice from here:

I changed this

Device device = new Device(DriverType.Hardware, DeviceCreationFlags.None);
Factory factory = new Factory();
SwapChain swapChain = new SwapChain(factory, device, desc);

to

Factory factory = new Factory();
var adapter = factory.GetAdapter(0);
Device device = new Device(adapter, DeviceCreationFlags.None);
SwapChain swapChain = new SwapChain(factory, device, desc);
share|improve this question

1 Answer 1

up vote 1 down vote accepted

This typically happens when calling a D3D function with an invalid parameter (e.g. a NULL pointer where not permitted). This is exactly what the SwapChain's constructor documentation says:

InvalidCallException The method call is invalid. For example, a method's parameter might contain an invalid value.

You need to check one by one the parameters you provide to this function, especially in this case you need to check that the present parameters you provide are correct (see the C++ doc for those, it's providing lots of details).

In your case, as it's failing on one specific machine, you're probably asking for stuff that isn't supported by its hardware, e.g. a D3D feature level too high for the graphics chip.

It sometimes help to check the samples provided by Microsoft to check what parameters they're passing, and see the differences that could cause the issue.

share|improve this answer
    
I checked the debug layer output and that it doesn't show any warnings or errors (I already said that in my question). –  Roman Reiner Mar 7 '14 at 8:48
    
@RomanReiner Erf, my bad, I missed that part :) So what's the desc you're passing to the SwapChain ctor? –  Laurent Couvidou Mar 7 '14 at 10:49
    
I updated my question with code. –  Roman Reiner Mar 13 '14 at 8:09
    
@RomandReiner Maybe it's the resolution? SharpDX says to provide values of zero to force using the window resolution. You could also try doing the same thing with "native" DirectX, maybe you're facing an issue with SharpDX itself. –  Laurent Couvidou Mar 13 '14 at 8:42
    
Thank you, those links are great! Much more useful than the SharpDX "documentation". However, those are for DirectX9. For DirectX11 the docs can be found here: msdn.microsoft.com/en-us/library/windows/desktop/… and for SwapChainDescription: msdn.microsoft.com/en-us/library/windows/desktop/…. If you add those links to your answer I will mark it as accepted! –  Roman Reiner Mar 18 '14 at 15:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.