#include "os/os_thread.h"
#include "pipe/p_state.h"
+#include "pipe/p_screen.h"
+#include "util/u_atomic.h"
#include "util/u_math.h"
#include "util/simple_mtx.h"
unsigned start, unsigned end)
{
if (start < range->start || end > range->end) {
- if (resource->flags & PIPE_RESOURCE_FLAG_SINGLE_THREAD_USE) {
+ if (resource->flags & PIPE_RESOURCE_FLAG_SINGLE_THREAD_USE ||
+ p_atomic_read(&resource->screen->num_contexts) == 1) {
range->start = MIN2(start, range->start);
range->end = MAX2(end, range->end);
} else {
* context.
*/
struct pipe_screen {
+ /**
+ * Atomically incremented by drivers to track the number of contexts.
+ * If it's 0, it can be assumed that contexts are not tracked.
+ * Used by some places to skip locking if num_contexts == 1.
+ */
+ unsigned num_contexts;
/**
* For drivers using u_transfer_helper: