Jump to content
  • Advertisement
mark_braga

DX11 Structured buffer vs Raw buffer performance

Recommended Posts

Posted (edited)

Hello,

I was curious about the performance of a structured buffer vs raw buffer in scenarios where the type is a uint or a uint4, ... (not a structure type). In these cases, does the driver treat the structured buffer like a raw buffer? Will it use the raw buffer features like load coalescing for 1D loads or it is identical to a structured buffer load in this case?

StructuredBuffer<uint> structured_buffer;
ByteAddressBuffer      raw_buffer;
  
StructuredBuffer<uint4> structured_buffer_4;
ByteAddressBuffer       raw_buffer_4;

cbuffer                constants
{
  uint indices[100];
};

void main()
{
  for (uint i = 0; i < 100; ++i)
  {
    uint index = constants.indices[i];
    uint s = structured_buffer[i];
    uint r = raw_buffer.Load(i * 4);

    uint4 s_4 = structured_buffer_4[i];
    uint4 r_4 = raw_buffer_4.Load4(i * 4 * 4);
    // Do something
  }
}

In the above two cases (1D and 4D load) are both treated identically for raw and structured buffers?

Also, interesting numbers about the performance stats of the different buffer types

https://github.com/sebbbi/perftest

Edited by mark_braga

Share this post


Link to post
Share on other sites
Advertisement

The question you're asking is best answered by sebbi's numbers. There's nothing at the D3D or HLSL level that says anything about how a particular piece of hardware will treat a particular buffer type in terms of load coalescing or the relative performance of StructuredBuffers vs ByteAddressBuffers.

You're just going to have to profile it on the cards you're interested in supporting and see which comes out the best. If you're really keen to get the best numbers possible you might want to provide both options in the engine and dynamically choose one based on the Vendor ID reported by the API.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!