Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_context.cc
| Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | if (ghost_window) { | ||||
| if (default_fbo != 0) { | if (default_fbo != 0) { | ||||
| front_left = new GLFrameBuffer("front_left", this, GL_COLOR_ATTACHMENT0, default_fbo, w, h); | front_left = new GLFrameBuffer("front_left", this, GL_COLOR_ATTACHMENT0, default_fbo, w, h); | ||||
| back_left = new GLFrameBuffer("back_left", this, GL_COLOR_ATTACHMENT0, default_fbo, w, h); | back_left = new GLFrameBuffer("back_left", this, GL_COLOR_ATTACHMENT0, default_fbo, w, h); | ||||
| } | } | ||||
| else { | else { | ||||
| front_left = new GLFrameBuffer("front_left", this, GL_FRONT_LEFT, 0, w, h); | front_left = new GLFrameBuffer("front_left", this, GL_FRONT_LEFT, 0, w, h); | ||||
| back_left = new GLFrameBuffer("back_left", this, GL_BACK_LEFT, 0, w, h); | back_left = new GLFrameBuffer("back_left", this, GL_BACK_LEFT, 0, w, h); | ||||
| } | } | ||||
| /* TODO(fclem) enable is supported. */ | GLboolean supports_stereo_quad_buffer = GL_FALSE; | ||||
| const bool supports_stereo_quad_buffer = false; | glGetBooleanv(GL_STEREO, &supports_stereo_quad_buffer); | ||||
| if (supports_stereo_quad_buffer) { | if (supports_stereo_quad_buffer) { | ||||
| front_right = new GLFrameBuffer("front_right", this, GL_FRONT_RIGHT, 0, w, h); | front_right = new GLFrameBuffer("front_right", this, GL_FRONT_RIGHT, 0, w, h); | ||||
| back_right = new GLFrameBuffer("back_right", this, GL_BACK_RIGHT, 0, w, h); | back_right = new GLFrameBuffer("back_right", this, GL_BACK_RIGHT, 0, w, h); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* For offscreen contexts. Default framebuffer is NULL. */ | /* For offscreen contexts. Default framebuffer is NULL. */ | ||||
| back_left = new GLFrameBuffer("back_left", this, GL_NONE, 0, 0, 0); | back_left = new GLFrameBuffer("back_left", this, GL_NONE, 0, 0, 0); | ||||
| ▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | void GLContext::fbo_free(GLuint fbo_id) | ||||
| if (this == GPU_context_active_get()) { | if (this == GPU_context_active_get()) { | ||||
| glDeleteFramebuffers(1, &fbo_id); | glDeleteFramebuffers(1, &fbo_id); | ||||
| } | } | ||||
| else { | else { | ||||
| orphans_add(orphaned_framebuffers_, lists_mutex_, fbo_id); | orphans_add(orphaned_framebuffers_, lists_mutex_, fbo_id); | ||||
| } | } | ||||
| } | } | ||||
| void GLBackend::buf_free(GLuint buf_id) | void GLContext::buf_free(GLuint buf_id) | ||||
| { | { | ||||
| /* Any context can free. */ | /* Any context can free. */ | ||||
| if (GPU_context_active_get()) { | if (GPU_context_active_get()) { | ||||
| glDeleteBuffers(1, &buf_id); | glDeleteBuffers(1, &buf_id); | ||||
| } | } | ||||
| else { | else { | ||||
| orphans_add(shared_orphan_list_.buffers, shared_orphan_list_.lists_mutex, buf_id); | GLSharedOrphanLists &orphan_list = GLBackend::get()->shared_orphan_list_get(); | ||||
| orphans_add(orphan_list.buffers, orphan_list.lists_mutex, buf_id); | |||||
| } | } | ||||
| } | } | ||||
| void GLBackend::tex_free(GLuint tex_id) | void GLContext::tex_free(GLuint tex_id) | ||||
| { | { | ||||
| /* Any context can free. */ | /* Any context can free. */ | ||||
| if (GPU_context_active_get()) { | if (GPU_context_active_get()) { | ||||
| glDeleteTextures(1, &tex_id); | glDeleteTextures(1, &tex_id); | ||||
| } | } | ||||
| else { | else { | ||||
| orphans_add(shared_orphan_list_.textures, shared_orphan_list_.lists_mutex, tex_id); | GLSharedOrphanLists &orphan_list = GLBackend::get()->shared_orphan_list_get(); | ||||
| orphans_add(orphan_list.textures, orphan_list.lists_mutex, tex_id); | |||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Linked object deletion | /** \name Linked object deletion | ||||
| * | * | ||||
| Show All 12 Lines | |||||
| void GLContext::vao_cache_unregister(GLVaoCache *cache) | void GLContext::vao_cache_unregister(GLVaoCache *cache) | ||||
| { | { | ||||
| lists_mutex_.lock(); | lists_mutex_.lock(); | ||||
| vao_caches_.remove(cache); | vao_caches_.remove(cache); | ||||
| lists_mutex_.unlock(); | lists_mutex_.unlock(); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Memory statistics | |||||
| * \{ */ | |||||
| void GLContext::memory_statistics_get(int *r_total_mem, int *r_free_mem) | |||||
| { | |||||
| /* TODO(merwin): use Apple's platform API to get this info. */ | |||||
| if (GLEW_NVX_gpu_memory_info) { | |||||
| /* Teturned value in Kb. */ | |||||
| glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, r_total_mem); | |||||
| glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, r_free_mem); | |||||
| } | |||||
| else if (GLEW_ATI_meminfo) { | |||||
| int stats[4]; | |||||
| glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, stats); | |||||
| *r_total_mem = 0; | |||||
| *r_free_mem = stats[0]; /* Total memory free in the pool. */ | |||||
| } | |||||
| else { | |||||
| *r_total_mem = 0; | |||||
| *r_free_mem = 0; | |||||
| } | |||||
| } | |||||
| /** \} */ | |||||