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

Adding Elements ?

14 posts in this topic

Hello,

 

I've spent the day getting a triangle to render in SlimDX and reading up on things. It was all going well until I tried to make the shader a little more complex. I just want to add a per-vertex colour. But when I did my vertex layout broke and I'm not sure why. The exception being thrown is the following:

 

 

 
An unhandled exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
 
Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)

 

I managed to find a thread that seems related: http://www.gamedev.net/topic/607455-slimdx-directx11-inputlayout-failure/

 

I'm not sure if that really helps or not as I don't fully understand it. He seems to be passing his DataStream as the signature which I'm not doing( Or if I am it's in such a way that I don't realise I am. ). I'm using the ShaderByteCode from the vertex program. This all worked for a triangle with only positional data being sent. It breaks on the Layout creation line.

 

 

 
            var elements = new[] { new DX.InputElement("POSITION", 0, GI.Format.R32G32B32_Float, 0),
                                   new DX.InputElement("COLOR", 0, GI.Format.R32G32B32A32_Float, DX.InputElement.AppendAligned)
            };
 
//Breaks on this line.
            VertexLayout = new DX.InputLayout(CoreComponents.mVideo.mDevice, HLSL.ShaderSignature.GetInputSignature(VPByte), elements);

 

The shader looks like this:

 

 

 
struct a2v {
float3 p : POSITION;
float4 c : COLOR0;
};
 
struct v2f {
float4 p : SV_POSITION;
float4 c : TEXCOORD0;
};
 
v2f vp(a2v a2vin) {
v2f v2fout;
 
v2fout.p  = float4(a2vin.p, 1);
v2fout.c  = a2vin.c;
 
return v2fout;
}
 
float4 fp(v2f v2fin): SV_TARGET {
return v2fin.c;
}

 

Any help or advice would be appreciated. Thank you.

0

Share this post


Link to post
Share on other sites
From a quick glance your code looks fine, so the problem might originate from elsewhere. Use D3D11_CREATE_DEVICE_DEBUG to get more information about why that call fails. Depending on what IDE you use (e.g. VS 2010 Express does not support native code debugging), you also want to install DebugView to grab the debug messages.
1

Share this post


Link to post
Share on other sites

From a quick glance your code looks fine, so the problem might originate from elsewhere. Use D3D11_CREATE_DEVICE_DEBUG to get more information about why that call fails. Depending on what IDE you use (e.g. VS 2010 Express does not support native code debugging), you also want to install DebugView to grab the debug messages.

 

Thanks unbird, I'll give those suggestions a try and get back.

0

Share this post


Link to post
Share on other sites

 

DebugView gives me the following output.

 

[5956] 
[5956] *** HR originated: -2147024774
[5956] ***   Source File: d:\iso_whid\x86fre\base\isolation\com\copyout.cpp, line 1391
[5956] 
[5956] 
[5956] *** HR propagated: -2147024774
[5956] ***   Source File: d:\iso_whid\x86fre\base\isolation\com\identityauthority.cpp, line 278
[5956] 
 
I've changed my vertex program as I think the problem is that the elements don't match the signature. But it's still throwing the same exception.
 
struct v2f {
float4 p : SV_POSITION;
float4 c : COLOR;
};
 
v2f vp(float3 p : POSITION,
float4 c : COLOR) {
v2f v2fout;
 
v2fout.p  = float4(p, 1);
v2fout.c  = c;
 
return v2fout;
}
 
Adding the debug flag to the device creation doesn't seem to help( I'm not entirely sure what I'm looking for ). The output is the same.
 

A first chance exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
An unhandled exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)
Edited by siri
0

Share this post


Link to post
Share on other sites
You should get more info than that, I think. Did the device creation succeed with that flag ? If yes, post some more of your code: How you load your shader, how you compile, etc.

Edit, ah sorry for being stupid: In SlimDX the debug flag is of course DeviceCreationFlags.Debug. Edited by unbird
1

Share this post


Link to post
Share on other sites

You should get more info than that, I think. Did the device creation succeed with that flag ? If yes, post some more of your code: How you load your shader, how you compile, etc.

 

I'm doing things pretty much the way the SlimDX tutorial did.

 

// Device creation.
 
            var desc = new SwapChainDescription()
            {
                BufferCount       = 1,
                Usage             = Usage.RenderTargetOutput,
                OutputHandle      = hHandle,
                IsWindowed        = bWindowed,
                ModeDescription   = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags             = SwapChainFlags.AllowModeSwitch,
                SwapEffect        = SwapEffect.Discard
            };
 
            SlimDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug, desc, out mDevice, out mSwapChain);
 
// Shaders.


        public void CreateVertexProgram(String strFilename, String strEntry, String strTarget) {
            VPByte        = HLSL.ShaderBytecode.CompileFromFile(strFilename, strEntry, strTarget, HLSL.ShaderFlags.Debug, HLSL.EffectFlags.None);
            VertexProgram = new DX.VertexShader(CoreComponents.mVideo.mDevice, VPByte);
        }
 
        public void CreateFragmentProgram(String strFilename, String strEntry, String strTarget) {
            FPByte          = HLSL.ShaderBytecode.CompileFromFile(strFilename, strEntry, strTarget, HLSL.ShaderFlags.None, HLSL.EffectFlags.None);
            FragmentProgram = new DX.PixelShader(CoreComponents.mVideo.mDevice, FPByte);
        }

0

Share this post


Link to post
Share on other sites

I tried your code and found the bug. The debug layer does actually tell me the problem:

 

[tt]D3D11: ERROR: ID3D11Device::CreateInputLayout: Element[1]'s slot (-1) too high.  Max slot index for current feature level is 15. [ STATE_CREATION ERROR #154: CREATEINPUTLAYOUT_INVALIDSLOT ][/tt]

 

You're using InputElement wrong: The last entry in that particular constructor is the slot number, not the offset. That overload actually uses InputElement.AppendAligned per default. This works:

 

var elements = new[] {
  new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0),
  new InputElement("COLOR", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 0)
};

 

I wonder why you don't get proper debug messages.

1

Share this post


Link to post
Share on other sites

You're welcome. But I really recommend getting the debug messages working - you can't sensibly develop without them.

 

Maybe it's [url="http://www.gamedev.net/topic/639532-d3d11createdevice-failed/"]this sucker again[/url]. Cephalo had a similar problem [url="http://www.gamedev.net/topic/641267-debugging-dx11-shaders-as-a-hobbyist/"] here and successfully uninstalled that nasty update[/url] (again: at your own risk, if it's actually the problem). 

1

Share this post


Link to post
Share on other sites

It's not failing but I'm not seeing any DX debug output. I am using VS2012 and Windows 8 so I assume I'm covered there. Do I need to turn it on ? -- I remember something about DX9 needing a checkbox ticked somewhere in order to get debug output.

0

Share this post


Link to post
Share on other sites
Ok, I still use VS 2010 (Express). VS 2012 seems to support native code debugging, even Express (s. here). It's for SharpDX but should apply to SlimDX too, hopefully. In that case you might ditch DebugView completely, since the messages should appear in the VS debug log.

Edit: The control panel still exists (it's the same for all DirectX stuff, not only graphics), but instead of a simple checkbox you explicitly select the application you want messages from. Can't confirm that it works, I always use the creation flag. Also: Not sure if that tool still comes with the newest DX SDK, I still haven't installed it. Edited by unbird
1

Share this post


Link to post
Share on other sites

I added it to the list, though I think the cp might be from the June SDK I have installed, still no output. I also installed the remote debugger but that didn't help either.

0

Share this post


Link to post
Share on other sites
Then I'm out of clues, sorry. Hopefully, someone else can help now.

But since you seem to just starting with D3D programming, you might give SharpDX a shot.
1

Share this post


Link to post
Share on other sites

Got it, solution: Open the solution properties, hit debug and ensure "Enable Native Code Debugging" is checked. 

1

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