0

Directx provides Structured Buffer. What's the analog of this in vulkan? How to create one in application? How to use it in glsl shaders?

4
  • What is the difference between that and an ordinary array? Commented Jan 25, 2018 at 12:59
  • @krOoze What do you mean under an array? How would I access one in a shader? Commented Jan 25, 2018 at 13:06
  • Just normal array as is in C/C++. And also structs. (GLSL have those.) Just asking if it is the same thing because my knowledge of DX is lacking... Commented Jan 25, 2018 at 13:48
  • Afaik, in dx I can use an array of structures with constant or structured buffers. They use different memory so the usage depends on the application. And iirc, there's no such thing as array in hlsl - I can pass data only in buffers. Commented Jan 25, 2018 at 14:10

1 Answer 1

4

A D3D "Structured Buffer" is equivalent to a Vulkan "Storage Buffer", if that storage buffer is read-only. However, Vulkan (like OpenGL) uses the storage buffer concept to cover a wide range of stuff that D3D considers different things.

RWStructuredBuffers in D3D are simply storage buffers that you declare in the shader to be writable. Append/ConsumeStructuredBuffers are just storage buffers where you bump an atomic variable to find the data that your shader instance is going to "append" or "consume".

At the level of the Vulkan API, these all utilize VkBuffers that have the VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set. Even in the descriptor set, you need not specify whether a particular storage buffer binding point is read-only or read/write, or even write-only. How it gets used is decided by the shader, not the descriptor.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.