Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


ShaderResourceView/ D3D11_BUFFER_SRV doc and usage mistmatch


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

#1 xoofx   Members   -  Reputation: 887

Like
0Likes
Like

Posted 19 October 2012 - 01:07 AM

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"]D3D11_SHADER_RESOURCE_VIEW_DESC desc;desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;desc.Format = ...;desc.Buffer.FirstElement = index; // Index in element countdesc.Buffer.NumElements = count; // Number of elements[/source]

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; };} D3D11_BUFFER_SRV;[/source]

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! Posted Image

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

Edited by xoofx, 19 October 2012 - 08:30 AM.


Sponsor:



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