Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


E_INVALIDARG with Device.CreateWithSwapChain


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Doggeti   Members   -  Reputation: 0

Like
0Likes
Like

Posted 05 January 2012 - 05:55 PM

Hello.

I am starting with DirectX and use SlimDX. I try to set up a device and swap chain. when calling Device.CreateWithSwapChain(...) i get an Direct3D11Exception "E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)". I have tried many combinations of settings and compared my code to a couple of other examples but I cannot see what is wrong. Here is my code:


...

// create the swap chain description
swapChainDescription = new SwapChainDescription();

// set to a single back buffer
swapChainDescription.BufferCount = 1;

// create the mode description for the back buffer
modeDescription = new ModeDescription();

// set refresh rate
refreshRate = new Rational();
refreshRate.Numerator = numerator;
refreshRate.Denominator = denominator;
modeDescription.RefreshRate = refreshRate;

// set the buffer size
modeDescription.Width = form.Width;
modeDescription.Height = form.Height;

// set the scan line ordering and scaling to unspecified
modeDescription.ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified;
modeDescription.Scaling = DisplayModeScaling.Unspecified;

// set the mode description of the back buffer
swapChainDescription.ModeDescription = modeDescription;

// set the usage of the back buffer
swapChainDescription.Usage = Usage.RenderTargetOutput;

// set the handle for the window to render to
swapChainDescription.OutputHandle = form.Handle;

// turn multisampling off
sampleDescription = new SampleDescription();
sampleDescription.Count = 1;
sampleDescription.Quality = 0;
swapChainDescription.SampleDescription = sampleDescription;

// fullscreen or windowed
swapChainDescription.IsWindowed = !fullscreen;

// discard the back buffer contents after presenting
swapChainDescription.SwapEffect = SwapEffect.Discard;

// don't set the advanced flags
swapChainDescription.Flags = SwapChainFlags.None;

// create the swap chain, device and device context
FeatureLevel[] featureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0 };
if (!Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, featureLevels, swapChainDescription, out device, out swapChain).IsSuccess)
{
MessageBox.Show("Cannot create a DirectX 11 device und swap chain", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
deviceContext = device.ImmediateContext;

...

with form being a SlimDX.Windows.RenderForm, numerator = 60, denominator = 1

I am pretty lost right now and hope someone can help me with this. Thanks in advance.

Sponsor:

#2 Doggeti   Members   -  Reputation: 0

Like
0Likes
Like

Posted 08 January 2012 - 02:09 PM

My graphics card is a NVIDIA GeForce GTX 460.

Here is the stacktrace:

bei SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
bei SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
bei SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
bei SlimDX.Direct3D11.Device.CreateWithSwapChain(Adapter adapter, DriverType driverType, DeviceCreationFlags flags, FeatureLevel[] featureLevels, SwapChainDescription swapChainDescription, Device& device, SwapChain& swapChain)
bei SlimDX.Direct3D11.Device.CreateWithSwapChain(DriverType driverType, DeviceCreationFlags flags, FeatureLevel[] featureLevels, SwapChainDescription swapChainDescription, Device& device, SwapChain& swapChain)
bei ProjectName.Rendering.DirectX.Initialize(RenderForm form, Boolean vSync, Boolean fullscreen, Single screenNear, Single screenFar) in C:\Users\Name\documents\visual studio 2010\Projects\ProjectName\ProjectName\Rendering\DirectX.cs:Zeile 178.
bei ProjectName.Program.Main(String[] args) in C:\Users\Name\documents\visual studio 2010\Projects\ProjectName\ProjectName\Program.cs:Zeile 42.
bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()


#3 Evil Steve   Members   -  Reputation: 1983

Like
1Likes
Like

Posted 09 January 2012 - 03:40 AM

Try turning on the debug runtimes from the DirectX Control Panel; that should give you a more useful error message in the debug output window (Or, use DebugView) when a D3D error occurs.

Steve Macpherson
Systems Programmer

Rockstar North


#4 Doggeti   Members   -  Reputation: 0

Like
0Likes
Like

Posted 09 January 2012 - 02:34 PM

Thank you for the hint. I received these three messages in DebugView:

[556] D3D11: ERROR: ID3D11Device::CreateTexture2D: A Texture2D does not support the following Format (0, UNKNOWN). [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT ]
[556] D3D11: ERROR: ID3D11Device::CreateTexture2D: The format (0, UNKNOWN) cannot be bound as a RenderTarget, or cast to a format that could be bound as a RenderTarget. Therefore this format does not support D3D11_BIND_RENDER_TARGET. [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT ]
[556] D3D11: ERROR: ID3D11Device::CreateTexture2D: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #104: CREATETEXTURE2D_INVALIDARG_RETURN ]

I did not set the property Format in ModeDescription. Now I use Format.B8G8R8A8_UNorm and the device / swap chain creation works. Thanks soo much.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS