Jump to content

  • Log In with Google      Sign In   
  • Create Account


Adding Elements ?


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
14 replies to this topic

#1 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 11 April 2013 - 07:26 PM

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.



Sponsor:

#2 unbird   Crossbones+   -  Reputation: 4969

Like
1Likes
Like

Posted 12 April 2013 - 08:07 AM

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.

#3 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 12 April 2013 - 09:54 AM

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.



#4 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 12 April 2013 - 10:39 AM


 

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, 12 April 2013 - 10:43 AM.


#5 unbird   Crossbones+   -  Reputation: 4969

Like
1Likes
Like

Posted 12 April 2013 - 10:56 AM

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, 12 April 2013 - 11:00 AM.


#6 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 12 April 2013 - 11:01 AM

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);
        }



#7 unbird   Crossbones+   -  Reputation: 4969

Like
1Likes
Like

Posted 12 April 2013 - 12:01 PM

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

 

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 ]

 

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.



#8 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 12 April 2013 - 12:21 PM

Yep, it's working now. Thank you unbird.



#9 unbird   Crossbones+   -  Reputation: 4969

Like
1Likes
Like

Posted 12 April 2013 - 12:34 PM

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

 

Maybe it's this sucker again. Cephalo had a similar problem here and successfully uninstalled that nasty update (again: at your own risk, if it's actually the problem). 



#10 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 12 April 2013 - 01:44 PM

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.



#11 unbird   Crossbones+   -  Reputation: 4969

Like
1Likes
Like

Posted 12 April 2013 - 01:51 PM

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, 12 April 2013 - 02:01 PM.


#12 siri   Members   -  Reputation: 233

Like
0Likes
Like

Posted 12 April 2013 - 02:27 PM

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.



#13 unbird   Crossbones+   -  Reputation: 4969

Like
1Likes
Like

Posted 12 April 2013 - 02:37 PM

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.

#14 siri   Members   -  Reputation: 233

Like
1Likes
Like

Posted 13 April 2013 - 03:25 PM

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



#15 unbird   Crossbones+   -  Reputation: 4969

Like
0Likes
Like

Posted 13 April 2013 - 04:02 PM

Aah, good to know this works for SlimDX, too. Thanks for the feedback.

 

Happy debugging biggrin.png






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