I want to do explicit clflushes in the GL driver as well. Jason and I figured this was small enough that we may as well just copy and paste it for now, as we don't have a decent common location for both drivers.
Irritatingly, because we include brw_context.h in C++ code, we have to use char * instead of void * to avoid piles of GCC warnings from -Wpointer-arith. In GNU C it works fine. Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> --- src/mesa/drivers/dri/i965/brw_context.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index aa1499a1fe1..b032d511a1e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1203,6 +1203,22 @@ struct brw_context struct intel_screen *screen; }; +#define CACHELINE_SIZE 64 +#define CACHELINE_MASK 63 + +static inline void +brw_clflush_range(void *start, size_t size) +{ + char *p = (char *) (((uintptr_t) start) & ~CACHELINE_MASK); + char *end = (char *) start + size; + + __builtin_ia32_mfence(); + while (p < end) { + __builtin_ia32_clflush(p); + p += CACHELINE_SIZE; + } +} + /* brw_clear.c */ extern void intelInitClearFuncs(struct dd_function_table *functions); -- 2.11.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev