Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_context.cc
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| } // namespace blender::gpu | } // namespace blender::gpu | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| GPUContext *GPU_context_create(void *ghost_window) | GPUContext *GPU_context_create(void *ghost_window, void *ghost_context) | ||||
| { | { | ||||
| { | { | ||||
| std::scoped_lock lock(backend_users_mutex); | std::scoped_lock lock(backend_users_mutex); | ||||
| if (num_backend_users == 0) { | if (num_backend_users == 0) { | ||||
| /* Automatically create backend when first context is created. */ | /* Automatically create backend when first context is created. */ | ||||
| gpu_backend_create(); | gpu_backend_create(); | ||||
| } | } | ||||
| num_backend_users++; | num_backend_users++; | ||||
| } | } | ||||
| Context *ctx = GPUBackend::get()->context_alloc(ghost_window); | Context *ctx = GPUBackend::get()->context_alloc(ghost_window, ghost_context); | ||||
| GPU_context_active_set(wrap(ctx)); | GPU_context_active_set(wrap(ctx)); | ||||
| return wrap(ctx); | return wrap(ctx); | ||||
| } | } | ||||
| void GPU_context_discard(GPUContext *ctx_) | void GPU_context_discard(GPUContext *ctx_) | ||||
| { | { | ||||
| Context *ctx = unwrap(ctx_); | Context *ctx = unwrap(ctx_); | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Backend selection | /** \name Backend selection | ||||
| * \{ */ | * \{ */ | ||||
| /* NOTE: To enable Metal API, we need to temporarily change this to `GPU_BACKEND_METAL`. | |||||
| * Until a global switch is added, Metal also needs to be enabled in GHOST_ContextCGL: | |||||
| * `m_useMetalForRendering = true`. */ | |||||
| static const eGPUBackendType g_backend_type = GPU_BACKEND_OPENGL; | static const eGPUBackendType g_backend_type = GPU_BACKEND_OPENGL; | ||||
| static GPUBackend *g_backend = nullptr; | static GPUBackend *g_backend = nullptr; | ||||
| bool GPU_backend_supported(void) | bool GPU_backend_supported(void) | ||||
| { | { | ||||
| switch (g_backend_type) { | switch (g_backend_type) { | ||||
| case GPU_BACKEND_OPENGL: | case GPU_BACKEND_OPENGL: | ||||
| #ifdef WITH_OPENGL_BACKEND | #ifdef WITH_OPENGL_BACKEND | ||||
| ▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines | |||||