Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texel Buffers (Uniform + Storage) #569

Closed
hrydgard opened this issue Mar 31, 2021 · 4 comments
Closed

Texel Buffers (Uniform + Storage) #569

hrydgard opened this issue Mar 31, 2021 · 4 comments
Labels
a: ark Issues that Ark depends on t: bug Something isn't working

Comments

@hrydgard
Copy link
Contributor

hrydgard commented Mar 31, 2021

Vulkan Texel buffers are (potentially) large 1-D images that are not backed by image objects, instead they're backed by a VkBufferView specifying a range (and format, for free conversion) of a VkBuffer.

These can be either read-only (Uniform Texel Buffers) or read/write (Storage Texel Buffers).

The corresponding SPIR-V can be found at https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_vulkan_glsl.txt#L370 .

Essentially, it's just texelFetch on an image with Dim = Buffer.

Historically, they are yet another historical artifact that predate storage buffers, they existed as a special kind of 1D textures in OpenGL to access large arbitrary data. Effectively it's using a texture unit on a linear buffer, so they still have advantages such as free format conversion from packed integer formats to float, and accessing unaligned formats like R32G32B32_FLOAT , which is good in raytracing shaders for grabbing vertex data through bindless arrays of these for doing stuff like normal or UV coordinate interpolation after a hit

#450 is related.

@hrydgard hrydgard added the t: bug Something isn't working label Mar 31, 2021
@XAMPPRocky
Copy link
Member

so they still have advantages such as free format conversion from packed integer formats to float, and accessing unaligned formats like R32G32B32_FLOAT

Are formats like R32G32B32_FLOAT required? AFAICT SPIR-V doesn't have those in the spec, and doesn't have an extension that adds them.

@XAMPPRocky XAMPPRocky added the a: ark Issues that Ark depends on label Apr 22, 2021
@XAMPPRocky
Copy link
Member

Both Uniform and Storage Texel Buffers are implemented in #359. With that PR you'd write the types from your example as follows:

use spirv_std::Image;

type UniformBuffer = Image!(buffer, type=f32, sampled);
type StorageBuffer = Image!(buffer, format=r32f, sampled=false);

@hrydgard
Copy link
Contributor Author

hrydgard commented Apr 22, 2021

Very cool!

@XAMPPRocky SPIR-V doesn't care about the specific format for those cases. It's like a texture, conversion happens on load and the exact format is specified when binding the texture. And yeah I think that's just supported for the Uniform variant.

@XAMPPRocky
Copy link
Member

these are now available in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: ark Issues that Ark depends on t: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants