[Mesa-dev] [PATCH 4/4] gallium/u_threaded: add a fast path for unbinding shader buffers
Marek Olšák
maraeo at gmail.com
Wed May 17 19:14:22 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/util/u_threaded_context.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index e33c846..8ea7f8a 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -817,69 +817,75 @@ tc_set_shader_images(struct pipe_context *_pipe,
util_range_add(&tres->valid_buffer_range, images[i].u.buf.offset,
images[i].u.buf.offset + images[i].u.buf.size);
}
}
memcpy(p->slot, images, count * sizeof(images[0]));
}
}
struct tc_shader_buffers {
ubyte shader, start, count;
+ bool unbind;
struct pipe_shader_buffer slot[0]; /* more will be allocated if needed */
};
static void
tc_call_set_shader_buffers(struct pipe_context *pipe, union tc_payload *payload)
{
struct tc_shader_buffers *p = (struct tc_shader_buffers *)payload;
unsigned count = p->count;
+ if (p->unbind) {
+ pipe->set_shader_buffers(pipe, p->shader, p->start, p->count, NULL);
+ return;
+ }
+
pipe->set_shader_buffers(pipe, p->shader, p->start, p->count, p->slot);
for (unsigned i = 0; i < count; i++)
pipe_resource_reference(&p->slot[i].buffer, NULL);
}
static void
tc_set_shader_buffers(struct pipe_context *_pipe, unsigned shader,
unsigned start, unsigned count,
const struct pipe_shader_buffer *buffers)
{
if (!count)
return;
struct threaded_context *tc = threaded_context(_pipe);
struct tc_shader_buffers *p =
- tc_add_slot_based_call(tc, TC_CALL_set_shader_buffers, tc_shader_buffers, count);
+ tc_add_slot_based_call(tc, TC_CALL_set_shader_buffers, tc_shader_buffers,
+ buffers ? count : 0);
p->shader = shader;
p->start = start;
p->count = count;
+ p->unbind = buffers == NULL;
if (buffers) {
for (unsigned i = 0; i < count; i++) {
struct pipe_shader_buffer *dst = &p->slot[i];
const struct pipe_shader_buffer *src = buffers + i;
tc_set_resource_reference(&dst->buffer, src->buffer);
dst->buffer_offset = src->buffer_offset;
dst->buffer_size = src->buffer_size;
if (src->buffer) {
struct threaded_resource *tres = threaded_resource(src->buffer);
util_range_add(&tres->valid_buffer_range, src->buffer_offset,
src->buffer_offset + src->buffer_size);
}
}
- } else {
- memset(p->slot, 0, count * sizeof(buffers[0]));
}
}
struct tc_vertex_buffers {
ubyte start, count;
bool unbind;
struct pipe_vertex_buffer slot[0]; /* more will be allocated if needed */
};
static void
--
2.7.4
More information about the mesa-dev
mailing list