Conversation
|
What's the difference between a texel buffer view and a storage buffer? Why do we need both? (I don't really what texel views mean in hardware) |
|
Good question. I can't think of a case where a storage texel buffer storage would be better than just a storage buffer. There are some minor things like sampling from it, or an ability to have the same shader handling both buffer and texture storages, but it feels fairly minor. The read-only (or "sampled") texel buffer views seem useful though. |
|
In Vulkan:
|
|
Thanks for digging into the details of texel buffers in Vulkan. The feature seems completely superseded by storage buffer, so we should postpone this (and I'd suggest we do this indefinitely) |
|
Closing as agreed during F2F. |
|
The format conversion parts are necessary for HLSL support, since the type of a StructuredBuffer doesn't necessarily have to match the underlying buffer's format. |
|
Buffers are untyped, you can implement StructuredBuffers by loading data and reinterpret_cast in the shader. |
|
reinterpret_cast is not what I mean. I mean that you can load |
|
The content of buffers is untyped so you an implement that StructuredBuffer with a storage buffer containing an unsized array of floats. |
|
I understand that I do not describe the buffer type directly to WebGPU, but texel views let me state that buffer contains data packed as SN16 (16-bit signed normal integers representing the range from -1.0 to 1.0) and load it in the shader as a float. This is known as a "typed surface load/store", it's implemented in GLSL through the extension GL_EXT_shader_image_load_formatted, StructuredBuffers in HLSL do it by default, and Vulkan storage buffers do not support it. |
|
@dneto0 provides a pretty good summary of what they are in Vulkan.
@Kangz and others, the main reason why there's still a distinction between STB (SSBO in OpenGL) and UTB (TBO in OpenGL) and why Uniform Texel Buffer (no idea why they called it "Uniform" in Vulkan) remains relevant is the following:
|
|
@devshgraphicsprogramming that's some great info/insight here! I think what's missing is some benchmarking to quantify the benefits of texel buffers, perhaps in extreme cases where it's supposed to be faster. |
|
@kvark we've been wanting to profile this for our engine for almost a year |
Closes #162
1. What is the API?
In D3D12 and Metal, texel buffer views are exposed the same way as texture views: via SRV/UAV and
MTLTexturecorrespondingly. In Vulkan, there is a separateVkBufferViewtype describing this object.I suggest us go with a separate object type as well (as opposed to piggy-backing on
GPUTextureView) because the produced view is more restricted than a normal texture view. It can only be used for bind group creation, where we already have an implicit enumerationGPUBindingResource, so it's trivial to extend it.2. Which texture formats can buffers be viewed as ?
One option would be to have some sort of query to ask the implementation if a specific texture format can be used for a texel view. I think having this query would harm portability and leave heavy fingerprints. Therefore, I suggest us just listing the formats in the spec document for MVP: