You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be possible to remove [[block]] annotations if we can expect implementations to reasonably infer them and synthesize them as-needed on backends.
Conceptually the block decoration on resources indicates "this object maps 1-1 to a binding slot".
So a consideration is what do we do when we can have arrays of resources. Without the block decoration, we have an ambiguity to resolve.
You can have sized or unsized arrays of those resources. The latter case is common when using a "bindless" approach.
Conceptually the block decoration on resources indicates "this object maps 1-1 to a binding slot".
I'm confused now. You mentioned that [[block]] is only for uniform buffers, and it doesn't support dynamic arrays. But storage buffers with dynamic arrays are also struct declarations that are 1-1 to a binding slot.
A block-decorated struct describes the content of a binding. That's true for uniform-buffer and storage-buffer.
The last element of the struct of a storage buffer may be an unsized array.
(From memory, the
What I'm saying is that, with an extension, Vulkan can do unsized arrays of those block-decorated structs.
The use case is bindless-style programming, where only the binding entries accessed from the descriptor array need to have been bound.
Here's an example in GLSL for a compute shader:
#version450// This extension allows non-uniform indexing of the runtime-arrays of UBO and SSBO// See SPIR-V capability RuntimeDescriptorArray#extension GL_EXT_nonuniform_qualifier : require
layout(set=0,binding=0) uniform U {
uint a;
float data[10]; // sized, hence OpTypeArray
} myuni []; // becomes OpTypeRuntimeArraylayout(set=0,binding=1) buffer B {
uint a;
float data[]; // unsized allowed. Becomes OpTypeRuntimeArray
} mybuf []; // becomes OpTypeRuntimeArrayvoid main() {
uint i = myuni[0].a;
mybuf[i].data[0] = myuni[i*i].data[0];
}
Compiling through "glslangValidator -V", we get this SPIR-V assembly:
Activity
dneto0 commentedon Aug 19, 2020
Conceptually the block decoration on resources indicates "this object maps 1-1 to a binding slot".
So a consideration is what do we do when we can have arrays of resources. Without the block decoration, we have an ambiguity to resolve.
You can have sized or unsized arrays of those resources. The latter case is common when using a "bindless" approach.
kvark commentedon Aug 19, 2020
I'm confused now. You mentioned that
[[block]]is only for uniform buffers, and it doesn't support dynamic arrays. But storage buffers with dynamic arrays are also struct declarations that are 1-1 to a binding slot.dneto0 commentedon Aug 19, 2020
I'm not explaining it clearly.
A block-decorated struct describes the content of a binding. That's true for uniform-buffer and storage-buffer.
The last element of the struct of a storage buffer may be an unsized array.
(From memory, the
What I'm saying is that, with an extension, Vulkan can do unsized arrays of those block-decorated structs.
The use case is bindless-style programming, where only the binding entries accessed from the descriptor array need to have been bound.
Here's an example in GLSL for a compute shader:
Compiling through "glslangValidator -V", we get this SPIR-V assembly:
dneto0 commentedon Sep 14, 2021
See #2104