Sign in to follow this  
wh1sp3rik

Writing to R16G16_UINT

Recommended Posts

wh1sp3rik    248

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

Share this post


Link to post
Share on other sites
Zaoshi Kaba    8434

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.

Edited by Zaoshi Kaba

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