Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_context.cpp
| Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* BLI_assert(thread_is_main()); */ | /* BLI_assert(thread_is_main()); */ | ||||
| GPUContext *ctx = new GPUContext; | GPUContext *ctx = new GPUContext; | ||||
| glGenVertexArrays(1, &ctx->default_vao); | glGenVertexArrays(1, &ctx->default_vao); | ||||
| GPU_context_active_set(ctx); | GPU_context_active_set(ctx); | ||||
| return ctx; | return ctx; | ||||
| } | } | ||||
| extern "C" { | |||||
| extern void BPyGPUOffScreen_free_for_context(GPUContext *); | |||||
| } | |||||
| /* to be called after GPU_context_active_set(ctx_to_destroy) */ | /* to be called after GPU_context_active_set(ctx_to_destroy) */ | ||||
| void GPU_context_discard(GPUContext *ctx) | void GPU_context_discard(GPUContext *ctx) | ||||
| { | { | ||||
| /* Make sure no other thread has locked it. */ | /* Make sure no other thread has locked it. */ | ||||
| BLI_assert(ctx == active_ctx); | BLI_assert(ctx == active_ctx); | ||||
| BLI_assert(pthread_equal(pthread_self(), ctx->thread)); | BLI_assert(pthread_equal(pthread_self(), ctx->thread)); | ||||
| BLI_assert(ctx->orphaned_vertarray_ids.empty()); | BLI_assert(ctx->orphaned_vertarray_ids.empty()); | ||||
| BPyGPUOffScreen_free_for_context(ctx); | |||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| /* For now don't allow GPUFrameBuffers to be reuse in another ctx. */ | /* For now don't allow GPUFrameBuffers to be reuse in another ctx. */ | ||||
| BLI_assert(ctx->framebuffers.empty()); | BLI_assert(ctx->framebuffers.empty()); | ||||
| #endif | #endif | ||||
| /* delete remaining vaos */ | /* delete remaining vaos */ | ||||
| while (!ctx->batches.empty()) { | while (!ctx->batches.empty()) { | ||||
| /* this removes the array entry */ | /* this removes the array entry */ | ||||
| GPU_batch_vao_cache_clear(*ctx->batches.begin()); | GPU_batch_vao_cache_clear(*ctx->batches.begin()); | ||||
| ▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines | |||||