summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2020-11-03 10:52:18 -0500
committerMarge Bot <eric+marge@anholt.net>2020-11-18 01:41:24 +0000
commitd5b37dd3c262443c8b842c4aa43d0d30117e21f7 (patch)
tree9bd017f9cfa9e922e30ef7ea198c59afb2ae6e0e /src/gallium/auxiliary/util
parentabe8ef862fe5649e16ceed76f60a2a364949b7b4 (diff)
gallium/u_threaded: lift DIV_ROUND_UP to eliminate it for constant expressions
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7441>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_threaded_context.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index da3f11a06a9..e3d357311df 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -194,11 +194,9 @@ tc_batch_flush(struct threaded_context *tc)
*/
static union tc_payload *
tc_add_sized_call(struct threaded_context *tc, enum tc_call_id id,
- unsigned payload_size)
+ unsigned num_call_slots)
{
struct tc_batch *next = &tc->batch_slots[tc->next];
- unsigned total_size = offsetof(struct tc_call, payload) + payload_size;
- unsigned num_call_slots = DIV_ROUND_UP(total_size, sizeof(struct tc_call));
tc_debug_check(tc);
@@ -221,19 +219,23 @@ tc_add_sized_call(struct threaded_context *tc, enum tc_call_id id,
return &call->payload;
}
+#define tc_payload_size_to_call_slots(size) \
+ DIV_ROUND_UP(offsetof(struct tc_call, payload) + (size), sizeof(struct tc_call))
+
#define tc_add_struct_typed_call(tc, execute, type) \
- ((struct type*)tc_add_sized_call(tc, execute, sizeof(struct type)))
+ ((struct type*)tc_add_sized_call(tc, execute, \
+ tc_payload_size_to_call_slots(sizeof(struct type))))
#define tc_add_slot_based_call(tc, execute, type, num_slots) \
- ((struct type*)tc_add_sized_call(tc, execute, \
+ ((struct type*)tc_add_sized_call(tc, execute, tc_payload_size_to_call_slots( \
sizeof(struct type) + \
sizeof(((struct type*)NULL)->slot[0]) * \
- (num_slots)))
+ (num_slots))))
static union tc_payload *
tc_add_small_call(struct threaded_context *tc, enum tc_call_id id)
{
- return tc_add_sized_call(tc, id, 0);
+ return tc_add_sized_call(tc, id, tc_payload_size_to_call_slots(0));
}
static bool
@@ -373,7 +375,8 @@ threaded_context_unwrap_sync(struct pipe_context *pipe)
tc_##func(struct pipe_context *_pipe, qualifier type deref param) \
{ \
struct threaded_context *tc = threaded_context(_pipe); \
- type *p = (type*)tc_add_sized_call(tc, TC_CALL_##func, sizeof(type)); \
+ type *p = (type*)tc_add_sized_call(tc, TC_CALL_##func, \
+ tc_payload_size_to_call_slots(sizeof(type))); \
*p = deref(param); \
}
@@ -705,7 +708,7 @@ tc_set_tess_state(struct pipe_context *_pipe,
{
struct threaded_context *tc = threaded_context(_pipe);
float *p = (float*)tc_add_sized_call(tc, TC_CALL_set_tess_state,
- sizeof(float) * 6);
+ tc_payload_size_to_call_slots(sizeof(float) * 6));
memcpy(p, default_outer_level, 4 * sizeof(float));
memcpy(p + 4, default_inner_level, 2 * sizeof(float));
@@ -2221,11 +2224,11 @@ tc_add_draw_vbo(struct pipe_context *_pipe, bool indirect)
if (indirect) {
return (struct tc_full_draw_info*)
tc_add_sized_call(threaded_context(_pipe), TC_CALL_draw_indirect,
- sizeof(struct tc_full_draw_info));
+ tc_payload_size_to_call_slots(sizeof(struct tc_full_draw_info)));
} else {
return (struct tc_full_draw_info*)
tc_add_sized_call(threaded_context(_pipe), TC_CALL_draw_vbo,
- sizeof(struct pipe_draw_info));
+ tc_payload_size_to_call_slots(sizeof(struct pipe_draw_info)));
}
}