diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-01 11:03:15 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-12 12:42:59 -0700 |
commit | 2efa025b055965c64301b5e497cdf2250d26b9ee (patch) | |
tree | 651d119242ee6f589fd20403d994ca79a9355c34 /src/gallium/drivers/panfrost/pan_context.c | |
parent | e881aa8c12c1447423c4acee4bbaaf503b19b057 (diff) |
panfrost: Add SSBO system value
For each SSBO index we get from Gallium/NIR, we need two pieces of
information in the shader:
1. The address of the SSBO in GPU memory. Within the shader, we'll be
accessing it with raw memory load/store, so we need the actual address,
not just an index.
2. The size of the SSBO. This is not strictly necessary, but at some
point, we may like to do bounds checking on SSBO accesses.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_context.c')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index ac1d1b9429b..035ce52128b 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -680,6 +680,7 @@ struct sysval_uniform { float f[4]; int32_t i[4]; uint32_t u[4]; + uint64_t du[2]; }; }; @@ -728,6 +729,26 @@ static void panfrost_upload_txs_sysval(struct panfrost_context *ctx, uniform->i[dim] = tex->texture->array_size; } +static void panfrost_upload_ssbo_sysval( + struct panfrost_context *ctx, + enum pipe_shader_type st, + unsigned ssbo_id, + struct sysval_uniform *uniform) +{ + assert(ctx->ssbo_mask[st] & (1 << ssbo_id)); + struct pipe_shader_buffer sb = ctx->ssbo[st][ssbo_id]; + + /* Compute address */ + struct panfrost_job *batch = panfrost_get_job_for_fbo(ctx); + struct panfrost_bo *bo = pan_resource(sb.buffer)->bo; + + panfrost_job_add_bo(batch, bo); + + /* Upload address and size as sysval */ + uniform->du[0] = bo->gpu + sb.buffer_offset; + uniform->u[2] = sb.buffer_size; +} + static void panfrost_upload_sysvals(struct panfrost_context *ctx, void *buf, struct panfrost_shader_state *ss, enum pipe_shader_type st) @@ -748,6 +769,10 @@ static void panfrost_upload_sysvals(struct panfrost_context *ctx, void *buf, panfrost_upload_txs_sysval(ctx, st, PAN_SYSVAL_ID(sysval), &uniforms[i]); break; + case PAN_SYSVAL_SSBO: + panfrost_upload_ssbo_sysval(ctx, st, PAN_SYSVAL_ID(sysval), + &uniforms[i]); + break; default: assert(0); } |