Hi!
I’m trying to a GraphicsBuffer to bind to a shader that uses it as a ByteAddressBuffer. Its obvious i should initialize it with GraphicsBufferType.Raw, however i dont know what stride to use.
Since i want to fill it with bytes i thought i’d pass in a stride of 1, however then the constructor complains that the stride must be a multiple of 4, unless its only a vertex or index buffer. Sadly the only part means i also cant lame it by also making it an index buffer.
When i initialize it with a stride of 4 (and modify the count accordingly) the buffer simply doesnt appear to be bound. So how am i supposed to create and use ByteAddressBuffers?
Wait i think this is a feature since the address must be a multiple of 4 too? ByteAddressBuffer::Load(int) function - Win32 apps | Microsoft Learn
If you are in doubt, refer to underlying API for the reference:
"A byte address buffer, which can also be called a raw buffer, uses a byte value offset from the beginning of the buffer to access data. The byte value must be a multiple of four so that it is DWORD aligned. If any other value is provided, behavior is undefined.
The contents of a byte address buffer is designed to be a 32-bit unsigned integer; if the value in the buffer is not really an unsigned integer, use a function such as asfloat to read it."
And don’t forget that: “You can’t combine the D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS flag with D3D11_RESOURCE_MISC_BUFFER_STRUCTURED.”
1 Like