D3D11_BUFFER_SRV - How to use it?

In DirectX11, when creating a Shader resource representation to a clipboard; we have to fill in the structure D3D11_BUFFER_SRV

.

The structure looks like this:

typedef struct D3D11_BUFFER_SRV {
  union {
    UINT FirstElement;
    UINT ElementOffset;
  };
  union {
    UINT NumElements;
    UINT ElementWidth;
  };
} D3D11_BUFFER_SRV;

      

I can't find any documentation on which field in each union I should use and when, or even really what they mean. The MSDN page ( http://msdn.microsoft.com/en-us/library/windows/desktop/ff476094%28v=vs.85%29.aspx ) gives a pretty obvious description of each field, but nothing helps.

+3


source to share


1 answer


As far as I know, for a structured buffer, D3D11 always interprets the values ​​in these joins as the first index and record count , which means you always want to use FirstElement

and NumElements

.

ElementWidth

does not seem necessary because the size of the element has already been declared with D3D11_BUFFER_DESC::StructureByteStride

. Also, the documentation is misleading because it FirstElement

really is the index for the first element, not the byte offset.



There is really no reason for the other two meanings. My only guess is that this structure was meant to be used somewhere else, perhaps in conjunction with a flag that said how to interpret unions, but I've never seen it use any other way.

+3


source







All Articles