Jump to content

  • Log In with Google      Sign In   
  • Create Account

Writing to R16G16_UINT


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

#1 wh1sp3rik   Members   -  Reputation: 248

Like
0Likes
Like

Posted 14 October 2013 - 05:36 AM

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++


Sponsor:

#2 Zaoshi Kaba   Crossbones+   -  Reputation: 4574

Like
2Likes
Like

Posted 14 October 2013 - 05:44 AM

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, 14 October 2013 - 05:45 AM.


#3 wh1sp3rik   Members   -  Reputation: 248

Like
0Likes
Like

Posted 14 October 2013 - 06:09 AM

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++





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