diff options
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 47 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 15 |
2 files changed, 61 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index f00126a7fab..4ded9dc6162 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -62,6 +62,9 @@ #include "BKE_object.h" #include "BKE_utildefines.h" +#include "BLI_threads.h" +#include "BLI_blenlib.h" + #include "GPU_extensions.h" #include "GPU_material.h" #include "GPU_draw.h" @@ -781,8 +784,44 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->shadow); } +ListBase image_free_queue = {NULL, NULL}; +static ThreadMutex queuelock = BLI_MUTEX_INITIALIZER; + +static void flush_queued_free(void) +{ + Image *ima, *imanext; + + BLI_mutex_lock(&queuelock); + + ima = image_free_queue.first; + image_free_queue.first = image_free_queue.last = NULL; + for (; ima; ima=imanext) { + imanext = (Image*)ima->id.next; + GPU_free_image(ima); + MEM_freeN(ima); + } + + BLI_mutex_unlock(&queuelock); +} + +static void queue_image_for_free(Image *ima) +{ + Image *cpy = MEM_dupallocN(ima); + + BLI_mutex_lock(&queuelock); + BLI_addtail(&image_free_queue, cpy); + BLI_mutex_unlock(&queuelock); +} + void GPU_free_image(Image *ima) { + if (!BLI_thread_is_main()) { + queue_image_for_free(ima); + return; + } else if (image_free_queue.first) { + flush_queued_free(); + } + /* free regular image binding */ if(ima->bindcode) { glDeleteTextures(1, (GLuint *)&ima->bindcode); @@ -1097,6 +1136,14 @@ void GPU_end_object_materials(void) GMS.matbuf= NULL; GMS.gmatbuf= NULL; GMS.blendmode= NULL; + + /* resetting the texture matrix after the glScale needed for tiled textures */ + if(GTS.tilemode) + { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + } } /* Lights */ diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 8e0a23ccfeb..4eaf969ee8a 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -71,6 +71,7 @@ static struct GPUGlobal { GLuint currentfb; int glslsupport; int extdisabled; + int color24bit; GPUDeviceType device; GPUOSType os; GPUDriverType driver; @@ -92,6 +93,7 @@ void GPU_extensions_disable() void GPU_extensions_init() { + GLint bits; const char *vendor, *renderer; glewInit(); @@ -106,6 +108,9 @@ void GPU_extensions_init() if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0; if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0; + glGetIntegerv(GL_RED_BITS, &bits); + GG.color24bit = (bits >= 8); + vendor = (const char*)glGetString(GL_VENDOR); renderer = (const char*)glGetString(GL_RENDERER); @@ -117,7 +122,10 @@ void GPU_extensions_init() GG.device = GPU_DEVICE_NVIDIA; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(vendor, "Intel") || strstr(renderer, "Mesa DRI Intel")) { + else if(strstr(vendor, "Intel") || + /* src/mesa/drivers/dri/intel/intel_context.c */ + strstr(renderer, "Mesa DRI Intel") || + strstr(renderer, "Mesa DRI Mobile Intel")) { GG.device = GPU_DEVICE_INTEL; GG.driver = GPU_DRIVER_OFFICIAL; } @@ -170,6 +178,11 @@ int GPU_non_power_of_two_support() return GLEW_ARB_texture_non_power_of_two; } +int GPU_24bit_color_support() +{ + return GG.color24bit; +} + int GPU_print_error(char *str) { GLenum errCode; |