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/compiler/agx3_graphics_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ agx3_g17p_fragment_blend_constant_base(enum agx_chip chip,
unsigned occupied_halfs,
uint16_t *base)
{
if ((!agx_chip_native_agx3(chip) && !agx_chip_g17_m5(chip)) || !base)
if (!agx_chip_native_or_m5(chip) || !base)
return false;

const unsigned start = ALIGN_POT(MAX2(occupied_halfs, 8), 2);
Expand Down
2 changes: 1 addition & 1 deletion src/asahi/compiler/agx_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ uint64_t agx_gather_texcoords(nir_shader *nir);

void agx_preprocess_nir(nir_shader *nir);
void agx_preprocess_nir_g17p(nir_shader *nir);
/* For any native AGX3 chip (agx_native_graphics); passes validated on G17P
/* For any native AGX3 chip (agx_chip_native_agx3); passes validated on G17P
* alone check chip. */
void agx_preprocess_nir_native(nir_shader *nir, enum agx_chip chip);
void agx_preprocess_nir_g18g(nir_shader *nir);
Expand Down
8 changes: 3 additions & 5 deletions src/asahi/compiler/agx_register_allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ prefer_high_bank(const struct ra_ctx *rctx, const agx_instr *I, unsigned d,
enum ra_class cls, unsigned minimum, unsigned limit)
{
const enum agx_chip chip = rctx->shader->key->dev.chip;
if ((chip != AGX_CHIP_G17P && !agx_chip_g17_m5(chip)) ||
if (!agx_chip_g17p_or_m5(chip) ||
!rctx->shader->has_spill_pcopy_reserved || cls != RA_GPR ||
minimum != 0 || limit != rctx->bound[cls] ||
limit <= G17P_LOW_BANK_HALVES ||
Expand Down Expand Up @@ -1621,8 +1621,7 @@ static bool
pick_phi_source_agreement(struct ra_ctx *rctx, agx_instr *I, unsigned *out)
{
if (I->op != AGX_OPCODE_PHI ||
(rctx->shader->key->dev.chip != AGX_CHIP_G17P &&
!agx_chip_g17_m5(rctx->shader->key->dev.chip)))
!agx_chip_g17p_or_m5(rctx->shader->key->dev.chip))
return false;

enum ra_class cls = ra_class_for_index(I->dest[0]);
Expand Down Expand Up @@ -1659,8 +1658,7 @@ pick_phi_unclaimed(struct ra_ctx *rctx, agx_instr *I, unsigned d,
unsigned count, unsigned align, unsigned *out)
{
if (I->op != AGX_OPCODE_PHI ||
(rctx->shader->key->dev.chip != AGX_CHIP_G17P &&
!agx_chip_g17_m5(rctx->shader->key->dev.chip)))
!agx_chip_g17p_or_m5(rctx->shader->key->dev.chip))
return false;

enum ra_class cls = ra_class_for_index(I->dest[d]);
Expand Down
3 changes: 1 addition & 2 deletions src/asahi/compiler/agx_spill.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,8 +1245,7 @@ compute_w_entry_loop_header(struct spill_ctx *ctx)

BITSET_WORD *used = NULL;
unsigned room = 0;
if ((ctx->shader->key->dev.chip == AGX_CHIP_G17P ||
agx_chip_g17_m5(ctx->shader->key->dev.chip)) &&
if (agx_chip_g17p_or_m5(ctx->shader->key->dev.chip) &&
!ctx->remat_only) {
used = BITSET_CALLOC(ctx->n);
room = loop_room_for_live_through(ctx, used);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,10 @@ check_agx2_compute_shared_not_vectorized(void)
static bool
check_agx3_generic_preprocess_shared_byte_offsets(enum agx_chip chip)
{
/* G18G compiles as G17G and re-encodes as agx3d (agx_gather_device_key) */
const bool g18g = chip == AGX_CHIP_G18G;
const enum agx_isa_encoding encoding =
chip == AGX_CHIP_G17P ? AGX_ISA_ENCODING_AGX3B : AGX_ISA_ENCODING_AGX3C;
agx_chip_isa_encoding(g18g ? AGX_CHIP_G17G : chip);

nir_builder b = nir_builder_init_simple_shader(
MESA_SHADER_COMPUTE, &agx_nir_options,
Expand Down
133 changes: 18 additions & 115 deletions src/asahi/genxml/agx3_cmdstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,7 @@ agx3_cmdstream_load_le32(const uint8_t *src)
static inline bool
agx3_cdm_launch_target_grounded(enum agx_chip chip)
{
switch (chip) {
case AGX_CHIP_G15G:
case AGX_CHIP_G15S:
case AGX_CHIP_G15C:
case AGX_CHIP_G15D:
case AGX_CHIP_G16G:
case AGX_CHIP_G16S:
case AGX_CHIP_G16C:
case AGX_CHIP_G17P:
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
case AGX_CHIP_G18G:
return true;
default:
return false;
}
return agx_chip_has_record(chip, AGX_RECORD_CDM_LAUNCH);
}

/* Kept separate from the 40-byte direct-launch gate so later evidence for one
Expand All @@ -159,25 +143,9 @@ agx3_cdm_launch_target_grounded(enum agx_chip chip)
static inline bool
agx3_cdm_indirect_launch_target_grounded(enum agx_chip chip)
{
switch (chip) {
/* G18G: the same six-word launch; the template's upper half of word 4
* is 0. */
case AGX_CHIP_G18G:
case AGX_CHIP_G15G:
case AGX_CHIP_G15S:
case AGX_CHIP_G15C:
case AGX_CHIP_G15D:
case AGX_CHIP_G16G:
case AGX_CHIP_G16S:
case AGX_CHIP_G16C:
case AGX_CHIP_G17P:
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
return true;
default:
return false;
}
return agx_chip_has_record(chip, AGX_RECORD_CDM_INDIRECT_LAUNCH);
}

/* Keep the nine-word family independently gated: its presence was checked
Expand All @@ -186,24 +154,8 @@ agx3_cdm_indirect_launch_target_grounded(enum agx_chip chip)
static inline bool
agx3_cdm_indirect_launch_36_target_grounded(enum agx_chip chip)
{
switch (chip) {
/* G18G: the same nine-word launch. */
case AGX_CHIP_G18G:
case AGX_CHIP_G15G:
case AGX_CHIP_G15S:
case AGX_CHIP_G15C:
case AGX_CHIP_G15D:
case AGX_CHIP_G16G:
case AGX_CHIP_G16S:
case AGX_CHIP_G16C:
case AGX_CHIP_G17P:
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
return true;
default:
return false;
}
return agx_chip_has_record(chip, AGX_RECORD_CDM_INDIRECT_LAUNCH_36);
}

/* The 48-bit link form holds in every scoped base and aggregate family.
Expand All @@ -212,22 +164,7 @@ agx3_cdm_indirect_launch_36_target_grounded(enum agx_chip chip)
static inline bool
agx3_cdm_stream_link_target_grounded(enum agx_chip chip)
{
switch (chip) {
case AGX_CHIP_G15G:
case AGX_CHIP_G15S:
case AGX_CHIP_G15C:
case AGX_CHIP_G15D:
case AGX_CHIP_G16G:
case AGX_CHIP_G16S:
case AGX_CHIP_G16C:
case AGX_CHIP_G17P:
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
return true;
default:
return false;
}
return agx_chip_has_record(chip, AGX_RECORD_CDM_STREAM_LINK);
}

static inline bool
Expand Down Expand Up @@ -524,7 +461,7 @@ agx3_cdm_stream_link_unpack(
static inline bool
agx3_cdm_link_padding_target_grounded(enum agx_chip chip)
{
return chip != AGX_CHIP_G18G && agx3_cdm_launch_target_grounded(chip);
return agx_chip_has_record(chip, AGX_RECORD_CDM_LINK_PADDING);
}

static inline bool
Expand Down Expand Up @@ -579,23 +516,7 @@ agx3_cdm_link_padding_unpack(
static inline bool
agx3_cdm_barrier_target_grounded(enum agx_chip chip)
{
switch (chip) {
case AGX_CHIP_G15G:
case AGX_CHIP_G15S:
case AGX_CHIP_G15C:
case AGX_CHIP_G15D:
case AGX_CHIP_G16G:
case AGX_CHIP_G16S:
case AGX_CHIP_G16C:
case AGX_CHIP_G17P:
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
case AGX_CHIP_G18G:
return true;
default:
return false;
}
return agx_chip_has_record(chip, AGX_RECORD_CDM_BARRIER);
}

static inline bool
Expand All @@ -604,20 +525,12 @@ agx3_cdm_barrier_flags_grounded(enum agx_chip chip, uint8_t flags)
if (!agx3_cdm_barrier_target_grounded(chip) || flags > 0xf)
return false;

switch (chip) {
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
return true;
case AGX_CHIP_G18G:
/* The flag-free word is captured on G18G (compute-add), and flags=5
* is grounded on hardware from rel24b+ chained launches: the weak
* flag-free tail does not give write visibility and flag-free chains
* hung the CDM (hk_cmd_dispatch.c). */
return flags == 0 || flags == 5;
default:
return flags == 0 || flags == 0x5;
}
/* The M5 parts take every flag combination, the other chips the flag-free
* word and flags=5. On G18G the flag-free word is captured (compute-add),
* and flags=5 is grounded on hardware from rel24b+ chained launches: the
* weak flag-free tail does not give write visibility and flag-free chains
* hung the CDM (hk_cmd_dispatch.c). */
return agx_chip_g17_m5(chip) || flags == 0 || flags == 5;
}

/* The wide-visibility barrier forms are only known on G15S and G16G with
Expand All @@ -627,8 +540,7 @@ agx3_cdm_barrier_wide_visibility_grounded(enum agx_chip chip)
{
/* G15C (M3 Max) is G15S's generation with more clusters and takes the
* same forms. */
return chip == AGX_CHIP_G15G || chip == AGX_CHIP_G15S ||
chip == AGX_CHIP_G15C || chip == AGX_CHIP_G16G;
return agx_chip_has_record(chip, AGX_RECORD_CDM_BARRIER_WIDE_VISIBILITY);
}

#define AGX3_CDM_BARRIER_WIDE_VISIBILITY UINT32_C(0x0002009e)
Expand All @@ -655,15 +567,7 @@ agx3_cdm_barrier_wide_visibility_grounded(enum agx_chip chip)
static inline bool
agx3_cdm_barrier_flush_memory_grounded(enum agx_chip chip)
{
switch (chip) {
case AGX_CHIP_G17P:
case AGX_CHIP_G17G:
case AGX_CHIP_G17S:
case AGX_CHIP_G17C:
return true;
default:
return false;
}
return agx_chip_has_record(chip, AGX_RECORD_CDM_BARRIER_FLUSH_MEMORY);
}

static inline uint32_t
Expand Down Expand Up @@ -762,7 +666,7 @@ agx3_cdm_sstt_flush_invalidate_pack(
return false;

memset(packed, 0, AGX3_CDM_SSTT_FLUSH_INVALIDATE_SIZE);
if (chip != AGX_CHIP_G17P && !agx_chip_g17_m5(chip))
if (!agx_chip_g17p_or_m5(chip))
return false;

agx3_cmdstream_store_le32(packed, UINT32_C(0x60024102));
Expand All @@ -774,7 +678,7 @@ agx3_cdm_sstt_flush_invalidate_validate(enum agx_chip chip,
const void *packed,
size_t available)
{
return (chip == AGX_CHIP_G17P || agx_chip_g17_m5(chip)) && packed &&
return agx_chip_g17p_or_m5(chip) && packed &&
available >= AGX3_CDM_SSTT_FLUSH_INVALIDATE_SIZE &&
agx3_cmdstream_load_le32((const uint8_t *)packed) ==
UINT32_C(0x60024102);
Expand All @@ -786,7 +690,7 @@ agx3_cdm_sstt_flush_invalidate_validate(enum agx_chip chip,
static inline bool
agx3_cdm_substream_barrier_target_grounded(enum agx_chip chip)
{
return chip != AGX_CHIP_G18G && agx3_cdm_barrier_target_grounded(chip);
return agx_chip_has_record(chip, AGX_RECORD_CDM_SUBSTREAM_BARRIER);
}

static inline bool
Expand Down Expand Up @@ -847,8 +751,7 @@ agx3_cdm_substream_barrier_unpack(
static inline bool
agx3_cdm_secondary_barrier_target_grounded(enum agx_chip chip)
{
return chip == AGX_CHIP_G17G || chip == AGX_CHIP_G17S ||
chip == AGX_CHIP_G17C;
return agx_chip_has_record(chip, AGX_RECORD_CDM_SECONDARY_BARRIER);
}

static inline bool
Expand Down
3 changes: 1 addition & 2 deletions src/asahi/lib/agx3_cdm_direct_launch_semantic_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ agx3_cdm_direct_dimension_word(uint8_t dimensions, uint32_t *word)
static bool
agx3_cdm_direct_g15x_bit31_allowed(enum agx_chip chip)
{
return chip == AGX_CHIP_G15G || chip == AGX_CHIP_G15S ||
chip == AGX_CHIP_G15C || chip == AGX_CHIP_G15D;
return agx_chip_command_stream_generation(chip) == AGX_CS_GENERATION_G15;
}

bool
Expand Down
3 changes: 1 addition & 2 deletions src/asahi/lib/agx3_compute_program_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ agx3_g17p_native_compute_launch_pack(

memset(packed, 0, AGX3_CDM_DIRECT_LAUNCH_SIZE);
if (!program || !grid ||
(!agx_chip_native_agx3(program->chip) &&
!agx_chip_g17_m5(program->chip) && program->chip != AGX_CHIP_G18G) ||
!agx_chip_agx3_path(program->chip) ||
program->program_va == 0 ||
program->program_va > UINT64_C(0xffffffffffff) ||
(program->program_va & (AGX_IOTO_PROGRAM_ALIGNMENT - 1)) != 0 ||
Expand Down
Loading