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

E_INVALIDARG with Device.CreateWithSwapChain

3 posts in this topic

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:


[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;

...
[/CODE]

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

Share this post


Link to post
Share on other sites
My graphics card is a NVIDIA GeForce GTX 460.

Here is the stacktrace:

[CODE]
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()
[/CODE]
0

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites
Thank you for the hint. I received these three messages in DebugView:

[CODE]
[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 ][/CODE]

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.
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