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
6 changes: 3 additions & 3 deletions src/asahi/compiler/agx_nir_lower_fma_rte.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ fma_rte_applies(const nir_shader *shader)
!(mode & FLOAT_CONTROLS_DENORM_PRESERVE_FP32);
}

/* G17P and the AGX3C parts detect FP32 FMA tininess before rounding. */
/* Apple Silicon GPUs (AGX2 G13/G14 and AGX3 G15/G16/G17) detect FP32 FMA
* tininess before rounding. */
static bool
fma_tininess_before_rounding(enum agx_chip chip)
{
return chip == AGX_CHIP_G17P ||
agx_chip_isa_encoding(chip) == AGX_ISA_ENCODING_AGX3C;
return chip != AGX_CHIP_UNKNOWN;
}

/*
Expand Down
9 changes: 5 additions & 4 deletions src/asahi/compiler/test/test-rte-fma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ TEST(NativeFMA, WeakFMAIsNotRepaired)

TEST(NativeFMA, RepairTakesOnlyStrictFMA)
{
for (enum agx_chip chip : {AGX_CHIP_G17P, AGX_CHIP_G17C, AGX_CHIP_G16G}) {
for (enum agx_chip chip : {AGX_CHIP_G13G, AGX_CHIP_G14G, AGX_CHIP_G15G,
AGX_CHIP_G16G, AGX_CHIP_G17P, AGX_CHIP_G17C}) {
SCOPED_TRACE(chip);
nir_builder b = nir_builder_init_simple_shader(
MESA_SHADER_COMPUTE, &agx_nir_options, "strict and weak FMA");
Expand All @@ -128,7 +129,7 @@ TEST(NativeFMA, RepairTakesOnlyStrictFMA)
nir_store_global(&b, nir_ffma_weak(&b, x, y, z), nir_imm_int64(&b, 8),
.align_mul = 4);

const bool repaired = chip != AGX_CHIP_G16G;
const bool repaired = true;
EXPECT_EQ(agx_nir_lower_fma_rte(b.shader, chip), repaired);
nir_validate_shader(b.shader, "strict and weak FMA");

Expand Down Expand Up @@ -265,13 +266,13 @@ TEST(NativeFMA, PreserveModeIsUnchanged)
EXPECT_EQ(preserve, rte_preserve);
}

TEST(NativeFMA, LegacyAndOtherAGX3ChipsAreUnchanged)
TEST(NativeFMA, AllGenerationsRepairExplicitRTE)
{
for (enum agx_chip chip : {AGX_CHIP_G13G, AGX_CHIP_G14G, AGX_CHIP_G15S, AGX_CHIP_G16G}) {
auto plain = compile_native_fma(0, 1, chip);
auto rte =
compile_native_fma(FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32, 1, chip);
EXPECT_FALSE(plain.empty());
EXPECT_EQ(plain, rte);
EXPECT_NE(plain, rte);
}
}
3 changes: 1 addition & 2 deletions src/asahi/lib/agx_chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ enum agx_chip_quirk {

/* The native chips that are not G17P: G15G, G15S, G15C and G16G. */
#define AGX_QUIRKS_NATIVE_PRE_G17 \
(AGX_QUIRKS_NATIVE | AGX_QUIRK_EXPLICIT_ROBUST_IMAGE_BOUNDS | \
AGX_QUIRK_INEXACT_FMA32)
(AGX_QUIRKS_NATIVE | AGX_QUIRK_EXPLICIT_ROBUST_IMAGE_BOUNDS)

#define AGX_QUIRKS_G17P \
(AGX_QUIRKS_NATIVE | AGX_QUIRK_NATIVE_RENDER_CONTEXT | \
Expand Down
2 changes: 1 addition & 1 deletion src/asahi/lib/tests/test-chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static unsigned checks;
"0000 01110 0100 10000 0 0") \
ROW(agx_chip_tri_merge_across_side_effects(c), "0000 00000 0000 10000 0 0") \
ROW(agx_chip_image_load_misses_own_store(c), "0000 00000 0000 10000 0 0") \
ROW(agx_chip_exact_fma32(c), "1111 10001 1011 11111 1 1") \
ROW(agx_chip_exact_fma32(c), "1111 11111 1111 11111 1 1") \
ROW(agx_chip_sampler_has_lod_bias(c), "0000 00000 1111 11000 0 0") \
ROW(agx_chip_native_preamble(c), "0000 00000 0000 10000 0 0") \
ROW(agx_chip_query_ti_spill(c), "0000 00000 0000 10000 0 0") \
Expand Down
21 changes: 2 additions & 19 deletions src/asahi/vulkan/hk_physical_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ hk_cache_identity(const uint8_t build_sha[32], const struct agx_device *dev,
memcpy(disk_cache_id, blake3, sizeof(*disk_cache_id));
}

/* VK_KHR_shader_fma: G17P with its explicit-RTE tininess repair
* (agx_nir_lower_fma_rte()) and M5. G13-G15 do not pass the newly exposed
* cases. */
static bool
hk_shader_fma_supported(enum agx_chip chip)
{
return agx_chip_g17p_or_m5(chip) &&
agx_chip_exact_fma32(chip);
}

static void
hk_get_device_extensions(const struct agx_device *dev,
const struct hk_instance *instance,
Expand Down Expand Up @@ -686,13 +676,10 @@ hk_get_device_features(

/* VK_KHR_shader_float_controls2 */
.shaderFloatControls2 = true,
.shaderFmaFloat16 = true,
.shaderFmaFloat32 = true,
.shaderFmaFloat64 = false,

/* VK_KHR_shader_fma */
.shaderFmaFloat16 = hk_shader_fma_supported(dev->chip),
.shaderFmaFloat32 = hk_shader_fma_supported(dev->chip),
.shaderFmaFloat16 = true,
.shaderFmaFloat32 = true,
.shaderFmaFloat64 = false,

/* VK_KHR_shader_maximal_reconvergence */
Expand Down Expand Up @@ -2300,10 +2287,6 @@ hk_create_drm_physical_device(struct vk_instance *_instance,
pdev->dev.chip == AGX_CHIP_G17P;
}

/* VK_KHR_shader_fma makes shaderFmaFloat32 mandatory. */
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
Expand Down