Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asahi/vulkan/hk_nir_lower_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ hk_nir_lower_descriptors(nir_shader *nir,

ctx.ssbo_addr_format = hk_buffer_addr_format(
rs->storage_buffers, rs->null_storage_buffer_descriptor,
ctx.descriptor_generation == 10);
ctx.descriptor_generation == AGX_DESCRIPTOR_GENERATION_10);

/* First lower everything but complex SSBOs, then lower complex SSBOs.
*
Expand Down
6 changes: 3 additions & 3 deletions src/asahi/vulkan/hk_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ hk_get_spirv_options(struct vk_physical_device *vk_pdev,
return (struct spirv_to_nir_options){
.ssbo_addr_format = hk_buffer_addr_format(
rs->storage_buffers, rs->null_storage_buffer_descriptor,
agx_chip_g17_m5(((struct hk_physical_device *)vk_pdev)->dev.chip)),
hk_ssbo_addr_has_map(((struct hk_physical_device *)vk_pdev)->dev.chip)),
.phys_ssbo_addr_format = nir_address_format_64bit_global,
.ubo_addr_format = hk_ubo_addr_format(rs->uniform_buffers),
.shared_addr_format = nir_address_format_32bit_offset,
Expand Down Expand Up @@ -3875,7 +3875,7 @@ hk_lower_nir(struct hk_device *dev, nir_shader *nir,
NIR_PASS(lowered_buf_io, nir, nir_lower_explicit_io, nir_var_mem_ssbo,
hk_buffer_addr_format(rs->storage_buffers,
rs->null_storage_buffer_descriptor,
agx_chip_g17_m5(dev->dev.chip)));
hk_ssbo_addr_has_map(dev->dev.chip)));
if (rs->uniform_buffers ==
VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2_EXT) {
uint8_t static_set_mask =
Expand Down Expand Up @@ -8625,7 +8625,7 @@ hk_maybe_build_byte_stencil(struct hk_device *dev, const nir_shader *nir,
const nir_address_format ssbo_addr_format = hk_buffer_addr_format(
info->robustness->storage_buffers,
info->robustness->null_storage_buffer_descriptor,
agx_chip_g17_m5(dev->dev.chip));
hk_ssbo_addr_has_map(dev->dev.chip));
out->tiled_nir = hk_nir_build_tiled_byte_stencil(NULL, nir, &out->plan,
ssbo_addr_format);
return out->tiled_nir != NULL;
Expand Down
8 changes: 8 additions & 0 deletions src/asahi/vulkan/hk_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,14 @@ hk_ubo_addr_format(VkPipelineRobustnessBufferBehaviorEXT robustness)
: nir_address_format_64bit_bounded_global;
}

/* Gen10 descriptor sets carry the 5-component SSBO address format with the
* sparse residency map slot (matching hk_nir_lower_descriptors()). */
static inline bool
hk_ssbo_addr_has_map(enum agx_chip chip)
{
return agx_chip_descriptor_generation(chip) == AGX_DESCRIPTOR_GENERATION_10;
}

static inline nir_address_format
hk_buffer_addr_format(VkPipelineRobustnessBufferBehaviorEXT robustness,
bool null_descriptor, bool map_metadata)
Expand Down
21 changes: 21 additions & 0 deletions src/asahi/vulkan/tests/test-hk-binding-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,31 @@ check_packed_uvec4_refused(bool from_ubo)
free(layout);
}

static void
check_ssbo_addr_format_matches_descriptor_gen(void)
{
/* Gen10 parts (M5 and G18G) all use the 5-component SSBO address format
* with the map slot, matching hk_nir_lower_descriptors(). */
CHECK(hk_ssbo_addr_has_map(AGX_CHIP_G17G));
CHECK(hk_ssbo_addr_has_map(AGX_CHIP_G17S));
CHECK(hk_ssbo_addr_has_map(AGX_CHIP_G17C));
CHECK(hk_ssbo_addr_has_map(AGX_CHIP_G18G));
CHECK(!hk_ssbo_addr_has_map(AGX_CHIP_G17P));
CHECK(!hk_ssbo_addr_has_map(AGX_CHIP_G16G));
CHECK(!hk_ssbo_addr_has_map(AGX_CHIP_G13G));

const nir_address_format g18_fmt = hk_buffer_addr_format(
VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, false,
hk_ssbo_addr_has_map(AGX_CHIP_G18G));
CHECK(g18_fmt == nir_address_format_64bit_global_32bit_offset_map);
CHECK(nir_address_format_num_components(g18_fmt) == 5);
}

int
main(void)
{
glsl_type_singleton_init_or_ref();
check_ssbo_addr_format_matches_descriptor_gen();
check_binding_accepted(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, true, false);
check_binding_accepted(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, false, false);
check_binding_accepted(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, true, false);
Expand Down