3

I'm trying to follow along with a tutorial that uses an OpenGL compute shader, but I'm using D3D11. What they do is:

layout (std430, binding = 0) buffer indices {
    int j[];
};

I have no experience with this and very little with directX, but that looks like a buffer of integer arrays. I've looked around and read that the equivalent to this OpenGL buffer in D3D11 is an RWBuffer. Using a compute shader, this is what I've tried. Note, I didn't redefine them in my code as they appear here, I just listed them together here.

RWBuffer indices
{
    int j[];
}

RWBuffer<{int j[];}> indices;

struct index
{
    //requires explicit length, which is why this doesn't work
    int j[];
}
RWStructuredBuffer<index> indices;

But, none of those worked. The end goal is to access them like so:

//id is SV_DispatchThreadID
indices.j[int(id.y)]

This seems like an inappropriately simple question to post, but I wasn't able to find documentation, even on MSDN, on defining buffers and what's allowed and not, etc.

slanden
  • 133
  • 3

1 Answers1

3

It looks to me like you want a buffer containing a single array of integers (not a buffer containing multiple arrays, whatever that would mean). So, you should be able to just do this:

RWBuffer<int> indices;

then access it like this:

indices[int(id.y)]
Nathan Reed
  • 25,002
  • 2
  • 68
  • 107
  • thank you for your quick answer. I didn't get the results I hoped, but you answered the question. – slanden Oct 17 '17 at 22:31