DXGI vertex buffer format problem

Started by
4 comments, last by randall68000 10 years, 10 months ago

Hi,

I have a problem with a vertex format in my DX11 engine. If I create a vertex buffer using the formats DXGI_FORMAT_R16G16B16A16_UINT or DXGI_FORMAT_R16G16B16A16_SINT for position (DX9 is SHORT4) I get zero for every component in the position passed into the shader (other componets are fine R8G8B8A8 colour and R16G16_SNORM for uv). I have ran pix and checked the inputs to the mesh on the Draw() command and confirmed they are all zero. If I pass in UNORM, SNORM or FLOAT I get reasonable data passed in for the position.

Is there any steps I have missed? ie. I don't create a ShaderResourceView but that doesn't seem to matter if I don't use the 16bit formats.

Thanks

Randall68000

Advertisement

Can you show some vertex buffer / vertex declaration code?

I'm a little confused of your question since I don't define any particular format for the vertex buffer. The CreateBuffer doesn't even expect any particular format to be defined.

Cheers!

Do all DX11 devices support 64 bit formats?

Does your vertex shader use uint4/int4 types for elements with that format? If I remember correctly UINT/SINT formats won't work correctly if your shader expects them as a float, although that would be something that the debug device would warn you about. Do you create your device with D3D11_CREATE_DEVICE_DEBUG?

Kauna

I build a vertex description using a series of vertex flags like this (BuildVertexElement just fills in an array of D3D11_INPUT_ELEMENT_DESC)

if(params.mTypeMask&VertexBufferParams::kTypeXYZ32)
{
BuildVertexElement(vertexElements,element,"POSITION",0,DXGI_FORMAT_R32G32B32_FLOAT,0,offset,D3D11_INPUT_PER_VERTEX_DATA,0);
offset+=12;
}
if(params.mTypeMask&VertexBufferParams::kTypeXYZRHW16)
{
BuildVertexElement(vertexElements,element,"POSITIONT",0,DXGI_FORMAT_R16G16B16A16_UINT,0,offset,D3D11_INPUT_PER_VERTEX_DATA,0);
offset+=8;
}
And I use this to create the input layout (you are right CreateBuffer doesn't expect a format - this is my mistake).
MJP
I support Short4 positions in my DX9 code - I would like to support them in DX11 hence using DXGI_FORMAT_R16G16B16A16_SINT/UINT. Ah well there's the rub - I've got problems with the debug layers dll on my machines for some reason and I can't create the device in debug mode. I haven't got round to fixing the issue yet.
Cheers guys.

MJP - I have just changed the shaders to use int4's and I am getting the correct positions through now.

Thanks for pointing that out!

This topic is closed to new replies.

Advertisement