Skip to content

v3dv: reduce CPU overhead of job BO tracking

Iago Toral requested to merge itoral/mesa:v3dv_write_uniforms_opt into master

mesa_set_search shows up frequently in perf results, mostly from v3dv_job_add_bo calls (to check we don't add the same BO more than once). In the UE4 Vehicle demo in particular, which as a lot of CPU overhead due to the large number of draw calls, v3dv_job_add_bo shows in ~30% of the samples taken for v3dv_write_uniforms, which is the top cause of CPU driver overhead in the driver.

During uniform writes, instead of trying to add a BO for a texture, sampler or a buffer resource every time we see it being referenced in the shader code, just flag it as used and add it only once at the end. Also, there are some other cases where we can skip the set search because we know we have not added the BO yet (typically, when we add it just after we have created it for example).

Per results for the UE4 Vehicle demo:

master:
  - mesa_set_search: 8.16%
  - write_uniforms: 20.65% 
     - mesa_set_search: 5.56%

patched:
  - mesa_set_search: 3.31%
  - write_uniforms: 14.57%
     - mesa_set_search: 2.11%

Merge request reports