slab_destroy_child(&tc->pool_transfers);
pipe->destroy(pipe);
- FREE(tc);
+ os_free_aligned(tc);
}
static const tc_execute execute_func[TC_NUM_CALLS] = {
if (!debug_get_bool_option("GALLIUM_THREAD", util_cpu_caps.nr_cpus > 1))
return pipe;
- tc = CALLOC_STRUCT(threaded_context);
+ tc = os_malloc_aligned(sizeof(struct threaded_context), 16);
if (!tc) {
pipe->destroy(pipe);
return NULL;
}
+ memset(tc, 0, sizeof(*tc));
+
+ assert((uintptr_t)tc % 16 == 0);
+ STATIC_ASSERT(offsetof(struct threaded_context, batch_slots[0]) % 16 == 0);
+ STATIC_ASSERT(offsetof(struct threaded_context, batch_slots[0].call[0]) % 16 == 0);
+ STATIC_ASSERT(offsetof(struct threaded_context, batch_slots[0].call[1]) % 16 == 0);
+ STATIC_ASSERT(offsetof(struct threaded_context, batch_slots[1].call[0]) % 16 == 0);
/* The driver context isn't wrapped, so set its "priv" to NULL. */
pipe->priv = NULL;
uint64_t __use_8_bytes;
};
-struct tc_call {
+#ifdef _MSC_VER
+#define ALIGN16 __declspec(align(16))
+#else
+#define ALIGN16 __attribute__((aligned(16)))
+#endif
+
+/* Each call slot should be aligned to its own size for optimal cache usage. */
+struct ALIGN16 tc_call {
unsigned sentinel;
ushort num_call_slots;
ushort call_id;