v3dv/descriptor_set: support for array of ubo/ssbo
For that we include the array_index when asking for a ubo/ssbo index from the descriptor_map. Until now, array_index was not included, but the descriptor_map took into account the array_size. This had the advantage that you only need a entry on the descriptor map, and the index was properly return. But this make it complex to get back the set, binding and array_index back from the ubo/ssbo binding. So it was more easy to just add array_index. Somehow now the "key" on the descriptor map is the combination of (set, binding, array_index). Note that this also make sense as the vulkan api identifies each array index as a descriptor, so for example, from spec, VkDescriptorSetLayoutBinding:descriptorCount "descriptorCount is the number of descriptors contained in the binding, accessed in a shader as an array" Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
committed by
Marge Bot
parent
9afd24f89a
commit
34cf475102
@@ -2140,7 +2140,7 @@ v3dv_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
|
||||
V3DV_FROM_HANDLE(v3dv_descriptor_set, set, pDescriptorSets[i]);
|
||||
uint32_t index = firstSet + i;
|
||||
|
||||
cmd_buffer->state.descriptor_state.descriptors[index] = set;
|
||||
cmd_buffer->state.descriptor_state.descriptor_sets[index] = set;
|
||||
cmd_buffer->state.descriptor_state.valid |= (1u << index);
|
||||
}
|
||||
|
||||
|
||||
@@ -720,8 +720,8 @@ v3dv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
|
||||
.viewportSubPixelBits = 0,
|
||||
.minMemoryMapAlignment = page_size,
|
||||
.minTexelBufferOffsetAlignment = 16,
|
||||
.minUniformBufferOffsetAlignment = 256,
|
||||
.minStorageBufferOffsetAlignment = 256,
|
||||
.minUniformBufferOffsetAlignment = 32,
|
||||
.minStorageBufferOffsetAlignment = 32,
|
||||
.minTexelOffset = -8,
|
||||
.maxTexelOffset = 7,
|
||||
.minTexelGatherOffset = -8,
|
||||
|
||||
@@ -267,27 +267,29 @@ static unsigned
|
||||
descriptor_map_add(struct v3dv_descriptor_map *map,
|
||||
int set,
|
||||
int binding,
|
||||
int value,
|
||||
int array_index,
|
||||
int array_size)
|
||||
{
|
||||
assert(array_index < array_size);
|
||||
|
||||
unsigned index = 0;
|
||||
for (unsigned i = 0; i < map->num; i++) {
|
||||
if (set == map->set[i] && binding == map->binding[i]) {
|
||||
assert(value == map->value[i]);
|
||||
for (unsigned i = 0; i < map->num_desc; i++) {
|
||||
if (set == map->set[i] &&
|
||||
binding == map->binding[i] &&
|
||||
array_index == map->array_index[i]) {
|
||||
assert(array_size == map->array_size[i]);
|
||||
return index;
|
||||
}
|
||||
index += map->array_size[i];
|
||||
index++;
|
||||
}
|
||||
|
||||
assert(index == map->num_desc);
|
||||
|
||||
map->set[map->num] = set;
|
||||
map->binding[map->num] = binding;
|
||||
map->value[map->num] = value;
|
||||
map->array_size[map->num] = array_size;
|
||||
map->num++;
|
||||
map->num_desc += array_size;
|
||||
map->set[map->num_desc] = set;
|
||||
map->binding[map->num_desc] = binding;
|
||||
map->array_index[map->num_desc] = array_index;
|
||||
map->array_size[map->num_desc] = array_size;
|
||||
map->num_desc++;
|
||||
|
||||
return index;
|
||||
}
|
||||
@@ -326,9 +328,9 @@ lower_vulkan_resource_index(nir_builder *b,
|
||||
* constants, that is already took into account when loading the ubo at
|
||||
* nir_to_vir, so we don't need to do it here again.
|
||||
*/
|
||||
index = descriptor_map_add(descriptor_map, set, binding, 0,
|
||||
index = descriptor_map_add(descriptor_map, set, binding,
|
||||
const_val->u32,
|
||||
binding_layout->array_size);
|
||||
index += const_val->u32;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -536,7 +536,7 @@ struct v3dv_vertex_binding {
|
||||
};
|
||||
|
||||
struct v3dv_descriptor_state {
|
||||
struct v3dv_descriptor_set *descriptors[MAX_SETS];
|
||||
struct v3dv_descriptor_set *descriptor_sets[MAX_SETS];
|
||||
uint32_t valid;
|
||||
};
|
||||
|
||||
@@ -749,11 +749,10 @@ struct v3dv_pipeline_layout {
|
||||
|
||||
struct v3dv_descriptor_map {
|
||||
/* TODO: avoid fixed size array/justify the size */
|
||||
unsigned num; /* number of array entries */
|
||||
unsigned num_desc; /* Number of descriptors (sum of array_size[]) */
|
||||
unsigned num_desc; /* Number of descriptors */
|
||||
int set[64];
|
||||
int binding[64];
|
||||
int value[64];
|
||||
int array_index[64];
|
||||
int array_size[64];
|
||||
};
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ get_descriptor(struct v3dv_descriptor_state *descriptor_state,
|
||||
struct v3dv_descriptor_map *map,
|
||||
uint32_t index)
|
||||
{
|
||||
assert(index >= 0 && index < map->num );
|
||||
assert(index >= 0 && index < map->num_desc);
|
||||
|
||||
uint32_t set_number = map->set[index];
|
||||
assert(descriptor_state->valid & 1 << set_number);
|
||||
|
||||
struct v3dv_descriptor_set *set =
|
||||
descriptor_state->descriptors[set_number];
|
||||
descriptor_state->descriptor_sets[set_number];
|
||||
assert(set);
|
||||
|
||||
uint32_t binding_number = map->binding[index];
|
||||
@@ -47,7 +47,10 @@ get_descriptor(struct v3dv_descriptor_state *descriptor_state,
|
||||
const struct v3dv_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->binding[binding_number];
|
||||
|
||||
return &set->descriptors[binding_layout->descriptor_index];
|
||||
uint32_t array_index = map->array_index[index];
|
||||
assert(array_index < binding_layout->array_size);
|
||||
|
||||
return &set->descriptors[binding_layout->descriptor_index + array_index];
|
||||
}
|
||||
|
||||
struct v3dv_cl_reloc
|
||||
|
||||
Reference in New Issue
Block a user