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
16 changes: 11 additions & 5 deletions src/asahi/compiler/agx_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,17 +1336,23 @@ agx3_tex_coord(const agx_instr *I, unsigned c)
bool agx3_tex_uniform_pair_unwitnessed(const agx_context *ctx,
const agx_instr *I, agx_index texture,
agx_index sampler);
/* Whether an M5 main-program FADD/FMUL/FFMA is a native uniform-operand form
* (agx3_uniform_float_encode). */
bool agx3_m5_float_native_uniform(const agx_context *ctx, const agx_instr *I);

/* Whether replacing source s of an M5 main-program FADD/FMUL/FFMA with
* `uniform` gives a native uniform-operand form (agx3_uniform_float_encode). */
bool agx3_m5_float_accepts_uniform(const agx_context *ctx, const agx_instr *I,
unsigned s, unsigned uniform,
enum agx_size size);

/* Whether replacing source s of an M5 main-program 32-bit ICMPSEL with
* `uniform` gives a native uniform-operand form (agx3_isel_encode). */
bool agx3_m5_isel_accepts_uniform(const agx_context *ctx, const agx_instr *I,
unsigned s, unsigned uniform,
enum agx_size size);
/* Whether an M5 main-program 32-bit ICMPSEL is a native uniform-operand form
* (agx3_isel_encode). */
bool agx3_m5_isel_native_uniform(const agx_context *ctx, const agx_instr *I);

/* Whether an M5 main-program 32-bit FCMPSEL is a native uniform-operand form
* (agx3_alu_fcmp_select32_gpu1). */
bool agx3_m5_fcmpsel_native_uniform(const agx_context *ctx, const agx_instr *I);

bool agx_instr_accepts_uniform(enum agx_isa_encoding encoding,
enum agx_opcode op, unsigned src_index,
Expand Down
46 changes: 27 additions & 19 deletions src/asahi/compiler/agx_lower_uniform_sources.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,12 @@ agx3_lower_m5_modified_fma_immediates(agx_context *ctx, agx_instr *I)
if (literal.type != AGX_INDEX_IMMEDIATE)
continue;

agx_index value = agx_mov_imm(
&b, 32, fui(agx_minifloat_decode(literal.value)));
value.abs = literal.abs;
value.neg = literal.neg;
I->src[s] = value;
uint32_t bits = fui(agx_minifloat_decode(literal.value));
if (literal.abs)
bits &= 0x7fffffffu;
if (literal.neg)
bits ^= 0x80000000u;
I->src[s] = agx_mov_imm(&b, 32, bits);
}
}

Expand Down Expand Up @@ -579,6 +580,12 @@ m5_float_uniforms_to_keep(const agx_context *ctx, const agx_instr *I,
return false;
}

bool
agx3_m5_float_native_uniform(const agx_context *ctx, const agx_instr *I)
{
return m5_native_float_uniform(ctx, I);
}

bool
agx3_m5_float_accepts_uniform(const agx_context *ctx, const agx_instr *I,
unsigned s, unsigned uniform,
Expand Down Expand Up @@ -688,21 +695,9 @@ m5_native_isel_uniform(const agx_context *ctx, const agx_instr *I)
}

bool
agx3_m5_isel_accepts_uniform(const agx_context *ctx, const agx_instr *I,
unsigned s, unsigned uniform, enum agx_size size)
agx3_m5_isel_native_uniform(const agx_context *ctx, const agx_instr *I)
{
if (ctx->key->dev.encoding != AGX_ISA_ENCODING_AGX3C ||
ctx->key->dev.emit_agx3d || ctx->is_preamble ||
I->op != AGX_OPCODE_ICMPSEL || s == 0 || s >= 4 || I->nr_srcs != 4 ||
size != AGX_SIZE_32 || (uniform & 1) || uniform >= 512)
return false;

agx_instr candidate = *I;
agx_index sources[4];
memcpy(sources, I->src, sizeof(sources));
candidate.src = sources;
sources[s] = agx_replace_index(sources[s], agx_uniform(uniform, size));
return m5_native_isel_uniform(ctx, &candidate);
return !ctx->key->dev.emit_agx3d && m5_native_isel_uniform(ctx, I);
}

/* On AGX3C, native uniform ISEL takes a uniform right comparand (cmp1_uniform)
Expand Down Expand Up @@ -822,6 +817,19 @@ m5_native_fsel_uniforms(const agx_context *ctx, const agx_instr *I,
agx3_alu_fcmp_select32_gpu1(&d, bytes, &length);
}

bool
agx3_m5_fcmpsel_native_uniform(const agx_context *ctx, const agx_instr *I)
{
if (ctx->key->dev.encoding != AGX_ISA_ENCODING_AGX3C ||
ctx->key->dev.emit_agx3d || ctx->is_preamble ||
I->op != AGX_OPCODE_FCMPSEL || I->nr_srcs != 4)
return false;
struct agx3_fsel32_gpu1_desc d;
uint8_t bytes[AGX3_ALU_MAX_LENGTH], length;
return agx3_m5_fcmpsel_gpu1_desc(ctx, I, true, &d) &&
agx3_alu_fcmp_select32_gpu1(&d, bytes, &length);
}

/* The uniform operands an M5 float select reads in place: every one when
* that encodes, otherwise the first one that encodes alone. A tied min/max
* keeps all of its uniforms or none, so its compared and selected operands
Expand Down
Loading