Writing to R16G16_UINT

Started by
1 comment, last by wh1sp3rik 10 years, 6 months ago

Hello,

I have a little problem :)

I would like to write data into buffer with format :


				{"POSITION",  0, DXGI_FORMAT_R16G16_UINT,  0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
				{"TPOSITION", 0, DXGI_FORMAT_R16G16_UINT,  1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
				{"LODID",     0, DXGI_FORMAT_R16_UINT,     1, 4, D3D11_INPUT_PER_INSTANCE_DATA, 1 },

First stream has 4 bytes, second stream has 6 bytes.

So, i created buffers with that sized and i copied USHORT data into buffer.

When rendering, it says


D3D11 ERROR: ID3D11DeviceContext::DrawIndexedInstanced: Vertex Buffer Stride (6) at the input vertex slot 1 is not aligned properly. The current Input Layout imposes an alignment of (4) because of the Formats used with this slot. [ EXECUTION ERROR #367: DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED]

Shader layout:


struct VIn
{
    uint2   position : POSITION0;
    uint2   instance : TPOSITION;
    uint    lodid    : LODID;
};

when i use 32bits , it's working fine. I also tried to use uint only and unpack two ushorts ( uints in hlsl ).

It's a pity, there are no ushorts in hlsl ;-)

thank you

DirectX 11, C++

Advertisement

I think it complains your vertex's size isn't multiple of 4. You can try changing LODID to DXGI_FORMAT_R32_UINT or just leave it unused.

Since it mentions other formats you could also try to use separate buffer for LODID with DXGI_FORMAT_R16_UINT.

Hello,

you are right. Also, there is not R16G16B16_UINT format, it has a reason :) These memory aligments are pain.

Thank you, I am on the good way now.

DirectX 11, C++

This topic is closed to new replies.

Advertisement