• Advertisement
Sign in to follow this  

ShaderResourceView/ D3D11_BUFFER_SRV doc and usage mistmatch

This topic is 1920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Usually when I was creating a ShaderResourceView on a Buffer (in hlsl: Buffer<float4> for example) or a StructuredBuffer (for example: StructuredBuffer<float4>), I was using something like:

[source lang="cpp"]


desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
desc.Format = ...;
desc.Buffer.FirstElement = index; // Index in element count
desc.Buffer.NumElements = count; // Number of elements


It is working fine with both type of buffers (plain or structured), but today, I was checking the documentation of D3D11_BUFFER_SRV, and It says something completely invalid to the usage I have of it.
First of all, there is an union:

[source lang="cpp"]
typedef struct D3D11_BUFFER_SRV {
union {
UINT FirstElement;
UINT ElementOffset;
union {
UINT NumElements;
UINT ElementWidth;


I have two questions:

1) And as stated in the doc FirstElement is "Number of bytes between the beginning of the buffer and the first element to access.", which is not what I'm experiencing, as I use the index of element, not the index * sizeof(element).
Is it the documentation that is wrong or Am I missing something here?

2) Also, ElementOffset would appear to be used with a byte offset, and ElementWidth as the size of the element, but in which case these fields are interpreted like this? I can't find any relevant doc about this.

Any hint highly appreciated! smile.png

Edit: Sorry for the source code, I can't get the source tag to work correctly, everything is collapsed. Edited by xoofx

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement