anv: Set alignments on UBO/SSBO root derefs

This doesn't really do anything for us today.  One day, I suppose we
could use it to do something with wide loads with non-uniform offsets.
The big reason to do this is to get better testing to make sure that NIR
doesn't blow up on the deref paths.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6472>
This commit is contained in:
Jason Ekstrand
2020-08-28 15:42:45 -05:00
committed by Marge Bot
parent c7dec0548a
commit 21fbffc542
3 changed files with 27 additions and 1 deletions

View File

@@ -1587,7 +1587,7 @@ void anv_GetPhysicalDeviceProperties(
*/
.minTexelBufferOffsetAlignment = 16,
.minUniformBufferOffsetAlignment = ANV_UBO_ALIGNMENT,
.minStorageBufferOffsetAlignment = 4,
.minStorageBufferOffsetAlignment = ANV_SSBO_ALIGNMENT,
.minTexelOffset = -8,
.maxTexelOffset = 7,
.minTexelGatherOffset = -32,

View File

@@ -552,6 +552,31 @@ lower_load_vulkan_descriptor(nir_intrinsic_instr *intrin,
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
assert(intrin->dest.is_ssa);
nir_foreach_use(src, &intrin->dest.ssa) {
if (src->parent_instr->type != nir_instr_type_deref)
continue;
nir_deref_instr *cast = nir_instr_as_deref(src->parent_instr);
assert(cast->deref_type == nir_deref_type_cast);
switch (desc_type) {
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
cast->cast.align_mul = ANV_UBO_ALIGNMENT;
cast->cast.align_offset = 0;
break;
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
cast->cast.align_mul = ANV_SSBO_ALIGNMENT;
cast->cast.align_offset = 0;
break;
default:
break;
}
}
assert(intrin->src[0].is_ssa);
nir_ssa_def *index = intrin->src[0].ssa;

View File

@@ -181,6 +181,7 @@ struct gen_perf_query_result;
* GEM object.
*/
#define ANV_UBO_ALIGNMENT 64
#define ANV_SSBO_ALIGNMENT 4
#define ANV_SSBO_BOUNDS_CHECK_ALIGNMENT 4
#define MAX_VIEWS_FOR_PRIMITIVE_REPLICATION 16