Jump to content

  • Log In with Google      Sign In   
  • Create Account

creatInputLayout returns a NULL pointer


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

#1 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 May 2013 - 01:35 PM

Hi !

// Create our vertex input layout
	D3D11_INPUT_ELEMENT_DESC layout[4];
	layout[0].SemanticName = "POSITION";
	layout[0].SemanticIndex = 0;
	layout[0].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	layout[0].InputSlot = 0;
	layout[0].AlignedByteOffset = 0;
	layout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[0].InstanceDataStepRate = 0;

	layout[1].SemanticName = "TEXCOORD";
	layout[1].SemanticIndex = 0;
	layout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
	layout[1].InputSlot = 0;
	layout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
	layout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[1].InstanceDataStepRate = 0;

	layout[2].SemanticName = "NORMAL";
	layout[2].SemanticIndex = 0;
	layout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
	layout[2].InputSlot = 0;
	layout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
	layout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[2].InstanceDataStepRate = 0;

	layout[3].SemanticName = "COLOR";
	layout[3].SemanticIndex = 0;
	layout[3].Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
	layout[3].InputSlot = 0;
	layout[3].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
	layout[3].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[3].InstanceDataStepRate = 0;

	UINT numElement = ARRAYSIZE( layout ) ;
	if(D3DERR_INVALIDCALL == deviceDX11->CreateInputLayout( layout, numElement, blobVertexGBuffer->GetBufferPointer(), blobVertexGBuffer->GetBufferSize(), &vertexGBufferLayout ))
		return ;

 

The variable "vertexGBufferLayout" has no adress (null pointer), after createInputLayout method. This vraiable is of type ID3D11InputLayout and is in "out" as described in the directx documentation.

 

The associated vertex shader is : 


struct vsIn
{
	float4 position : POSITION ;
	float2 texCoord : TEXCOORD0 ;
	float3 normal   : NORMAL   ;
	float4 color    : COLOR ;
};

struct vsOut
{
	float4 RTposition : POSITION1 ;
	float2 texCoord : TEXCOORD0 ;
	float4 color : COLOR0 ;
	float4 finalPos :SV_POSITION ;
	float3 normal   : NORMAL   ;
	float4 posInLightSpace	 : TEXCOORD1 ;
};

cbuffer globalMatrices
{
	float4x4 WorldView ;
	float4x4 WorldViewProj;
	float4x4 InverseTransposedWorld ;
	//float4x4 lightViewProj ;
}

vsOut vertex_main(in vsIn IN, vsOut OUT)//, in float4 position : POSITION0)
{
	
	//OUT.posInLightSpace = mul(position, lightViewProj); 
	OUT.RTposition = mul(IN.position, WorldView);
	OUT.color = IN.color ;
	OUT.color.w = 1.0 ; 
	//OUT.normal = mul(IN.normal, WorldView);
	OUT.normal = mul(IN.normal, InverseTransposedWorld);
	OUT.texCoord = IN.texCoord ;
	
    OUT.finalPos= mul( IN.position, WorldViewProj );

	return OUT ;
} 

Can you help me ? Did I do something wrong ?

I'm not sure that the pixel format is right as I did, specially for COLOR semantic (is it the right name for colors' semantic ?) where I put DXGI_FORMAT_R8G8B8A8_UNORM_SRGB



Sponsor:

#2 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 23 May 2013 - 01:56 PM

What does this give you:  ARRAYSIZE( layout );

 

Are blobVertexGBuffer and blobVertexGBuffer valid pointers?

 

And have you tried declaring color without the type DXGI_FORMAT_R8G8B8A8_UNORM_SRGB ?


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#3 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 May 2013 - 02:09 PM

ARRAYSIZE makes a sizeof of the whole array (here the variable named "layout") divided by the sizeof the first element of this array. Here it gives me a size of 4.

blobVertexGBuffer has a valid adress, yes.

I would like to put something else than DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, but I don't know what to put : R8G8B8A8 it's sure, but in float ? UINT ? It is to store colors, and don't know what is appropriate or the most appropriate to store colors from a scene representation.



#4 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 23 May 2013 - 03:01 PM

try to use DXGI_FORMAT_R32G32B32A32_FLOAT for colors.


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#5 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 May 2013 - 03:07 PM

Ok but why ? It stores colors on 128 bits, instead of 32 bits, so why ?

It tried but it don't work.



#6 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 23 May 2013 - 03:12 PM

Maybe instead of this:

vsOut vertex_main(in vsIn IN, vsOut OUT)//, in float4 position : POSITION0)
{

 

 
try this:
vsOut vertex_main(in vsIn IN)
{
    vsOut OUT;

 

 

It could work...


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#7 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 23 May 2013 - 03:17 PM

After the creation, does vertexGBufferLayout have a value?


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#8 MJP   Moderators   -  Reputation: 11380

Like
2Likes
Like

Posted 23 May 2013 - 03:40 PM

Not all DXGI formats are supported for use in a vertex buffer. You need to look at the table entitled "Input assembler vertex buffer resources" from here to see which formats are supported. In your particular case the issue is that _SRGB formats aren't supported. You need to use DXGI_FORMAT_R8G8B8A8_UNORM instead, and then apply sRGB->Linear conversion manually in the shader.

Also you should consider turning on the debug device by passing
D3D11_CREATE_DEVICE_DEBUG when creating your device. When you do this, you'll get helpful error messages in your debugger output window whenever you do something wrong.
 



#9 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 24 May 2013 - 04:19 AM

vertexGBufferLayout has no value (null pointer), I tried with DXGI_FORMAT_R8G8B8A8_UNORM and vertexGBufferLayout has still no value, I tried also by removing all lines concerning colors in the vertex shader and this code from C++ code :

layout[3].SemanticName = "COLOR";
layout[3].SemanticIndex = 0;
layout[3].Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
layout[3].InputSlot = 0;
layout[3].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[3].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[3].InstanceDataStepRate = 0;

 

And it still doesn't work sad.png

I tried to put D3D11_CREATE_DEVICE_DEBUG and my program crashes sooner in my code at a place where it usually doesn't crash. And I have no more messages in the output than before. sad.png 



#10 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 24 May 2013 - 04:23 AM

Can you show your initialization code for directx 11?

What IDE are you using?

 

Have you tried to initialize your input layout without the Semantic COLOR ?

 

So it would look like this:

 

D3D11_INPUT_ELEMENT_DESC layout[3];
	layout[0].SemanticName = "POSITION";
	layout[0].SemanticIndex = 0;
	layout[0].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	layout[0].InputSlot = 0;
	layout[0].AlignedByteOffset = 0;
	layout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[0].InstanceDataStepRate = 0;

	layout[1].SemanticName = "TEXCOORD";
	layout[1].SemanticIndex = 0;
	layout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
	layout[1].InputSlot = 0;
	layout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
	layout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[1].InstanceDataStepRate = 0;

	layout[2].SemanticName = "NORMAL";
	layout[2].SemanticIndex = 0;
	layout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
	layout[2].InputSlot = 0;
	layout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
	layout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
	layout[2].InstanceDataStepRate = 0;

	UINT numElement = ARRAYSIZE( layout ) ;
	if(D3DERR_INVALIDCALL == deviceDX11->CreateInputLayout( layout, numElement, blobVertexGBuffer->GetBufferPointer(), blobVertexGBuffer->GetBufferSize(), &vertexGBufferLayout ))
		return ;

 

 

And then the shader as the following:

 

struct vsIn
{
	float4 position : POSITION ;
	float2 texCoord : TEXCOORD0 ;
	float3 normal   : NORMAL   ;
};

struct vsOut
{
	float4 RTposition : POSITION1 ;
	float2 texCoord : TEXCOORD0 ;
	float4 color : COLOR0 ;
	float4 finalPos :SV_POSITION ;
	float3 normal   : NORMAL   ;
	float4 posInLightSpace	 : TEXCOORD1 ;
};

cbuffer globalMatrices
{
	float4x4 WorldView ;
	float4x4 WorldViewProj;
	float4x4 InverseTransposedWorld ;
	//float4x4 lightViewProj ;
}

vsOut vertex_main(in vsIn IN, vsOut OUT)//, in float4 position : POSITION0)
{
	
	//OUT.posInLightSpace = mul(position, lightViewProj); 
	OUT.RTposition = mul(IN.position, WorldView);
	OUT.color = float4(1, 1, 1, 1) ;
	OUT.color.w = 1.0 ; 
	//OUT.normal = mul(IN.normal, WorldView);
	OUT.normal = mul(IN.normal, InverseTransposedWorld);
	OUT.texCoord = IN.texCoord ;
	
    OUT.finalPos= mul( IN.position, WorldViewProj );

	return OUT ;
} 

 

 

Just to see if COLOR is the issue.


Edited by Migi0027, 24 May 2013 - 04:27 AM.

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#11 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 24 May 2013 - 04:26 AM

void D3D11Rendering::initD3DDevice()
{

	D3D_FEATURE_LEVEL  FeatureLevelsRequested = D3D_FEATURE_LEVEL_11_0;
	UINT               numLevelsRequested = 1;


	HRESULT hr = E_FAIL;
	D3D_FEATURE_LEVEL FeatureLevel;

	hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, NULL, 0,
		D3D11_SDK_VERSION, &swapChainDesc, &swapChain,  &deviceDX11, &FeatureLevel, &deviceContext );

	if(FAILED(hr))
	{
		return ;
	}
}

 

I guess it was it ?



#12 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 24 May 2013 - 04:34 AM

It still doesn't work



#13 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 24 May 2013 - 04:34 AM

You're missing an awful lot of code, where is swapChainDesc defined and set?


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#14 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 24 May 2013 - 04:39 AM

It is ever created i initialized it in the constructor, there is no problems with that.



#15 ATEFred   Members   -  Reputation: 1080

Like
1Likes
Like

Posted 24 May 2013 - 04:42 AM

vertexGBufferLayout has no value (null pointer), I tried with DXGI_FORMAT_R8G8B8A8_UNORM and vertexGBufferLayout has still no value, I tried also by removing all lines concerning colors in the vertex shader and this code from C++ code :

layout[3].SemanticName = "COLOR";
layout[3].SemanticIndex = 0;
layout[3].Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
layout[3].InputSlot = 0;
layout[3].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[3].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[3].InstanceDataStepRate = 0;

 

And it still doesn't work sad.png

I tried to put D3D11_CREATE_DEVICE_DEBUG and my program crashes sooner in my code at a place where it usually doesn't crash. And I have no more messages in the output than before. sad.png 

 

If you are using vs2010, a recent update caused a crash (on device creation if I remember correctly?). You can fix that by installing the remote vs2012 debugging tools (free). see here: http://blogs.msdn.com/b/chuckw/archive/2013/02/26/directx-11-1-and-windows-7-update.aspx
You really should make sure you get the debug runtimes working, it's really helpful, definitely worth the (minimal) effort to setup.



#16 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 24 May 2013 - 04:53 AM

well then how do you define your screen width and height if you don't touch the swap chain.

 

Hehe, you're a bit lazy aren't you happy.png


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#17 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 24 May 2013 - 05:00 AM

I get screen dimensions and affect it then.

For vs2012 tools, thanks i'm downloading it, I come back then to tell you if it works or not.



#18 Migi0027   Crossbones+   -  Reputation: 1728

Like
0Likes
Like

Posted 24 May 2013 - 05:06 AM

Wait, so you do touch the swapchain description?

 

Show us if you do.


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#19 theScore   Members   -  Reputation: 158

Like
0Likes
Like

Posted 26 May 2013 - 11:50 PM

It works, I forgot the semantics which were in output from the vertex shader.

And I can now use the directx debug runtime.

Thanks






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