Commit bd19a5b6 authored by Icecream95's avatar Icecream95
Browse files

panfrost: Push UBO range combining

Makes panfrost_emit_const_buf about twice as fast.
parent 8fe9b012
Pipeline #299915 waiting for manual action with stages
......@@ -1158,7 +1158,9 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
uint32_t *push_cpu = (uint32_t *) push_transfer.cpu;
*push_constants = push_transfer.gpu;
for (unsigned i = 0; i < ss->info.push.count; ++i) {
unsigned dst_offset = 0;
for (unsigned i = 0; i < ss->info.push.num_words; ++i) {
struct panfrost_ubo_word src = ss->info.push.words[i];
/* Map the UBO, this should be cheap. However this is reading
......@@ -1169,8 +1171,9 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
const void *mapped_ubo = (src.ubo == sysval_ubo) ? transfer.cpu :
panfrost_map_constant_buffer_cpu(ctx, buf, src.ubo);
/* TODO: Is there any benefit to combining ranges */
memcpy(push_cpu + i, (uint8_t *) mapped_ubo + src.offset, 4);
memcpy(push_cpu + dst_offset, (uint8_t *) mapped_ubo + src.offset, src.size * 4);
dst_offset += src.size;
}
buf->dirty_mask = 0;
......
......@@ -135,14 +135,21 @@ pan_print_alu_type(nir_alu_type t, FILE *fp)
unsigned
pan_lookup_pushed_ubo(struct panfrost_ubo_push *push, unsigned ubo, unsigned offs)
{
struct panfrost_ubo_word word = {
.ubo = ubo,
.offset = offs
};
unsigned count = 0;
for (unsigned i = 0; i < push->count; ++i) {
if (memcmp(push->words + i, &word, sizeof(word)) == 0)
return i;
struct panfrost_ubo_word word = push->words[i];
count += word.size;
if (word.ubo != ubo)
continue;
unsigned start = word.offset;
unsigned end = word.offset + (word.size * 4);
if (offs >= start && offs < end)
return count - (end - offs) / 4;
}
unreachable("UBO not pushed");
......@@ -152,10 +159,24 @@ pan_lookup_pushed_ubo(struct panfrost_ubo_push *push, unsigned ubo, unsigned off
void
pan_add_pushed_ubo(struct panfrost_ubo_push *push, unsigned ubo, unsigned offs)
{
++push->count;
if (push->num_words) {
struct panfrost_ubo_word *prev;
prev = &push->words[push->num_words - 1];
if (prev->ubo == ubo &&
prev->offset + prev->size * 4 == offs) {
++prev->size;
return;
}
}
struct panfrost_ubo_word word = {
.ubo = ubo,
.size = 1,
.offset = offs,
};
push->words[push->count++] = word;
push->words[push->num_words++] = word;
}
......@@ -90,12 +90,14 @@ struct panfrost_sysvals {
* an offset to a word must be < 2^16. There are less than 2^8 UBOs */
struct panfrost_ubo_word {
uint16_t ubo;
uint8_t ubo;
uint8_t size;
uint16_t offset;
};
struct panfrost_ubo_push {
unsigned count;
unsigned num_words;
struct panfrost_ubo_word words[PAN_MAX_PUSH];
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment