diff options
author | Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> | 2019-12-19 16:46:43 -0500 |
---|---|---|
committer | Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> | 2019-12-24 22:42:07 -0500 |
commit | d36ca7c0a38dcae2e63296b38558844084e21d5d (patch) | |
tree | 0ac27f1cedd249bd1524845a3efb90b0d2e44e20 /src/gallium/drivers/panfrost | |
parent | 62ce9001c20f0135544e8ca99ef1b10aaaa7f085 (diff) |
panfrost: Remove pan_shift_odd
Padded counts are numbers of the form:
n = (2k + 1) * 2^s
for k, s integers. Rather than explicitly store k and s separately and
then compute this formula on demand, it's much cleaner to store the
padded number itself, which is what you manipulate most of the time.
When you do need k,s it is easy to factor by noticing the bitwise
representation:
s = ctz(n)
k = n >> (s + 1)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index ea2bb442047..27b6cd7be2f 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1551,16 +1551,16 @@ panfrost_draw_vbo( /* Encode the padded vertex count */ if (info->instance_count > 1) { - struct pan_shift_odd so = - panfrost_padded_vertex_count(vertex_count); + ctx->padded_count = panfrost_padded_vertex_count(vertex_count); - ctx->payloads[PIPE_SHADER_VERTEX].instance_shift = so.shift; - ctx->payloads[PIPE_SHADER_FRAGMENT].instance_shift = so.shift; + unsigned shift = __builtin_ctz(ctx->padded_count); + unsigned k = ctx->padded_count >> (shift + 1); - ctx->payloads[PIPE_SHADER_VERTEX].instance_odd = so.odd; - ctx->payloads[PIPE_SHADER_FRAGMENT].instance_odd = so.odd; + ctx->payloads[PIPE_SHADER_VERTEX].instance_shift = shift; + ctx->payloads[PIPE_SHADER_FRAGMENT].instance_shift = shift; - ctx->padded_count = pan_expand_shift_odd(so); + ctx->payloads[PIPE_SHADER_VERTEX].instance_odd = k; + ctx->payloads[PIPE_SHADER_FRAGMENT].instance_odd = k; } else { ctx->padded_count = vertex_count; |