diff options
author | Eric Anholt <[email protected]> | 2019-03-19 09:58:14 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2019-03-21 14:20:50 -0700 |
commit | 16f2770eb40e7e11d149b4551de27d8d663f4e22 (patch) | |
tree | ba45e5afb703a3125536de9e396c632700b6a90b /src/gallium/drivers | |
parent | 320e96baced8093c6af11d86a216d83cee1eeb30 (diff) |
v3d: Upload all of UBO[0] if any indirect load occurs.
The idea was that we could skip uploading the constant-indexed uniform
data and just upload the uniforms that are variably-indexed. However,
since the VS bin and render shaders may have a different set of uniforms
used, this meant that we had to upload the UBO for each of them. The
first case is generally a fairly small impact (usually the uniform array
is the most space, other than a couple of FSes in shader-db), while the
second is a larger impact: 3DMMES2 was uploading 38k/frame of uniforms
instead of 18k.
Given that the optimization is of dubious value, has a big downside, and
is quite a bit of code, just drop it. No change in shader-db. No change
on 3DMMES2 (n=15).
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/v3d/v3d_uniforms.c | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/src/gallium/drivers/v3d/v3d_uniforms.c b/src/gallium/drivers/v3d/v3d_uniforms.c index b48f6526d61..a5532bdf2b4 100644 --- a/src/gallium/drivers/v3d/v3d_uniforms.c +++ b/src/gallium/drivers/v3d/v3d_uniforms.c @@ -22,6 +22,7 @@ */ #include "util/u_pack_color.h" +#include "util/u_upload_mgr.h" #include "util/format_srgb.h" #include "v3d_context.h" @@ -95,28 +96,6 @@ get_image_size(struct v3d_shaderimg_stateobj *shaderimg, } } -static struct v3d_bo * -v3d_upload_ubo(struct v3d_context *v3d, - struct v3d_compiled_shader *shader, - const uint32_t *gallium_uniforms) -{ - if (!shader->prog_data.base->ubo_size) - return NULL; - - struct v3d_bo *ubo = v3d_bo_alloc(v3d->screen, - shader->prog_data.base->ubo_size, - "ubo"); - void *data = v3d_bo_map(ubo); - for (uint32_t i = 0; i < shader->prog_data.base->num_ubo_ranges; i++) { - memcpy(data + shader->prog_data.base->ubo_ranges[i].dst_offset, - ((const void *)gallium_uniforms + - shader->prog_data.base->ubo_ranges[i].src_offset), - shader->prog_data.base->ubo_ranges[i].size); - } - - return ubo; -} - /** * Writes the V3D 3.x P0 (CFG_MODE=1) texture parameter. * @@ -235,7 +214,6 @@ v3d_write_uniforms(struct v3d_context *v3d, struct v3d_compiled_shader *shader, struct v3d_uniform_list *uinfo = &shader->prog_data.base->uniforms; struct v3d_job *job = v3d->job; const uint32_t *gallium_uniforms = cb->cb[0].user_buffer; - struct v3d_bo *ubo = v3d_upload_ubo(v3d, shader, gallium_uniforms); /* We always need to return some space for uniforms, because the HW * will be prefetching, even if we don't read any in the program. @@ -329,21 +307,26 @@ v3d_write_uniforms(struct v3d_context *v3d, struct v3d_compiled_shader *shader, v3d->zsa->base.alpha.ref_value); break; - case QUNIFORM_UBO_ADDR: - if (data == 0) { - cl_aligned_reloc(&job->indirect, &uniforms, - ubo, 0); - } else { - int ubo_index = v3d_unit_data_get_unit(data); - struct v3d_resource *rsc = - v3d_resource(cb->cb[ubo_index].buffer); - - cl_aligned_reloc(&job->indirect, &uniforms, - rsc->bo, - cb->cb[ubo_index].buffer_offset + - v3d_unit_data_get_offset(data)); + case QUNIFORM_UBO_ADDR: { + uint32_t unit = v3d_unit_data_get_unit(data); + /* Constant buffer 0 may be a system memory pointer, + * in which case we want to upload a shadow copy to + * the GPU. + */ + if (!cb->cb[unit].buffer) { + u_upload_data(v3d->uploader, 0, + cb->cb[unit].buffer_size, 16, + cb->cb[unit].user_buffer, + &cb->cb[unit].buffer_offset, + &cb->cb[unit].buffer); } + + cl_aligned_reloc(&job->indirect, &uniforms, + v3d_resource(cb->cb[unit].buffer)->bo, + cb->cb[unit].buffer_offset + + v3d_unit_data_get_offset(data)); break; + } case QUNIFORM_SSBO_OFFSET: { struct pipe_shader_buffer *sb = @@ -397,8 +380,6 @@ v3d_write_uniforms(struct v3d_context *v3d, struct v3d_compiled_shader *shader, cl_end(&job->indirect, uniforms); - v3d_bo_unreference(&ubo); - return uniform_stream; } |