Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions src/asahi/vulkan/hk_buffer_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ hk_get_buffer_format_features(struct hk_physical_device *pdev,

if (p_format == PIPE_FORMAT_R32_UINT || p_format == PIPE_FORMAT_R32_SINT ||
(p_format == PIPE_FORMAT_R32_FLOAT &&
(agx_chip_native_hal200(pdev->dev.chip) ||
agx_chip_g17_m5(pdev->dev.chip))))
pdev->vk.supported_features.shaderImageFloat32Atomics))
features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
}

Expand Down
6 changes: 2 additions & 4 deletions src/asahi/vulkan/hk_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ hk_get_image_plane_format_features(struct hk_physical_device *pdev,

enum pipe_format p_format = hk_format_to_pipe_format(vk_format);
/* D16S8 uses the existing independent D16 and S8 planes, as D32S8 does
* on G17P and M5. */
* across all generations. */
if (vk_format == VK_FORMAT_D16_UNORM_S8_UINT) {
if (!agx_chip_g17p_or_m5(pdev->dev.chip))
return 0;
p_format = PIPE_FORMAT_Z16_UNORM;
}
if (p_format == PIPE_FORMAT_NONE)
Expand Down Expand Up @@ -233,7 +231,7 @@ hk_get_image_plane_format_features(struct hk_physical_device *pdev,
/* Our image atomic lowering doesn't bother to handle linear */
if ((p_format == PIPE_FORMAT_R32_UINT || p_format == PIPE_FORMAT_R32_SINT ||
(p_format == PIPE_FORMAT_R32_FLOAT &&
agx_chip_g17p_or_m5(pdev->dev.chip))) &&
pdev->vk.supported_features.shaderImageFloat32Atomics)) &&
tiling == VK_IMAGE_TILING_OPTIMAL) {

features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT;
Expand Down
48 changes: 12 additions & 36 deletions src/asahi/vulkan/hk_physical_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ hk_get_device_extensions(const struct agx_device *dev,
.KHR_bind_memory2 = true,
.KHR_buffer_device_address = true,
.KHR_calibrated_timestamps = true,
.KHR_compute_shader_derivatives = true,
.KHR_copy_commands2 = true,
.KHR_create_renderpass2 = true,
.KHR_dedicated_allocation = true,
Expand Down Expand Up @@ -352,8 +353,8 @@ hk_get_device_extensions(const struct agx_device *dev,
.EXT_sampler_filter_minmax = false,
.EXT_scalar_block_layout = true,
.EXT_separate_stencil_usage = true,
.EXT_shader_atomic_float = false,
.EXT_shader_atomic_float2 = false,
.EXT_shader_atomic_float = true,
.EXT_shader_atomic_float2 = true,
.EXT_shader_image_atomic_int64 = false,
.EXT_shader_demote_to_helper_invocation = true,
.EXT_shader_module_identifier = true,
Expand All @@ -369,6 +370,7 @@ hk_get_device_extensions(const struct agx_device *dev,
.EXT_swapchain_maintenance1 = true,
#endif
.EXT_texel_buffer_alignment = true,
.EXT_texture_compression_astc_hdr = true,
.EXT_tooling_info = true,
.EXT_transform_feedback = true,

Expand Down Expand Up @@ -1092,21 +1094,16 @@ hk_get_device_features(
* fragment entry and prevent merging triangles across derivative quads.
*/
features->shaderQuadControl = dev->chip == AGX_CHIP_G17P;

/* Qualified on A18 Pro only. */
if (dev->chip == AGX_CHIP_G17P) {
features->computeDerivativeGroupQuads = true;
features->computeDerivativeGroupLinear = true;
features->textureCompressionASTC_HDR = true;
}
}

/* Compute derivatives are NIR quad-swap lowering plus explicit-gradient
* samples, both available on M5; quad control remains restricted to G17P. */
if (agx_chip_g17_m5(dev->chip)) {
features->computeDerivativeGroupQuads = true;
features->computeDerivativeGroupLinear = true;
}
/* Compute derivatives lower in NIR to quad swaps and explicit-gradient
* texture operations, available across all generations. */
features->computeDerivativeGroupQuads =
supported_extensions->KHR_compute_shader_derivatives;
features->computeDerivativeGroupLinear =
supported_extensions->KHR_compute_shader_derivatives;
features->textureCompressionASTC_HDR =
supported_extensions->EXT_texture_compression_astc_hdr;

/* A multiview promise for a stage this device does not expose is
* meaningless, so keep the pair consistent however the stage bits above
Expand Down Expand Up @@ -2304,27 +2301,6 @@ hk_create_drm_physical_device(struct vk_instance *_instance,
if (!hk_shader_fma_supported(pdev->dev.chip))
supported_extensions.KHR_shader_fma = false;

if (pdev->dev.chip == AGX_CHIP_G17P) {
/* Advanced blending is hardware-qualified on A18 Pro for every
* operation and advertised overlap/premultiplication mode, including
* coherent sequencing, across the bounded one-attachment profile. */
supported_extensions.KHR_compute_shader_derivatives = true;
supported_extensions.EXT_shader_atomic_float = true;
supported_extensions.EXT_shader_atomic_float2 = true;
supported_extensions.EXT_texture_compression_astc_hdr = true;
}

if (agx_chip_g17_m5(pdev->dev.chip))
supported_extensions.KHR_compute_shader_derivatives = true;

/* AGX3C has no witnessed native float atomic; agx_nir_lower_atomics turns
* fp32 add/min/max on buffers, shared memory and (lowered) images into
* compare-and-swap loops, so the same feature set is exact on M5. */
if (agx_chip_g17_m5(pdev->dev.chip)) {
supported_extensions.EXT_shader_atomic_float = true;
supported_extensions.EXT_shader_atomic_float2 = true;
}

struct vk_features supported_features;
/* G17P runs mesh shaders natively and task shaders in software. */
if (pdev->dev.chip == AGX_CHIP_G17P)
Expand Down
20 changes: 10 additions & 10 deletions src/asahi/vulkan/hk_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,29 +559,29 @@ hk_preprocess_nir(struct vk_physical_device *vk_pdev, nir_shader *nir,
UNUSED const struct vk_pipeline_robustness_state *rs)
{
hk_preprocess_nir_internal(vk_pdev, nir);
const enum agx_chip chip = ((struct hk_physical_device *)vk_pdev)->dev.chip;
/* G17P task shaders run as compute kernels, and mesh workgroups map
* invocations to lanes as compute does, so they take the same derivatives
* (meshAndTaskShaderDerivatives). */
const bool g17p_compute_derivatives =
((agx_chip_g17p_or_m5(chip) &&
/* Compute derivatives lower via NIR quad swaps and explicit-gradient
* samples across all chips; mesh/task derivatives follow
* meshAndTaskShaderDerivatives. */
const bool lower_compute_derivatives =
((vk_pdev->supported_features.computeDerivativeGroupQuads &&
nir->info.stage == MESA_SHADER_COMPUTE) ||
(chip == AGX_CHIP_G17P && (nir->info.stage == MESA_SHADER_TASK ||
nir->info.stage == MESA_SHADER_MESH))) &&
(vk_pdev->properties.meshAndTaskShaderDerivatives &&
(nir->info.stage == MESA_SHADER_TASK ||
nir->info.stage == MESA_SHADER_MESH))) &&
nir->info.derivative_group != DERIVATIVE_GROUP_NONE;
nir_lower_compute_system_values_options csv_options = {
/* Only vkCmdDispatchBase has a base workgroup. Task/mesh draws have
* none, and their root is the graphics arm: root.cs.base_group
* (byte 88) overlays root.draw.attrib_clamps[2..4] there. */
.has_base_workgroup_id = nir->info.stage == MESA_SHADER_COMPUTE,
};
if (g17p_compute_derivatives &&
if (lower_compute_derivatives &&
nir->info.derivative_group == DERIVATIVE_GROUP_QUADS) {
NIR_PASS(_, nir, agx_nir_lower_quad_derivative_ids);
csv_options.shuffle_local_ids_for_quad_derivatives = true;
}
NIR_PASS(_, nir, nir_lower_compute_system_values, &csv_options);
if (g17p_compute_derivatives)
if (lower_compute_derivatives)
NIR_PASS(_, nir, agx_nir_lower_compute_derivatives);
}

Expand Down