• Home
  • Raw
  • Download

Lines Matching +full:shared +full:- +full:glapi

28  * In multicore systems, many applications end up CPU-bound with about half
49 struct gl_shared_state *shared = ctx->Shared; in glthread_update_global_locking() local
52 simple_mtx_lock(&shared->Mutex); in glthread_update_global_locking()
58 bool lock_mutexes = shared->GLThread.LastContextSwitchTime + in glthread_update_global_locking()
59 shared->GLThread.NoLockDuration < current_time; in glthread_update_global_locking()
64 if (ctx != shared->GLThread.LastExecutingCtx) { in glthread_update_global_locking()
68 if (shared->GLThread.LastContextSwitchTime + in glthread_update_global_locking()
72 * time, reset the no-lock time to its initial state of only 1 in glthread_update_global_locking()
74 * multi-context loading of game content and shaders. in glthread_update_global_locking()
77 shared->GLThread.NoLockDuration = ONE_SECOND_IN_NS; in glthread_update_global_locking()
78 } else if (shared->GLThread.NoLockDuration < 32 * ONE_SECOND_IN_NS) { in glthread_update_global_locking()
79 /* Double the no-lock duration if we are transitioning from only in glthread_update_global_locking()
84 shared->GLThread.NoLockDuration *= 2; in glthread_update_global_locking()
93 * effectively resets the non-locking stopwatch to 0, so that multiple in glthread_update_global_locking()
96 shared->GLThread.LastExecutingCtx = ctx; in glthread_update_global_locking()
97 shared->GLThread.LastContextSwitchTime = current_time; in glthread_update_global_locking()
99 simple_mtx_unlock(&shared->Mutex); in glthread_update_global_locking()
101 ctx->GLThread.LockGlobalMutexes = lock_mutexes; in glthread_update_global_locking()
108 struct gl_context *ctx = batch->ctx; in glthread_unmarshal_batch()
110 unsigned used = batch->used; in glthread_unmarshal_batch()
111 uint64_t *buffer = batch->buffer; in glthread_unmarshal_batch()
112 struct gl_shared_state *shared = ctx->Shared; in glthread_unmarshal_batch() local
114 /* Determine once every 64 batches whether shared mutexes should be locked. in glthread_unmarshal_batch()
117 * https://gitlab.freedesktop.org/mesa/mesa/-/issues/8910 in glthread_unmarshal_batch()
119 if (ctx->GLThread.GlobalLockUpdateBatchCounter++ % 64 == 0) in glthread_unmarshal_batch()
123 _glapi_set_dispatch(ctx->Dispatch.Current); in glthread_unmarshal_batch()
128 bool lock_mutexes = ctx->GLThread.LockGlobalMutexes; in glthread_unmarshal_batch()
130 _mesa_HashLockMutex(&shared->BufferObjects); in glthread_unmarshal_batch()
131 ctx->BufferObjectsLocked = true; in glthread_unmarshal_batch()
132 simple_mtx_lock(&shared->TexMutex); in glthread_unmarshal_batch()
133 ctx->TexturesLocked = true; in glthread_unmarshal_batch()
140 pos += _mesa_unmarshal_dispatch[cmd->cmd_id](ctx, cmd); in glthread_unmarshal_batch()
144 ctx->TexturesLocked = false; in glthread_unmarshal_batch()
145 simple_mtx_unlock(&shared->TexMutex); in glthread_unmarshal_batch()
146 ctx->BufferObjectsLocked = false; in glthread_unmarshal_batch()
147 _mesa_HashUnlockMutex(&shared->BufferObjects); in glthread_unmarshal_batch()
151 batch->used = 0; in glthread_unmarshal_batch()
153 unsigned batch_index = batch - ctx->GLThread.batches; in glthread_unmarshal_batch()
154 _mesa_glthread_signal_call(&ctx->GLThread.LastProgramChangeBatch, batch_index); in glthread_unmarshal_batch()
155 _mesa_glthread_signal_call(&ctx->GLThread.LastDListChangeBatchIndex, batch_index); in glthread_unmarshal_batch()
157 p_atomic_inc(&ctx->GLThread.stats.num_batches); in glthread_unmarshal_batch()
163 struct glthread_state *glthread = &ctx->GLThread; in glthread_apply_thread_sched_policy()
165 if (!glthread->thread_sched_enabled) in glthread_apply_thread_sched_policy()
171 if (initialization || ++glthread->pin_thread_counter % 128 == 0) { in glthread_apply_thread_sched_policy()
175 util_thread_sched_apply_policy(glthread->queue.threads[0], in glthread_apply_thread_sched_policy()
177 &glthread->thread_sched_state)) { in glthread_apply_thread_sched_policy()
179 ctx->pipe->set_context_param(ctx->pipe, in glthread_apply_thread_sched_policy()
191 st_set_background_context(ctx, &ctx->GLThread.stats); in glthread_thread_initialization()
212 struct pipe_screen *screen = ctx->screen; in _mesa_glthread_init()
213 struct glthread_state *glthread = &ctx->GLThread; in _mesa_glthread_init()
214 assert(!glthread->enabled); in _mesa_glthread_init()
216 if (!screen->get_param(screen, PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE) || in _mesa_glthread_init()
217 !screen->get_param(screen, PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION)) in _mesa_glthread_init()
220 if (!util_queue_init(&glthread->queue, "gl", MARSHAL_MAX_BATCHES - 2, in _mesa_glthread_init()
225 _mesa_InitHashTable(&glthread->VAOs); in _mesa_glthread_init()
226 _mesa_glthread_reset_vao(&glthread->DefaultVAO); in _mesa_glthread_init()
227 glthread->CurrentVAO = &glthread->DefaultVAO; in _mesa_glthread_init()
229 ctx->MarshalExec = _mesa_alloc_dispatch_table(true); in _mesa_glthread_init()
230 if (!ctx->MarshalExec) { in _mesa_glthread_init()
231 _mesa_DeinitHashTable(&glthread->VAOs, NULL, NULL); in _mesa_glthread_init()
232 util_queue_destroy(&glthread->queue); in _mesa_glthread_init()
236 _mesa_glthread_init_dispatch(ctx, ctx->MarshalExec); in _mesa_glthread_init()
239 glthread->batches[i].ctx = ctx; in _mesa_glthread_init()
240 util_queue_fence_init(&glthread->batches[i].fence); in _mesa_glthread_init()
242 glthread->next_batch = &glthread->batches[glthread->next]; in _mesa_glthread_init()
243 glthread->used = 0; in _mesa_glthread_init()
244 glthread->stats.queue = &glthread->queue; in _mesa_glthread_init()
246 _mesa_glthread_init_call_fence(&glthread->LastProgramChangeBatch); in _mesa_glthread_init()
247 _mesa_glthread_init_call_fence(&glthread->LastDListChangeBatchIndex); in _mesa_glthread_init()
254 util_queue_add_job(&glthread->queue, ctx, &fence, in _mesa_glthread_init()
259 glthread->thread_sched_enabled = ctx->pipe->set_context_param && in _mesa_glthread_init()
261 util_thread_scheduler_init_state(&glthread->thread_sched_state); in _mesa_glthread_init()
274 struct glthread_state *glthread = &ctx->GLThread; in _mesa_glthread_destroy()
278 if (util_queue_is_initialized(&glthread->queue)) { in _mesa_glthread_destroy()
279 util_queue_destroy(&glthread->queue); in _mesa_glthread_destroy()
282 util_queue_fence_destroy(&glthread->batches[i].fence); in _mesa_glthread_destroy()
284 _mesa_DeinitHashTable(&glthread->VAOs, free_vao, NULL); in _mesa_glthread_destroy()
291 if (ctx->GLThread.enabled || in _mesa_glthread_enable()
292 ctx->Dispatch.Current == ctx->Dispatch.ContextLost || in _mesa_glthread_enable()
293 ctx->GLThread.DebugOutputSynchronous) in _mesa_glthread_enable()
296 ctx->GLThread.enabled = true; in _mesa_glthread_enable()
297 ctx->GLApi = ctx->MarshalExec; in _mesa_glthread_enable()
300 ctx->st->pin_thread_counter = ST_THREAD_SCHEDULER_DISABLED; in _mesa_glthread_enable()
303 if (_glapi_get_dispatch() == ctx->Dispatch.Current) { in _mesa_glthread_enable()
304 _glapi_set_dispatch(ctx->GLApi); in _mesa_glthread_enable()
310 if (!ctx->GLThread.enabled) in _mesa_glthread_disable()
315 ctx->GLThread.enabled = false; in _mesa_glthread_disable()
316 ctx->GLApi = ctx->Dispatch.Current; in _mesa_glthread_disable()
318 /* Re-enable thread scheduling in st/mesa when glthread is disabled. */ in _mesa_glthread_disable()
319 if (ctx->pipe->set_context_param && util_thread_scheduler_enabled()) in _mesa_glthread_disable()
320 ctx->st->pin_thread_counter = 0; in _mesa_glthread_disable()
323 if (_glapi_get_dispatch() == ctx->MarshalExec) { in _mesa_glthread_disable()
324 _glapi_set_dispatch(ctx->GLApi); in _mesa_glthread_disable()
327 /* Unbind VBOs in all VAOs that glthread bound for non-VBO vertex uploads in _mesa_glthread_disable()
330 if (ctx->API != API_OPENGL_CORE) in _mesa_glthread_disable()
338 struct glthread_batch *next = glthread->next_batch; in glthread_finalize_batch()
342 (struct marshal_cmd_base *)&next->buffer[glthread->used]; in glthread_finalize_batch()
343 last->cmd_id = NUM_DISPATCH_CMD; in glthread_finalize_batch()
345 p_atomic_add(num_items_counter, glthread->used); in glthread_finalize_batch()
346 next->used = glthread->used; in glthread_finalize_batch()
347 glthread->used = 0; in glthread_finalize_batch()
349 glthread->LastCallList = NULL; in glthread_finalize_batch()
350 glthread->LastBindBuffer1 = NULL; in glthread_finalize_batch()
351 glthread->LastBindBuffer2 = NULL; in glthread_finalize_batch()
357 struct glthread_state *glthread = &ctx->GLThread; in _mesa_glthread_flush_batch()
358 if (!glthread->enabled) in _mesa_glthread_flush_batch()
361 if (ctx->Dispatch.Current == ctx->Dispatch.ContextLost) { in _mesa_glthread_flush_batch()
366 if (!glthread->used) in _mesa_glthread_flush_batch()
370 glthread_finalize_batch(glthread, &glthread->stats.num_offloaded_items); in _mesa_glthread_flush_batch()
372 struct glthread_batch *next = glthread->next_batch; in _mesa_glthread_flush_batch()
374 util_queue_add_job(&glthread->queue, next, &next->fence, in _mesa_glthread_flush_batch()
376 glthread->last = glthread->next; in _mesa_glthread_flush_batch()
377 glthread->next = (glthread->next + 1) % MARSHAL_MAX_BATCHES; in _mesa_glthread_flush_batch()
378 glthread->next_batch = &glthread->batches[glthread->next]; in _mesa_glthread_flush_batch()
390 struct glthread_state *glthread = &ctx->GLThread; in _mesa_glthread_finish()
391 if (!glthread->enabled) in _mesa_glthread_finish()
399 if (u_thread_is_self(glthread->queue.threads[0])) in _mesa_glthread_finish()
402 struct glthread_batch *last = &glthread->batches[glthread->last]; in _mesa_glthread_finish()
403 struct glthread_batch *next = glthread->next_batch; in _mesa_glthread_finish()
406 if (!util_queue_fence_is_signalled(&last->fence)) { in _mesa_glthread_finish()
407 util_queue_fence_wait(&last->fence); in _mesa_glthread_finish()
413 if (glthread->used) { in _mesa_glthread_finish()
414 glthread_finalize_batch(glthread, &glthread->stats.num_direct_items); in _mesa_glthread_finish()
430 p_atomic_inc(&glthread->stats.num_syncs); in _mesa_glthread_finish()
466 struct glthread_state *glthread = &ctx->GLThread; in _mesa_glthread_invalidate_zsbuf()
467 if (!glthread->enabled) in _mesa_glthread_invalidate_zsbuf()