3
$\begingroup$

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.

$\endgroup$

1 Answer 1

3
$\begingroup$

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)]
$\endgroup$
1
  • $\begingroup$ thank you for your quick answer. I didn't get the results I hoped, but you answered the question. $\endgroup$
    – slanden
    Commented Oct 17, 2017 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.