radeonsi: optimize si_invalidate_buffer based on bind_history

Just enclose each section with: if (rbuffer->bind_history & PIPE_BIND_...)

Bioshock Infinite: +1% performance

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
This commit is contained in:
Marek Olšák 2016-10-02 15:50:15 +02:00
parent e43bd861e8
commit 7e6428e0a8
1 changed files with 94 additions and 81 deletions

View File

@ -1503,6 +1503,7 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
*/
/* Vertex buffers. */
if (rbuffer->bind_history & PIPE_BIND_VERTEX_BUFFER) {
for (i = 0; i < num_elems; i++) {
int vb = sctx->vertex_elements->elements[i].vertex_buffer_index;
@ -1516,8 +1517,10 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
break;
}
}
}
/* Streamout buffers. (other internal buffers can't be invalidated) */
if (rbuffer->bind_history & PIPE_BIND_STREAM_OUTPUT) {
for (i = SI_VS_STREAMOUT_BUF0; i <= SI_VS_STREAMOUT_BUF3; i++) {
struct si_buffer_resources *buffers = &sctx->rw_buffers;
struct si_descriptors *descs =
@ -1543,17 +1546,24 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
sctx->b.streamout.enabled_mask;
r600_streamout_buffers_dirty(&sctx->b);
}
}
/* Constant and shader buffers. */
for (shader = 0; shader < SI_NUM_SHADERS; shader++) {
if (rbuffer->bind_history & PIPE_BIND_CONSTANT_BUFFER) {
for (shader = 0; shader < SI_NUM_SHADERS; shader++)
si_reset_buffer_resources(sctx, &sctx->const_buffers[shader],
si_const_buffer_descriptors_idx(shader),
buf, old_va);
}
if (rbuffer->bind_history & PIPE_BIND_SHADER_BUFFER) {
for (shader = 0; shader < SI_NUM_SHADERS; shader++)
si_reset_buffer_resources(sctx, &sctx->shader_buffers[shader],
si_shader_buffer_descriptors_idx(shader),
buf, old_va);
}
if (rbuffer->bind_history & PIPE_BIND_SAMPLER_VIEW) {
/* Texture buffers - update virtual addresses in sampler view descriptors. */
LIST_FOR_EACH_ENTRY(view, &sctx->b.texture_buffers, list) {
if (view->base.texture == buf) {
@ -1585,8 +1595,10 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
}
}
}
}
/* Shader images */
if (rbuffer->bind_history & PIPE_BIND_SHADER_IMAGE) {
for (shader = 0; shader < SI_NUM_SHADERS; ++shader) {
struct si_images_info *images = &sctx->images[shader];
struct si_descriptors *descs =
@ -1615,6 +1627,7 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
}
}
}
}
/* Update mutable image descriptor fields of all bound textures. */
void si_update_all_texture_descriptors(struct si_context *sctx)