Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fad9452
pvr/g3: A7 transfers as compute copies, and linear images
ricktav Nov 28, 2026
62c8f46
pvr/g3: diagnostics for the A7's transfer kernel
ricktav Nov 28, 2026
58c6415
pco: on the A7, a ld's destination never shares its address register
ricktav Nov 28, 2026
a9a9375
pvr/g3: separate copy and fill transfer kernels on the A7
ricktav Nov 28, 2026
a07480f
pco, pvr/g3: no notequal test on the A7
ricktav Nov 28, 2026
d9be950
pvr/g3: depth/stencil attachments on the A7's upstream draw path
ricktav Nov 28, 2026
6edb5ad
pvr/g3: colour LOAD and blending on the A7's upstream draw path
ricktav Nov 28, 2026
66ab854
pvr/g3: the A7 load op's texture state through PDS_BGRND1_BASE
ricktav Nov 28, 2026
73c3510
pvr/g3: the full render path by default on the A7, and DONT_CARE renders
ricktav Nov 28, 2026
5d57779
pvr/g3: byte-granular A7 transfers (8/16-bit formats, sub-rectangles)
ricktav Nov 28, 2026
243cff6
pvr/g3: A7 clears of F16-per-channel targets (sRGB, 10-bit, 16-bit fl…
ricktav Nov 29, 2026
ae4279d
pvr: align the load-op PDS staging buffer by hand
ricktav Nov 29, 2026
be5d749
pvr/g3: Firefox on the A7: no fs_meta register, the clear's NIR options
ricktav Nov 29, 2026
26cd1d3
pvr/g3: vkCmdClearAttachments on the A7 as an ordinary draw
ricktav Nov 29, 2026
da41ea6
pvr/g3: scaling blits and mip chains on the A7
ricktav Nov 29, 2026
6ba676f
pvr/g3: PVR_G3_LOG_COPY logs the A7's copy, fill and dispatch jobs
ricktav Nov 29, 2026
68c8d63
pvr/wsi: Two-image Wayland swapchains on the A7
ricktav Nov 29, 2026
8e0ac49
pvr/g3: Split the A7's 2D copies over up to 64 workgroups
ricktav Nov 29, 2026
3a6e61c
zink: the A7 (PowerVR G3) as G5P, with two-image swapchains
ricktav Nov 29, 2026
c28d5b7
pvr/g3: One sample on the A7
ricktav Nov 29, 2026
06222c5
zink: No render-to-texture MSAA without multisampled attachments
ricktav Nov 29, 2026
6e43248
pvr/g3: No dual-source blending on the A7
ricktav Nov 30, 2026
a778090
pco/usclib: Size, levels and base level of a linear texture state
ricktav Nov 30, 2026
34c4e40
pvr/g3: Size the clear quad's vertex buffer
ricktav Nov 30, 2026
97c92fc
pvr/g3: Advertise the texel buffer elements the A7 addresses
ricktav Nov 30, 2026
45d17e9
pvr/g3: Say why the A7 has no dual-source blending
ricktav Nov 30, 2026
29e4bf6
Merge main into a7/desktop
henrikklee Dec 2, 2026
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
14 changes: 12 additions & 2 deletions src/gallium/drivers/zink/zink_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -3610,7 +3610,13 @@ begin_rendering(struct zink_context *ctx, bool check_attachment_shadow)
ctx->dynamic_fb.attachments[i].resolveImageView = iv;
ctx->dynamic_fb.attachments[i].resolveImageLayout = res->layout;

iv = zink_create_transient_surface(ctx, &ctx->fb_state.cbufs[i], ctx->fb_state.cbufs[i].nr_samples)->image_view;
struct zink_surface *transient_surf =
zink_create_transient_surface(ctx, &ctx->fb_state.cbufs[i], ctx->fb_state.cbufs[i].nr_samples);
/* no multisampled image (out of memory, or samples the driver cannot make): no render pass,
* so the draw is skipped as for a dead swapchain instead of rendering into a null view */
if (!transient_surf)
return 0;
iv = transient_surf->image_view;
struct zink_resource *transient_res = res->transient;
prep_fb_attachment(ctx, transient_res, i);
ctx->dynamic_fb.attachments[i].imageLayout = transient_res->layout;
Expand Down Expand Up @@ -3661,7 +3667,11 @@ begin_rendering(struct zink_context *ctx, bool check_attachment_shadow)
ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].resolveImageView = iv;
ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].resolveImageLayout = res->layout;

iv = zink_create_transient_surface(ctx, &ctx->fb_state.zsbuf, ctx->fb_state.zsbuf.nr_samples)->image_view;
struct zink_surface *transient_surf =
zink_create_transient_surface(ctx, &ctx->fb_state.zsbuf, ctx->fb_state.zsbuf.nr_samples);
if (!transient_surf)
return 0;
iv = transient_surf->image_view;
struct zink_resource *transient_res = res->transient;
prep_fb_attachment(ctx, transient_res, ctx->fb_state.nr_cbufs);
ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].imageLayout = transient_res->layout;
Expand Down
5 changes: 4 additions & 1 deletion src/gallium/drivers/zink/zink_kopper.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ kopper_CreateSwapchain(struct zink_screen *screen, struct kopper_displaytarget *
/* A/B knob for the drawable count (CAMetalLayer defaults to 3).
* Keep the default rule until measurements decide the image count.
*/
const int64_t images = debug_get_option_g5p_swapchain_images();
/* The A7 (1 GB, GPU memory is pinned RAM): two images unless the knob says otherwise */
int64_t images = debug_get_option_g5p_swapchain_images();
if (!images && screen->is_g3)
images = 2;
if (images >= 2 && images <= 8)
want = MAX2(cswap->scci.minImageCount, (uint32_t)images);
}
Expand Down
3 changes: 2 additions & 1 deletion src/gallium/drivers/zink/zink_render_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ zink_render_attachment_shadow(struct zink_context *ctx, uint32_t attachment_shad

bool blitting = ctx->blitting;
u_foreach_bit(i, attachment_shadow_mask) {
zink_create_transient_surface(ctx, &ctx->fb_state.cbufs[i], ctx->fb_state.cbufs[i].nr_samples);
if (!zink_create_transient_surface(ctx, &ctx->fb_state.cbufs[i], ctx->fb_state.cbufs[i].nr_samples))
continue; /* begin_rendering() then starts no render pass: the draw is skipped */
struct pipe_resource *src = ctx->fb_state.cbufs[i].texture;
struct zink_resource *res = zink_resource(src);
struct zink_resource *transient = res->transient;
Expand Down
11 changes: 9 additions & 2 deletions src/gallium/drivers/zink/zink_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,10 @@ zink_init_screen_caps(struct zink_screen *screen)

caps->draw_vertex_state = screen->info.have_EXT_vertex_input_dynamic_state;

caps->surface_sample_count = screen->vk_version >= VK_MAKE_VERSION(1,2,0);
/* EXT_multisampled_render_to_texture renders into transient multisampled images: none
* without multisampled colour attachments (the A7) */
caps->surface_sample_count = screen->vk_version >= VK_MAKE_VERSION(1,2,0) &&
(screen->info.props.limits.framebufferColorSampleCounts & ~VK_SAMPLE_COUNT_1_BIT);

caps->shader_group_vote =
(screen->info.have_vulkan11 &&
Expand Down Expand Up @@ -3892,8 +3895,12 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev
}

/* Apple A9 (G5P, the PowerVR Vulkan driver): its memory, synchronization and lost-device handling */
/* The A7 (G3) runs the same firmware interface and has 1 GB: it shares G5P's memory, synchronization
* and lost-device handling. */
screen->is_g3 = screen->info.driver_props.driverID == VK_DRIVER_ID_IMAGINATION_OPEN_SOURCE_MESA &&
!strncmp(screen->info.driver_props.driverName, "Mesa PowerVR G3", 15);
screen->is_g5p = screen->info.driver_props.driverID == VK_DRIVER_ID_IMAGINATION_OPEN_SOURCE_MESA &&
!strcmp(screen->info.driver_props.driverName, "Mesa PowerVR G5P");
(!strcmp(screen->info.driver_props.driverName, "Mesa PowerVR G5P") || screen->is_g3);
screen->is_g5p_a8 = screen->is_g5p && !strcmp(screen->info.props.deviceName, "PowerVR Apple A8");
screen->precise_sync = screen->is_g5p;
screen->frames_in_flight = zink_default_frames_in_flight(screen->info.driver_props.driverID);
Expand Down
1 change: 1 addition & 0 deletions src/gallium/drivers/zink/zink_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,7 @@ struct zink_screen {
bool precise_sync;
bool is_g5p;
bool is_g5p_a8; /* the A8 on the G5P driver: no texel fetch (its form is not captured) */
bool is_g3; /* the A7 (G3 driver): G5P plus two-image swapchains by default */

const char *vendor_name;
const char *device_name;
Expand Down
16 changes: 16 additions & 0 deletions src/imagination/g3/g3_compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ struct g3_program {
unsigned usc_temps; /* USC temporaries the program allocates */
unsigned entry_offset; /* the entry point's offset in code */
unsigned num_pool; /* 32-bit constants outside Rogue's table 0..31, from the unified store */
unsigned num_params; /* the first pool entries are per-dispatch parameters (internal programs) */
bool movi_consts; /* input: 32-bit constants as movi32 immediates, not the pool (diagnostics) */
uint32_t pool[G3_MAX_POOL];
unsigned shmem_size; /* threadgroup memory bytes per workgroup, in a buffer the dispatch allocates */
/* the transfer kernel only: workgroup g copies the rows g * band_rows .. of the region in pool (its source,
* destination and height rebased per workgroup in the PDS data), so the workgroups spread over the clusters;
* 0: one workgroup */
unsigned band_rows;
unsigned num_buffers;
struct {
uint8_t set, binding;
Expand Down Expand Up @@ -140,6 +146,16 @@ unsigned g3_pds_data(const struct g3_program *p, uint32_t usc_offset, const uint
* from spirv_to_nir with g3_pco_spirv_options()/g3_pco_nir_options().
*/
bool g3_compile_pco(void *pco_ctx, struct nir_shader *nir, struct g3_program *out);

/* The A7's transfer kernel (g3_pco.c): its parameters, pool entries 0..G3_COPY_PARAMS-1 */
enum {
G3_COPY_SRC_LO, G3_COPY_SRC_HI, G3_COPY_DST_LO, G3_COPY_DST_HI, G3_COPY_WIDTH /* dwords */, G3_COPY_HEIGHT,
G3_COPY_SRC_PITCH /* bytes */, G3_COPY_DST_PITCH, G3_COPY_FILL, G3_COPY_MODE /* 0 copy, 1 fill */,
G3_COPY_PARAMS
};
bool g3_nir_lower_ne(struct nir_shader *nir);
bool g3_build_copy(void *pco_ctx, struct g3_program *out, const uint32_t *imm, bool bypass, bool fill_only);
bool g3_build_copy_bytes(void *pco_ctx, struct g3_program *out, bool fill_only);
const struct spirv_to_nir_options *g3_pco_spirv_options(void);
const struct nir_shader_compiler_options *g3_pco_nir_options(void);

Expand Down
189 changes: 187 additions & 2 deletions src/imagination/g3/g3_pco.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,35 @@ shl_to_mul(nir_builder *b, nir_instr *instr, void *data)
return true;
}

/*
* The A7's test op has no working "ne": on the J71 (overlay 15) dne, b = a != 50 ? 1000 : 2000, came out
* wrong in 33 of 64 lanes, and the transfer kernel's mode != 0 select stored its fill value. Tests that ran:
* ge, g, z, gz. So a != b on integers is (a ^ b) > 0 unsigned (xor, then tst g after trans_cmp's swap), and
* on floats a < b || b < a (two tests g; a NaN operand gives false, not true).
*/
static bool
lower_ne(nir_builder *b, nir_instr *instr, void *data)
{
if (instr->type != nir_instr_type_alu)
return false;
nir_alu_instr *alu = nir_instr_as_alu(instr);
if (alu->op != nir_op_ine && alu->op != nir_op_fneu)
return false;
b->cursor = nir_before_instr(instr);
nir_def *x = nir_mov_alu(b, alu->src[0], alu->def.num_components);
nir_def *y = nir_mov_alu(b, alu->src[1], alu->def.num_components);
nir_def *r = alu->op == nir_op_ine ? nir_ult(b, nir_imm_intN_t(b, 0, x->bit_size), nir_ixor(b, x, y))
: nir_ior(b, nir_flt(b, x, y), nir_flt(b, y, x));
nir_def_replace(&alu->def, r);
return true;
}

bool
g3_nir_lower_ne(struct nir_shader *nir)
{
return nir_shader_instructions_pass(nir, lower_ne, nir_metadata_control_flow, NULL);
}

/* pco's min (O_MIN) tests "less" in its own encoding: as a select of a comparison, which trans_cmp() swaps */
static bool
lower_min(nir_builder *b, nir_instr *instr, void *data)
Expand Down Expand Up @@ -331,7 +360,8 @@ const_to_pool(nir_builder *b, nir_instr *instr, void *data)
return false;
}
unsigned i;
for (i = 0; i < st->p->num_pool && st->p->pool[i] != v; i++)
/* the first num_params entries are the caller's parameters (g3_compile_pco()), never shared */
for (i = st->p->num_params; i < st->p->num_pool && st->p->pool[i] != v; i++)
;
if (i == st->p->num_pool) {
if (i == G3_MAX_POOL) {
Expand Down Expand Up @@ -438,6 +468,8 @@ g3_pco_check(pco_shader *s, struct g3_program *p)
if (op == PCO_TST_OP_MAIN_LESS || op == PCO_TST_OP_MAIN_LEQUAL)
return refuse(p, "a %s test (the A7's test op has no fourth bit)",
op == PCO_TST_OP_MAIN_LESS ? "less" : "lequal");
if (op == PCO_TST_OP_MAIN_NOTEQUAL)
return refuse(p, "a notequal test (wrong on the A7: lower_ne())");
}
pco_instr *be = igrp->hdr.alutype == PCO_ALUTYPE_MAIN ? igrp->instrs[PCO_OP_PHASE_BACKEND] : NULL;
if (!be || be->op != PCO_OP_ST32)
Expand All @@ -464,7 +496,14 @@ g3_compile_pco(void *pco, struct nir_shader *nir, struct g3_program *out)
struct lower_state st = { .p = out };
bool ok = false;

/* an internal program's parameters (pvr_arch_g3_compute.c's copy kernel): pool entries 0..num_params-1,
* unified registers G3_PCO_BUFFER0 + i with no buffers, each dispatch's own values */
const unsigned num_params = out->num_params;
const bool movi_consts = out->movi_consts;
memset(out, 0, sizeof(*out));
out->num_params = num_params;
out->movi_consts = movi_consts;
out->num_pool = num_params;
out->pco = true;
if (nir->info.stage != MESA_SHADER_COMPUTE) {
refuse(out, "a non-compute shader");
Expand Down Expand Up @@ -528,7 +567,9 @@ g3_compile_pco(void *pco, struct nir_shader *nir, struct g3_program *out)
struct pool_state ps = { .p = out, .base = G3_PCO_BUFFER0 + 2 * out->num_buffers };
nir_shader_instructions_pass(nir, shl_to_mul, nir_metadata_control_flow, NULL);
nir_shader_instructions_pass(nir, lower_min, nir_metadata_control_flow, NULL);
nir_shader_instructions_pass(nir, const_to_pool, nir_metadata_control_flow, &ps);
g3_nir_lower_ne(nir);
if (!out->movi_consts)
nir_shader_instructions_pass(nir, const_to_pool, nir_metadata_control_flow, &ps);
nir_opt_dce(nir);
if (ps.failed) {
refuse(out, "more than %u 32-bit constants outside 0..31", G3_MAX_POOL);
Expand Down Expand Up @@ -596,3 +637,147 @@ g3_compile_pco(void *pco, struct nir_shader *nir, struct g3_program *out)
ralloc_free(mem_ctx);
return ok;
}

/*
* The A7's transfer kernel (pvr_arch_g3_compute.c g3_cmd_copy()): one workgroup of 32 lanes copies or fills a 2D
* region of dwords, lane l taking the dwords l, l + 32, .. of each row, rows one after another. Only forms that
* ran on the J71: ld/st with a wdf, loops on a tst ge (ploop), imadd, movc. Its parameters are pool entries
* (G3_COPY_*: unified registers 8 + i, written by each dispatch's PDS), so one program serves every transfer.
*/
bool
g3_build_copy(void *pco_ctx, struct g3_program *out, const uint32_t *imm, bool bypass, bool fill_only)
{
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, g3_pco_nir_options(), "a7-copy");
b.shader->info.workgroup_size[0] = 32;
b.shader->info.workgroup_size[1] = 1;
b.shader->info.workgroup_size[2] = 1;
/* imm: the parameters baked in as constants (diagnostics: no parameter registers) */
#define P(i) (imm ? nir_imm_int(&b, imm[i]) : nir_load_vtxin_pco(&b, 1, nir_imm_int(&b, G3_PCO_BUFFER0 + (i))))
nir_def *src_lo = P(G3_COPY_SRC_LO), *src_hi = P(G3_COPY_SRC_HI);
nir_def *dst_lo = P(G3_COPY_DST_LO), *dst_hi = P(G3_COPY_DST_HI);
nir_def *w = P(G3_COPY_WIDTH), *h = P(G3_COPY_HEIGHT);
nir_def *sp = P(G3_COPY_SRC_PITCH), *dp = P(G3_COPY_DST_PITCH);
nir_def *fill = P(G3_COPY_FILL), *mode = P(G3_COPY_MODE);
#undef P
nir_def *lane = nir_load_local_invocation_index(&b);
nir_variable *yv = nir_local_variable_create(b.impl, glsl_uint_type(), "y");
nir_variable *xv = nir_local_variable_create(b.impl, glsl_uint_type(), "x");
nir_store_var(&b, yv, nir_imm_int(&b, 0), 1);
nir_push_loop(&b);
{
nir_def *y = nir_load_var(&b, yv);
nir_break_if(&b, nir_uge(&b, y, h));
nir_store_var(&b, xv, lane, 1);
nir_push_loop(&b);
{
nir_def *x = nir_load_var(&b, xv);
nir_break_if(&b, nir_uge(&b, x, w));
nir_def *x4 = nir_imul_imm(&b, x, 4);
nir_def *soff = nir_iadd(&b, nir_imul(&b, y, sp), x4);
nir_def *doff = nir_iadd(&b, nir_imul(&b, y, dp), x4);
/* no carry: transfers stay within one 4 GiB window (the A7's heaps) */
/* bypass: the ld skips the MCU cache (diagnostics). Copy and fill are two programs: with one, a select on
* the mode register (tst ne, movc) stored the fill value in copy mode on the J71 (overlays 12-14) */
(void)mode;
nir_def *v = fill_only ? fill
: nir_load_global_2x32(&b, 1, 32, nir_vec2(&b, nir_iadd(&b, src_lo, soff), src_hi),
.access = bypass ? ACCESS_COHERENT : 0);
nir_store_global_2x32(&b, v, nir_vec2(&b, nir_iadd(&b, dst_lo, doff), dst_hi), .write_mask = 1);
nir_store_var(&b, xv, nir_iadd_imm(&b, x, 32), 1);
}
nir_pop_loop(&b, NULL);
nir_store_var(&b, yv, nir_iadd_imm(&b, y, 1), 1);
}
nir_pop_loop(&b, NULL);
nir_lower_vars_to_ssa(b.shader);
memset(out, 0, sizeof(*out));
out->num_params = imm ? 0 : G3_COPY_PARAMS;
out->movi_consts = imm != NULL;
return g3_compile_pco(pco_ctx, b.shader, out);
}

/*
* The A7's byte-granular transfer kernel (pvr_arch_g3_compute.c): rows of any byte length at any byte offset
* and pitch (8- and 16-bit formats, sub-rectangles). Lane l writes destination dwords l, l + 32, .. of each row,
* built from the source bytes with shifts and masks (bitwise groups that ran: r8, pbits), and keeps the bytes of
* an edge dword outside the row (a read-modify-write; rows run one after another in the 32 lanes, so a dword two
* rows share is never written by two lanes at once). Parameters as g3_build_copy(), WIDTH in bytes; fill_only
* stores the 32-bit FILL pattern (already replicated for 8/16-bit texels).
*/
static nir_def *
al4(nir_builder *b, nir_def *x)
{
return nir_ishl_imm(b, nir_ushr_imm(b, x, 2), 2); /* x & ~3 without the constant */
}

bool
g3_build_copy_bytes(void *pco_ctx, struct g3_program *out, bool fill_only)
{
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, g3_pco_nir_options(), "a7-copy-bytes");
b.shader->info.workgroup_size[0] = 32;
b.shader->info.workgroup_size[1] = 1;
b.shader->info.workgroup_size[2] = 1;
#define P(i) nir_load_vtxin_pco(&b, 1, nir_imm_int(&b, G3_PCO_BUFFER0 + (i)))
nir_def *src_lo = P(G3_COPY_SRC_LO), *src_hi = P(G3_COPY_SRC_HI);
nir_def *dst_lo = P(G3_COPY_DST_LO), *dst_hi = P(G3_COPY_DST_HI);
nir_def *n = P(G3_COPY_WIDTH), *h = P(G3_COPY_HEIGHT);
nir_def *sp = P(G3_COPY_SRC_PITCH), *dp = P(G3_COPY_DST_PITCH);
nir_def *fill = P(G3_COPY_FILL);
#undef P
nir_def *lane = nir_load_local_invocation_index(&b);
nir_variable *yv = nir_local_variable_create(b.impl, glsl_uint_type(), "y");
nir_variable *kv = nir_local_variable_create(b.impl, glsl_uint_type(), "k");
nir_store_var(&b, yv, nir_imm_int(&b, 0), 1);
nir_push_loop(&b);
{
nir_def *y = nir_load_var(&b, yv);
nir_break_if(&b, nir_uge(&b, y, h));
nir_def *db = nir_iadd(&b, dst_lo, nir_imul(&b, y, dp)); /* the row's first byte */
nir_def *sb = nir_iadd(&b, src_lo, nir_imul(&b, y, sp));
nir_def *end = nir_iadd(&b, db, n); /* one past its last byte */
nir_def *first = al4(&b, db);
nir_def *ndw = nir_ushr_imm(&b, nir_isub(&b, al4(&b, nir_iadd_imm(&b, end, 3)), first), 2);
nir_store_var(&b, kv, lane, 1);
nir_push_loop(&b);
{
nir_def *k = nir_load_var(&b, kv);
nir_break_if(&b, nir_uge(&b, k, ndw));
nir_def *a = nir_iadd(&b, first, nir_imul_imm(&b, k, 4));
nir_def *v = fill;
if (!fill_only) {
nir_def *s = nir_iadd(&b, sb, nir_isub(&b, a, db)); /* the source byte for byte 0 of this dword */
nir_def *s4 = al4(&b, s);
nir_def *sh = nir_ishl_imm(&b, nir_iand_imm(&b, s, 3), 3);
nir_def *aligned = nir_ult_imm(&b, sh, 1);
/* the dwords read stay inside the source row's (the bytes from outside it are masked off) */
nir_def *sfirst = al4(&b, sb);
nir_def *slast = al4(&b, nir_isub(&b, nir_iadd(&b, sb, n), nir_imm_int(&b, 1)));
nir_def *a0 = nir_bcsel(&b, nir_ult(&b, s4, sfirst), sfirst, s4);
nir_def *a1 = nir_bcsel(&b, aligned, a0, nir_iadd_imm(&b, s4, 4));
a1 = nir_bcsel(&b, nir_ult(&b, slast, a1), slast, a1);
nir_def *s0 = nir_load_global_2x32(&b, 1, 32, nir_vec2(&b, a0, src_hi));
nir_def *s1 = nir_load_global_2x32(&b, 1, 32, nir_vec2(&b, a1, src_hi));
nir_def *hi = nir_ishl_imm(&b, nir_ishl(&b, s1, nir_isub(&b, nir_imm_int(&b, 24), sh)), 8);
v = nir_ior(&b, nir_ushr(&b, s0, sh), nir_bcsel(&b, aligned, nir_imm_int(&b, 0), hi));
}
/* bytes j of this dword inside the row: lo <= j < hi */
nir_def *lo = nir_bcsel(&b, nir_ult(&b, a, db), nir_isub(&b, db, a), nir_imm_int(&b, 0));
nir_def *hi = nir_bcsel(&b, nir_ult(&b, end, nir_iadd_imm(&b, a, 4)), nir_isub(&b, end, a), nir_imm_int(&b, 4));
/* the row's bytes of this dword, lo <= j < hi (hi > lo), as a mask; the bytes outside it kept with a
* subtraction (no complement: few 32-bit constants, and an and-not is a logical op the A7 has not run) */
nir_def *gap = nir_imul_imm(&b, nir_isub(&b, nir_iadd_imm(&b, lo, 4), hi), 8); /* 8 * (4 - (hi - lo)) */
nir_def *m = nir_ishl(&b, nir_ushr(&b, nir_imm_int(&b, ~0u), gap), nir_imul_imm(&b, lo, 8));
nir_def *old = nir_load_global_2x32(&b, 1, 32, nir_vec2(&b, a, dst_hi));
nir_def *res = nir_iadd(&b, nir_isub(&b, old, nir_iand(&b, old, m)), nir_iand(&b, v, m));
nir_store_global_2x32(&b, res, nir_vec2(&b, a, dst_hi), .write_mask = 1);
nir_store_var(&b, kv, nir_iadd_imm(&b, k, 32), 1);
}
nir_pop_loop(&b, NULL);
nir_store_var(&b, yv, nir_iadd_imm(&b, y, 1), 1);
}
nir_pop_loop(&b, NULL);
nir_lower_vars_to_ssa(b.shader);
memset(out, 0, sizeof(*out));
out->num_params = G3_COPY_PARAMS;
return g3_compile_pco(pco_ctx, b.shader, out);
}
1 change: 1 addition & 0 deletions src/imagination/pco/pco_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,7 @@ bool pco_cf(pco_shader *shader);
bool pco_dce(pco_shader *shader);
bool pco_post_ra_legalize(pco_shader *shader);
bool pco_pre_ra_legalize(pco_shader *shader);
bool pco_a7_ld_addr_live(pco_shader *shader);
bool pco_end(pco_shader *shader);
bool pco_group_instrs(pco_shader *shader);
bool pco_index(pco_shader *shader, bool skip_ssa);
Expand Down
1 change: 1 addition & 0 deletions src/imagination/pco/pco_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void pco_process_ir(pco_ctx *ctx, pco_shader *shader)
*/
PCO_PASS(_, shader, pco_schedule);
PCO_PASS(_, shader, pco_pre_ra_legalize);
PCO_PASS(_, shader, pco_a7_ld_addr_live);
PCO_PASS(_, shader, pco_ra);
PCO_PASS(_, shader, pco_post_ra_legalize);
PCO_PASS(_, shader, pco_end);
Expand Down
Loading
Loading