Sign in to follow this  
adt7

DX11 [SlimDX] Problems Creating InputLayout in DirectX 11

Recommended Posts

I'm using the MiniTri D3D11 sample that's in the repository (DX11 branch), I've updated all of the code to match the changes made since that was written and the latest SDK (Feb 2010). I'm having difficulty creating an InputLayout from the MiniTri.fx vertex shader however. Relevant code is below:
string errors;

using (D3D11.ShaderBytecode vsShaderByte = D3D11.ShaderBytecode.CompileFromFile("MiniTri.fx", "VS", "vs_4_0", SlimDX.Direct3D11.ShaderFlags.None, SlimDX.Direct3D11.EffectFlags.None, null, null, out errors))
{
    VertexShader = new SlimDX.Direct3D11.VertexShader(Device, vsShaderByte);
    D3D11.ShaderSignature s = D3D11.ShaderSignature.GetInputSignature(vsShaderByte);
    Layout = new D3D11.InputLayout(Device, s, inputElements);
}

The code breaks on the "Layout = ..." line, with the following error in my output window:
D3D11: ERROR: ID3D11Device::CreateInputLayout: Encoded Signature size doesn't match specified size. [ STATE_CREATION ERROR #161: CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE ]
Unfortunately, I don't have a clue what that means, and Google hasn't been too helpful so far either. For reference, the MiniTri.fx file is as follows:
struct VS_IN
{
	float4 pos : POSITION;
	float4 col : COLOR;
};

struct PS_IN
{
	float4 pos : SV_POSITION;
	float4 col : COLOR;
};


PS_IN VS( VS_IN input )
{
	PS_IN output = (PS_IN)0;
	
	output.pos = input.pos;
	output.col = input.col;
	
	return output;
}

float4 PS( PS_IN input ) : SV_Target
{
	return input.col;
}

technique10 Render
{
	pass P0
	{
		SetGeometryShader( 0 );
		SetVertexShader( CompileShader( vs_4_0, VS() ) );
		SetPixelShader( CompileShader( ps_4_0, PS() ) );
	}
}

[Edited by - adt7 on March 7, 2010 2:11:46 PM]

Share this post


Link to post
Share on other sites
Still no joy on this. I realise I left out the contents of the inputElements variable in my above post:

            D3D11.InputElement[] inputElements = new SlimDX.Direct3D11.InputElement[]
{
new D3D11.InputElement("POSITION",0,DXGI.Format.R32G32B32A32_Float,0,0),
new D3D11.InputElement("COLOR",0,DXGI.Format.R8G8B8A8_UNorm,16,0)
};[/lang]

Share this post


Link to post
Share on other sites
Newbie here so please beware of the advice :p.

But isn't DXGI.Format.R8G8B8A8_UNorm an integer format?
and your color is actually a float4?

Shouldn't it be DXGI.Format.R32G32B32A32_Float in your InputElements?

edit:
ie:
new D3D11.InputElement("COLOR",0,DXGI.Format.R32G32B32A32_Float,16,0)

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike.Popoloski
Does your effect file perhaps have a Unicode encoding? That always causes all sorts of strange errors to occur.


Nope. It's copied straight from the repository.

I've tried saving one out from Notepad with ANSI encoding and still the same problem.

Don't Unicode .fx files normally throw errors at compile time? Rather than when using the result of the compile?

Quote:
Original post by LostIchi
Newbie here so please beware of the advice :p.

But isn't DXGI.Format.R8G8B8A8_UNorm an integer format?
and your color is actually a float4?

Shouldn't it be DXGI.Format.R32G32B32A32_Float in your InputElements?

edit:
ie:
new D3D11.InputElement("COLOR",0,DXGI.Format.R32G32B32A32_Float,16,0)


I thought that might be a problem (not that it should be) and have tried this already, same deal.

Share this post


Link to post
Share on other sites
This is frustrating the hell out of me now.

Someone must be using DirectX 11 with SlimDX, or it must have at least been tested by the SlimDX guys.

Is there not an updated MiniTri sample for DirectX 11 out there?

How else am I meant to create a valid ShaderSignature to be used to generate an InputLayout without using the Effects framework from SlimDX.Direct3D10?

EDIT: The files I'm working with can be found here.

[Edited by - adt7 on March 8, 2010 5:16:06 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by adt7
Is there not an updated MiniTri sample for DirectX 11 out there?


Yes, it is indeed a shame that there isn't a MiniTri11 example included in the SlimDX SDK. I think its pretty essential.
I've updated MiniTri10 to work with DX11. You can find it here:

http://pastebin.com/xW21pnG4

Just use the FX file from the MiniTri10 example.

Share this post


Link to post
Share on other sites
Thanks a lot for that. Rating++.

I didn't realise that using "dummy" in the Effect constructor would allow you to compile a SlimDX.Direct11.Effect, I simply saw the parameter and figured it was the same as when compiling a Vertex Shader/Pixel Shader separately and that didn't work when I tried it.

Now to get on with some actual work!

Although this still doesn't solve the fact that the InputLayout ctor is throwing up an error with what should be valid input.

[Edited by - adt7 on March 8, 2010 9:34:20 AM]

Share this post


Link to post
Share on other sites
Apologies for bumping this again, but I'm hoping it'll catch one of the SlimDX guy's eye again.

As said already, I've started making some progress by using Effects rather than trying to produce seperate VertexShader and PixelShader objects, however, ideally, this is what I want to be able to do.

So, is there a reason why the InputLayout ctor is failing with what I assume is a valid ShaderSignature (it is produced from valid bytecode, so it should be, and no exception or errors appear on creation) from a compiled VertexShader?

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  

  • Forum Statistics

    • Total Topics
      628282
    • Total Posts
      2981805
  • Similar Content

    • By noodleBowl
      I was wondering if anyone could explain the depth buffer and the depth stencil state comparison function to me as I'm a little confused
      So I have set up a depth stencil state where the DepthFunc is set to D3D11_COMPARISON_LESS, but what am I actually comparing here? What is actually written to the buffer, the pixel that should show up in the front?
      I have these 2 quad faces, a Red Face and a Blue Face. The Blue Face is further away from the Viewer with a Z index value of -100.0f. Where the Red Face is close to the Viewer with a Z index value of 0.0f.
      When DepthFunc is set to D3D11_COMPARISON_LESS the Red Face shows up in front of the Blue Face like it should based on the Z index values. BUT if I change the DepthFunc to D3D11_COMPARISON_LESS_EQUAL the Blue Face shows in front of the Red Face. Which does not make sense to me, I would think that when the function is set to D3D11_COMPARISON_LESS_EQUAL the Red Face would still show up in front of the Blue Face as the Z index for the Red Face is still closer to the viewer
      Am I thinking of this comparison function all wrong?
      Vertex data just in case
      //Vertex date that make up the 2 faces Vertex verts[] = { //Red face Vertex(Vector4(0.0f, 0.0f, 0.0f), Color(1.0f, 0.0f, 0.0f)), Vertex(Vector4(100.0f, 100.0f, 0.0f), Color(1.0f, 0.0f, 0.0f)), Vertex(Vector4(100.0f, 0.0f, 0.0f), Color(1.0f, 0.0f, 0.0f)), Vertex(Vector4(0.0f, 0.0f, 0.0f), Color(1.0f, 0.0f, 0.0f)), Vertex(Vector4(0.0f, 100.0f, 0.0f), Color(1.0f, 0.0f, 0.0f)), Vertex(Vector4(100.0f, 100.0f, 0.0f), Color(1.0f, 0.0f, 0.0f)), //Blue face Vertex(Vector4(0.0f, 0.0f, -100.0f), Color(0.0f, 0.0f, 1.0f)), Vertex(Vector4(100.0f, 100.0f, -100.0f), Color(0.0f, 0.0f, 1.0f)), Vertex(Vector4(100.0f, 0.0f, -100.0f), Color(0.0f, 0.0f, 1.0f)), Vertex(Vector4(0.0f, 0.0f, -100.0f), Color(0.0f, 0.0f, 1.0f)), Vertex(Vector4(0.0f, 100.0f, -100.0f), Color(0.0f, 0.0f, 1.0f)), Vertex(Vector4(100.0f, 100.0f, -100.0f), Color(0.0f, 0.0f, 1.0f)), };  
    • By mellinoe
      Hi all,
      First time poster here, although I've been reading posts here for quite a while. This place has been invaluable for learning graphics programming -- thanks for a great resource!
      Right now, I'm working on a graphics abstraction layer for .NET which supports D3D11, Vulkan, and OpenGL at the moment. I have implemented most of my planned features already, and things are working well. Some remaining features that I am planning are Compute Shaders, and some flavor of read-write shader resources. At the moment, my shaders can just get simple read-only access to a uniform (or constant) buffer, a texture, or a sampler. Unfortunately, I'm having a tough time grasping the distinctions between all of the different kinds of read-write resources that are available. In D3D alone, there seem to be 5 or 6 different kinds of resources with similar but different characteristics. On top of that, I get the impression that some of them are more or less "obsoleted" by the newer kinds, and don't have much of a place in modern code. There seem to be a few pivots:
      The data source/destination (buffer or texture) Read-write or read-only Structured or unstructured (?) Ordered vs unordered (?) These are just my observations based on a lot of MSDN and OpenGL doc reading. For my library, I'm not interested in exposing every possibility to the user -- just trying to find a good "middle-ground" that can be represented cleanly across API's which is good enough for common scenarios.
      Can anyone give a sort of "overview" of the different options, and perhaps compare/contrast the concepts between Direct3D, OpenGL, and Vulkan? I'd also be very interested in hearing how other folks have abstracted these concepts in their libraries.
    • By turanszkij
      If I do a buffer update with MAP_NO_OVERWRITE or MAP_DISCARD, can I just write to the buffer after I called Unmap() on the buffer? It seems to work fine for me (Nvidia driver), but is it actually legal to do so? I have a graphics device wrapper and I don't want to expose Map/Unmap, but just have a function like void* AllocateFromRingBuffer(GPUBuffer* buffer, uint size, uint& offset); This function would just call Map on the buffer, then Unmap immediately and then return the address of the buffer. It usually does a MAP_NO_OVERWRITE, but sometimes it is a WRITE_DISCARD (when the buffer wraps around). Previously I have been using it so that the function expected the data upfront and would copy to the buffer between Map/Unmap, but now I want to extend functionality of it so that it would just return an address to write to.
    • By mister345
      Trying to write a multitexturing shader in DirectX11 - 3 textures work fine, but adding 4th gets sampled as black!
      Could you please look at the textureClass.cpp line 79? - I'm guess its D3D11_TEXTURE2D_DESC settings are wrong, 
      but no idea how to set it up right. I tried changing ArraySize from 1 to 4, but does nothing. If thats not the issue, please look
      at the LightShader_ps - maybe doing something wrong there? Otherwise, no idea.
          // Setup the description of the texture.
          textureDesc.Height = height;
          textureDesc.Width = width;
          textureDesc.MipLevels = 0;
          textureDesc.ArraySize = 1;
          textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
          textureDesc.SampleDesc.Count = 1;
          textureDesc.SampleDesc.Quality = 0;
          textureDesc.Usage = D3D11_USAGE_DEFAULT;
          textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
          textureDesc.CPUAccessFlags = 0;
          textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
      Please help, thanks.
      https://github.com/mister51213/DirectX11Engine/blob/master/DirectX11Engine/Texture.cpp
       
    • By GameDevCoder
      I have to learn DirectX for a course I am studying. This book https://www.amazon.co.uk/Introduction-3D-Game-Programming-Directx/dp/1936420228 I felt would be great for me to learn from.
      The trouble is the examples which are all offered here http://www.d3dcoder.net/d3d11.htm . They do not work for me. This is a known issue as there is a link on the examples page saying how to fix it. I'm having difficulty with doing this though. This is the page with the solution http://www.d3dcoder.net/Data/Book4/d3d11Win10.htm.
      The reason why this problem is happening, the book was released before Windows 10 was released. Now when the examples are run they need slight fixes in order for them to even work. I just can't get these examples working at all.
      Would anyone be able to help me get the examples working please. I am running Windows 10 also just to make this clear, so this is why the examples are experiencing the not so desired behaviour. I just wish they would work straight away but there seems to be issues with the examples from this book mainly because of it trying to run from a Windows 10 OS.
      On top of this, if anyone has any suggestions with how I can learn DirectX 11 i would be most grateful. Thanks very much. I really would like to get them examples working to though from the book I mentioned.
      Look forward to reading any replies this thread receives.
       
      GameDevCoder.


      PS - If anyone has noticed. I asked this about 1 year ago also but this was when I was dabbling in it. Now I am actually needing to produce some stuff with DirectX so I have to get my head round this now. I felt at the time that I sort of understood what was being written to me in response to my thread back then. I had always been a little unsure though of being absolutely sure of what was happening with these troublesome examples. So I am really just trying to get to the bottom of this now. If anyone can help me work these examples out so I can see them working then hopefully I can learn DirectX 11 from them.
       
      *SOLUTION* - I was able to get the examples running thanks to the gamedev.net community. Great work guys. I'm so please now that I can learn from this book now I have the examples running.
      https://www.gamedev.net/forums/topic/693437-i-need-to-learn-directx-the-examples-for-introduction-to-3d-programming-with-directx-11-by-frank-d-luna-does-not-work-can-anyone-help-me/?do=findComment&comment=5363013
  • Popular Now