From 44c4979227c83b8241c8b30c9e7bb96bf9232c89 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Dec 2020 12:35:54 -0800 Subject: [PATCH] gallium/tgsi_exec: Move the SSBO store path to tgsi_exec, too. Now that we have lookups, we can just fold this in. Reviewed-by: Dave Airlie Part-of: --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 45 +++++++++++------------ src/gallium/auxiliary/tgsi/tgsi_exec.h | 5 --- src/gallium/drivers/softpipe/sp_buffer.c | 47 ------------------------ 3 files changed, 22 insertions(+), 75 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 172b8497103..ff28d582d99 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -4083,35 +4083,34 @@ static void exec_store_buf(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst) { - union tgsi_exec_channel r[3]; - union tgsi_exec_channel value[4]; - float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]; - struct tgsi_buffer_params params; - int i, j; - uint unit; + uint32_t unit = fetch_store_img_unit(mach, &inst->Dst[0]); + uint32_t size; + char *ptr = mach->Buffer->lookup(mach->Buffer, unit, &size); + int kilmask = mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0]; + int execmask = mach->ExecMask & mach->NonHelperMask & ~kilmask; - unit = fetch_store_img_unit(mach, &inst->Dst[0]); + union tgsi_exec_channel offset; + IFETCH(&offset, 0, TGSI_CHAN_X); - params.execmask = mach->ExecMask & mach->NonHelperMask & ~kilmask; - params.unit = unit; - params.writemask = inst->Dst[0].Register.WriteMask; - - IFETCH(&r[0], 0, TGSI_CHAN_X); - for (i = 0; i < 4; i++) { + union tgsi_exec_channel value[4]; + for (int i = 0; i < 4; i++) FETCH(&value[i], 1, TGSI_CHAN_X + i); - } - for (j = 0; j < TGSI_QUAD_SIZE; j++) { - rgba[0][j] = value[0].f[j]; - rgba[1][j] = value[1].f[j]; - rgba[2][j] = value[2].f[j]; - rgba[3][j] = value[3].f[j]; - } + for (int j = 0; j < TGSI_QUAD_SIZE; j++) { + if (!(execmask & (1 << j))) + continue; + if (size < offset.u[j]) + continue; - mach->Buffer->store(mach->Buffer, ¶ms, - r[0].i, - rgba); + uint32_t *invocation_ptr = (uint32_t *)(ptr + offset.u[j]); + uint32_t size_avail = size - offset.u[j]; + + for (int chan = 0; chan < MIN2(4, size_avail / 4); chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) + memcpy(&invocation_ptr[chan], &value[chan].u[j], 4); + } + } } static void diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index bf89ec0df86..6bf1c093628 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -155,11 +155,6 @@ struct tgsi_buffer_params { /* SSBO interfaces */ struct tgsi_buffer { - void (*store)(const struct tgsi_buffer *buffer, - const struct tgsi_buffer_params *params, - const int s[TGSI_QUAD_SIZE], - float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]); - void *(*lookup)(const struct tgsi_buffer *buffer, uint32_t unit, uint32_t *size); diff --git a/src/gallium/drivers/softpipe/sp_buffer.c b/src/gallium/drivers/softpipe/sp_buffer.c index d08b8d8adb9..27655cc6323 100644 --- a/src/gallium/drivers/softpipe/sp_buffer.c +++ b/src/gallium/drivers/softpipe/sp_buffer.c @@ -42,52 +42,6 @@ get_dimensions(const struct pipe_shader_buffer *bview, return true; } -/* - * Implement the buffer STORE operation. - */ -static void -sp_tgsi_store(const struct tgsi_buffer *buffer, - const struct tgsi_buffer_params *params, - const int s[TGSI_QUAD_SIZE], - float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) -{ - struct sp_tgsi_buffer *sp_buf = (struct sp_tgsi_buffer *)buffer; - struct pipe_shader_buffer *bview; - struct softpipe_resource *spr; - unsigned width; - int j, c; - - if (params->unit >= PIPE_MAX_SHADER_BUFFERS) - return; - - bview = &sp_buf->sp_bview[params->unit]; - spr = softpipe_resource(bview->buffer); - if (!spr) - return; - - if (!get_dimensions(bview, spr, &width)) - return; - - for (j = 0; j < TGSI_QUAD_SIZE; j++) { - int s_coord; - - if (!(params->execmask & (1 << j))) - continue; - - s_coord = s[j]; - if (s_coord >= width) - continue; - - uint32_t *dst = (uint32_t *)((unsigned char *)spr->data + - bview->buffer_offset + s_coord); - - for (c = 0; c < 4; c++) { - if (params->writemask & (1 << c)) - memcpy(&dst[c], &rgba[c][j], 4); - } - } -} - static void * sp_tgsi_ssbo_lookup(const struct tgsi_buffer *buffer, uint32_t unit, @@ -140,7 +94,6 @@ sp_create_tgsi_buffer(void) if (!buf) return NULL; - buf->base.store = sp_tgsi_store; buf->base.lookup = sp_tgsi_ssbo_lookup; buf->base.get_dims = sp_tgsi_get_dims; return buf;