Sign in to follow this  
BattleMetalChris

[DX10] What's wrong with my inputlayout?

Recommended Posts

This is probably going to be something really obvious once someone points it out...

I get 'An invalid parameter was passed to the returning function' when I try to create an inputlayout I've made. This is it:

[code]D3D10_INPUT_ELEMENT_DESC newLayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD1", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD2", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 }
};
m_inputLayout = setInputLayout(newLayout, 3);[/code]

Which is passed to this function:

[code]
ID3D10InputLayout* ShaderBase::setInputLayout(D3D10_INPUT_ELEMENT_DESC layout[], unsigned int numElements)
{
ID3D10InputLayout* newLayout;
D3D10_PASS_DESC PassDesc;
m_technique->GetPassByIndex( 0 )->GetDesc( &PassDesc );
HRESULT hr = m_device->CreateInputLayout(layout, numElements, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &newLayout);
if (FAILED(hr))
{
std::string message(DXGetErrorDescription(hr));
MessageBox(0, message.c_str(), "Input Layout Create Fail", MB_OK);
}
m_inputLayout = newLayout;
return newLayout;
}[/code]

This is the format of my vertex shader input in the .fx file:

[code]VS_OUTPUT VS( float4 Pos : POSITION, float2 Tex1 : TEXCOORD1, float2 Tex2 : TEXCOORD2);[/code]

Can someone have a look and see where it might be going wrong please? I'm tearing my hair out over this.

Share this post


Link to post
Share on other sites
Put the index in the second argument, not in the string, like so:
[code]
D3D10_INPUT_ELEMENT_DESC newLayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 }
};
[/code]
Not sure if there are other problems, though.

Share this post


Link to post
Share on other sites
Well, you declare


[code]ID3D10InputLayout* newLayout;[/code]

but then you pass it by reference. Try taking that ampersand out of


[code]HRESULT hr = m_device->CreateInputLayout(layout, numElements, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &newLayout);[/code]

so that you're passing that newLayout pointer, instead of a reference to your pointer.

Edit for gamedev forums not liking my copy pasta

Share this post


Link to post
Share on other sites
[quote name='Kobo' timestamp='1318353009' post='4871503']
Well, you declare


[code]ID3D10InputLayout* newLayout;[/code]

but then you pass it by reference. Try taking that ampersand out of


[code]HRESULT hr = m_device->CreateInputLayout(layout, numElements, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &newLayout);[/code]

so that you're passing that newLayout pointer, instead of a reference to your pointer.

Edit for gamedev forums not liking my copy pasta
[/quote]

It's not that, CreateInputLayout takes a pointer to a pointer for that parameter. [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb173550(v=vs.85).aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url] (plus the compiler would pick that up and it compiles fine)

I've got it working now anyway, I messed with the indices and semantic names a little and it seemed to like it.

For all the other input layouts I've used though, I've had all the indices as 0 and they've worked fine. The DX10 documentation says that you should use indices in the input layout whenever you're trying to use the same semantic name for more than one variable. Does this mean if you're using, for example, float2 tex1 : TEXCOORD1, float2 tex2 : TEXCOORD2, float2 tex3 : TEXCOORD3, in the shader, or does it mean if you were using just 'TEXCOORD' (without a digit on the end) for all three semantic names?

Share this post


Link to post
Share on other sites
[strike]Yes[/strike]. I should read more carefully. In the shader, no, just in the inputlayout.

For my first reply I remembered another post where someone erroneously put the index in the string, but I quickly checked with the debug layer and got this:
[quote]
[4848] D3D10: ERROR: ID3D10Device::CreateInputLayout: Element[1]: SemanticName string ("TEXCOORD1") cannot end with a number.
Instead, use the number in the SemanticIndex field. For example, suppose a float4x4 in HLSL is given the semantic "foo13".
To match that name via declaration element, the SemanticName field would have to be "foo", and SemanticIndex for
the declarations of each of the 4 rows of the float4x4 would have to be 13, 14, 15, and 16.[ STATE_CREATION ERROR #385: CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC ]
[/quote]
I couldn't put it any more clear.

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