[SOLVED] [D3D10] Problems creating input layout

Started by
-1 comments, last by idloco 17 years, 1 month ago
I'm having problems creating the Input Layout for a shader I'm using. The CreateInputLayout() returns me invalid arg, but I have checked the parameters several times and I don't see anything wrong ( I know it has to be something wrong some where ) This is the code snip where I create the Input Layout

m_pSectionVertexLayout = NULL;
hr = TheGraphics.GetGraphicsDevice()->CreateInputLayout( D3DVERTEX_Layout, D3DVERTEX_DECL_SIZE, 
							m_pTerrainVertexShader->GetShaderBuffer()->GetBufferPointer(),
							m_pTerrainVertexShader->GetShaderBuffer()->GetBufferSize(),
							&m_pSectionVertexLayout ) ;
if (FAILED(hr))
{
	log_graphics_critical(" CTerrainSection::LoadTerrainSection - Error creating the section Input Layout");
	return hr;
}


Here is the vertex declaration

typedef struct SVertex
{
	D3DXVECTOR3 v; // Actual Vertex
	D3DXVECTOR3 n; // Normal Vector
	D3DXVECTOR2	tu1; // Texture Coordinates
	D3DXVECTOR2	tu2; // Texture Coordinates
	D3DXVECTOR3 t; // tangent Vertex
	D3DXVECTOR3 bn; // BiNormal Vector
} D3DVERTEX;


#define D3DVERTEX_DECL_SIZE 6

// Define the input layout
const D3D10_INPUT_ELEMENT_DESC D3DVERTEX_Layout[] =
{
	{ "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT,	0,  0,	D3D10_INPUT_PER_VERTEX_DATA, 0 },  
	{ "Normal",		 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 12,	D3D10_INPUT_PER_VERTEX_DATA, 0 },  
	{ "TEXCOORD0",   0, DXGI_FORMAT_R32G32_FLOAT,		0, 24,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
	{ "TEXCOORD1",   0, DXGI_FORMAT_R32G32_FLOAT,		0, 32,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
	{ "TANGENT",     0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 40,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
	{ "BINORMAL",    0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 52,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
};


I have checked the creation/compilation of the shaders and it is fine, it doesn't gives me any errors. Here is the shader if you want to look at it, this is just a small shader which I later want to convert to a bump mapping shader, so, the only thing that it does at this time ( or at least it supposed to do ) its translate the vertices from one space to world space.

//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
cbuffer cb0
{
    row_major float4x4 mWorldViewProj : packoffset(c0);     // World * View * Projection transformation
    float fTime :                       packoffset(c5.y);   // Time parameter. This keeps increasing
                                                            // Notice, that this parameter is placed in c5.y.
                                                            // If it were packed by the default packing rules, 
                                                            // it would be placed in c4.x
};

//-----------------------------------------------------------------------------
// Vertex shader input structure
// 	{ "SV_POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT,	0,  0,	D3D10_INPUT_PER_VERTEX_DATA, 0 },  
//	{ "NORMAL",		 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 12,	D3D10_INPUT_PER_VERTEX_DATA, 0 },  
//	{ "TEXCOORD0",   0, DXGI_FORMAT_R32G32_FLOAT,		0, 24,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
//	{ "TEXCOORD1",   0, DXGI_FORMAT_R32G32_FLOAT,		0, 32,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
//	{ "TANGENT",     0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 40,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
//	{ "BINORMAL",    0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 52,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
//-----------------------------------------------------------------------------

struct VS_INPUT
{
	float4 Position		: SV_Position; // Vertex Position
	float3 Normal		: Normal;
	float2 TexCoord0	: Texcoord0;
	float2 TexCoord1	: Texcoord0;
	float3 Tangent		: Tangent;
	float3 Binormal		: Binormal0; 
};

struct VS_OUTPUT
{
    float4 Position   : SV_Position;   // vertex position 
   
};


VS_OUTPUT VSBump( in VS_INPUT pVertex )
{
    VS_OUTPUT Output;
    
    // Change the y of the vertex position based on a function of time 
    // and transform the vertex into projection space. 
    Output.Position = mul( pVertex.Position, mWorldViewProj );
    
    return Output;
}



Any hint/clue/advice in how I can fix this or where did I make the mistake will be highly appreciated. Thanks in advance /********************************************************/ Solved - Here is the answer for case documenation... /********************************************************/ I have used a bad index on the vertex declaration the new vertex declaration its now like this

	{ "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT,	0,  0,	D3D10_INPUT_PER_VERTEX_DATA, 0 },  
	{ "Normal",		 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 12,	D3D10_INPUT_PER_VERTEX_DATA, 0 },  
	{ "TEXCOORD",    0, DXGI_FORMAT_R32G32_FLOAT,		0, 24,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
	{ "TEXCOORD",    1, DXGI_FORMAT_R32G32_FLOAT,		0, 32,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
	{ "TANGENT",     0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 40,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 
	{ "BINORMAL",    0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 52,	D3D10_INPUT_PER_VERTEX_DATA, 0 }, 

Thanks to Zeux for the help :D [Edited by - idloco on March 7, 2007 4:41:24 PM]
------------------------------------ IDLoco Game Studios

This topic is closed to new replies.

Advertisement