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
1 change: 1 addition & 0 deletions src/gallium/drivers/asahi/agx_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ agx_batch_init(struct agx_context *ctx,
batch->g17p_fragment_shader = NULL;
batch->g17p_fragment_linked = NULL;
batch->g17p_bind_tail_latched = false;
memset(batch->g17p_resource_pair, 0, sizeof(batch->g17p_resource_pair));
batch->g17p_have_latched_vs = false;
batch->g17p_latched_vs_shader = NULL;
batch->repeat.valid = false;
Expand Down
32 changes: 26 additions & 6 deletions src/gallium/drivers/asahi/agx_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -8287,6 +8287,31 @@ agx_graphics_tps_frame(const struct agx_device *dev,
return dev->chip == AGX_CHIP_G18G ? ALIGN_POT(frame, 16) : frame;
}

static uint64_t
agx_g17p_resource_pair_va(struct agx_batch *batch, mesa_shader_stage stage)
{
const uint64_t texture_base = batch->stage_uniforms[stage].texture_base;
const uint64_t samplers = batch->samplers[stage];
if (!texture_base || !samplers)
return 0;

if (batch->g17p_resource_pair[stage].va &&
batch->g17p_resource_pair[stage].texture_base == texture_base &&
batch->g17p_resource_pair[stage].samplers == samplers)
return batch->g17p_resource_pair[stage].va;

const uint64_t pointers[2] = {texture_base, samplers};
const uint64_t va =
agx_pool_upload_aligned(&batch->pool, pointers, sizeof(pointers), 8);
if (!va)
return 0;

batch->g17p_resource_pair[stage].texture_base = texture_base;
batch->g17p_resource_pair[stage].samplers = samplers;
batch->g17p_resource_pair[stage].va = va;
return va;
}

/* A uniform range that agx_g17p_collect_graphics_uniform_ranges() did not
* read from a system value table. */
#define AGX_G17P_RANGE_NO_TABLE 0xff
Expand Down Expand Up @@ -8336,12 +8361,7 @@ agx_g17p_collect_graphics_uniform_ranges(
(batch->ctx->stage[stage].custom_borders &&
!cs->g17p_custom_border_emulation))
return false;
const uint64_t pointers[2] = {
batch->stage_uniforms[stage].texture_base,
batch->samplers[stage],
};
const uint64_t pointer_va = agx_pool_upload_aligned(
&batch->pool, pointers, sizeof(pointers), 8);
const uint64_t pointer_va = agx_g17p_resource_pair_va(batch, stage);
if (!pointer_va)
return false;
if (range_table)
Expand Down
7 changes: 7 additions & 0 deletions src/gallium/drivers/asahi/agx_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@ struct agx_batch {
uint32_t g17p_latched_vs_word0;
uint32_t g17p_latched_vs_outputs[2];

/* Batch-local upload of the stage texture and sampler table addresses. */
struct {
uint64_t texture_base;
uint64_t samplers;
uint64_t va;
} g17p_resource_pair[MESA_SHADER_STAGES];

/* Native AGX3: the last direct draw, for agx_draw_vbo_repeat(). It may
* replay that draw when at most the vertex constant buffers changed. */
struct {
Expand Down