summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-08-07 13:31:09 -0700
committerEric Anholt <[email protected]>2018-08-07 17:00:22 -0700
commit3954331aff2329157a15f8b5b9b4655179aafc33 (patch)
treeb02581247cb537ec1f87ab5ca4a1d273ec3e694e /src/gallium/drivers/vc4
parent550e9c917c155b3fc4e7bd0b74ead90814f864d8 (diff)
vc4: Pull uinfo->data[i] dereference out to the top of the loop.
Reduces the size of vc4_uniforms.o by about 10%. We would basically always end up loading the cachline of uinfo->data[i] anyway, so it should be good for performance as well as making the code a bit cleaner.
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r--src/gallium/drivers/vc4/vc4_uniforms.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/gallium/drivers/vc4/vc4_uniforms.c b/src/gallium/drivers/vc4/vc4_uniforms.c
index 8a435173b7e..e66654361cc 100644
--- a/src/gallium/drivers/vc4/vc4_uniforms.c
+++ b/src/gallium/drivers/vc4/vc4_uniforms.c
@@ -224,14 +224,16 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
uinfo->num_texture_samples);
for (int i = 0; i < uinfo->count; i++) {
+ enum quniform_contents contents = uinfo->contents[i];
+ uint32_t data = uinfo->data[i];
- switch (uinfo->contents[i]) {
+ switch (contents) {
case QUNIFORM_CONSTANT:
- cl_aligned_u32(&uniforms, uinfo->data[i]);
+ cl_aligned_u32(&uniforms, data);
break;
case QUNIFORM_UNIFORM:
cl_aligned_u32(&uniforms,
- gallium_uniforms[uinfo->data[i]]);
+ gallium_uniforms[data]);
break;
case QUNIFORM_VIEWPORT_X_SCALE:
cl_aligned_f(&uniforms, vc4->viewport.scale[0] * 16.0f);
@@ -249,36 +251,33 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
case QUNIFORM_USER_CLIP_PLANE:
cl_aligned_f(&uniforms,
- vc4->clip.ucp[uinfo->data[i] / 4][uinfo->data[i] % 4]);
+ vc4->clip.ucp[data / 4][data % 4]);
break;
case QUNIFORM_TEXTURE_CONFIG_P0:
- write_texture_p0(job, &uniforms, texstate,
- uinfo->data[i]);
+ write_texture_p0(job, &uniforms, texstate, data);
break;
case QUNIFORM_TEXTURE_CONFIG_P1:
- write_texture_p1(job, &uniforms, texstate,
- uinfo->data[i]);
+ write_texture_p1(job, &uniforms, texstate, data);
break;
case QUNIFORM_TEXTURE_CONFIG_P2:
- write_texture_p2(job, &uniforms, texstate,
- uinfo->data[i]);
+ write_texture_p2(job, &uniforms, texstate, data);
break;
case QUNIFORM_TEXTURE_FIRST_LEVEL:
write_texture_first_level(job, &uniforms, texstate,
- uinfo->data[i]);
+ data);
break;
case QUNIFORM_UBO_ADDR:
- if (uinfo->data[i] == 0) {
+ if (data == 0) {
cl_aligned_reloc(job, &job->uniforms,
&uniforms, ubo, 0);
} else {
struct pipe_constant_buffer *c =
- &cb->cb[uinfo->data[i]];
+ &cb->cb[data];
struct vc4_resource *rsc =
vc4_resource(c->buffer);
@@ -289,13 +288,12 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
break;
case QUNIFORM_TEXTURE_MSAA_ADDR:
- write_texture_msaa_addr(job, &uniforms,
- texstate, uinfo->data[i]);
+ write_texture_msaa_addr(job, &uniforms, texstate, data);
break;
case QUNIFORM_TEXTURE_BORDER_COLOR:
write_texture_border_color(job, &uniforms,
- texstate, uinfo->data[i]);
+ texstate, data);
break;
case QUNIFORM_TEXRECT_SCALE_X:
@@ -303,7 +301,7 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
cl_aligned_u32(&uniforms,
get_texrect_scale(texstate,
uinfo->contents[i],
- uinfo->data[i]));
+ data));
break;
case QUNIFORM_BLEND_CONST_COLOR_X:
@@ -342,9 +340,9 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
case QUNIFORM_STENCIL:
cl_aligned_u32(&uniforms,
- vc4->zsa->stencil_uniforms[uinfo->data[i]] |
- (uinfo->data[i] <= 1 ?
- (vc4->stencil_ref.ref_value[uinfo->data[i]] << 8) :
+ vc4->zsa->stencil_uniforms[data] |
+ (data <= 1 ?
+ (vc4->stencil_ref.ref_value[data] << 8) :
0));
break;