diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 8755e37c68d..944df961306 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -482,8 +482,8 @@ class USERPREF_PT_system(Panel): col.separator() - col.label(text="Images:") - col.prop(system, "image_gpubuffer_limit") + col.label(text="Images Draw Method:") + col.prop(system, "image_draw_method", text="") col.separator() col.separator() diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3723fe54cec..fdeb48e07ee 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7764,14 +7764,8 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd) copy_v4_v4_char(btheme->tseq.grid, btheme->tseq.back); } } - - if (bmain->versionfile < 267) { - - if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "image_gpubuffer_limit")) - user->image_gpubuffer_limit = 20; - - } } + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index b6ee9254396..dd8c5fab0c6 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -708,17 +708,13 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo /* uses either DrawPixelsSafe or DrawPixelsTex, based on user defined maximum */ void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect) { - if (U.image_gpubuffer_limit) { - /* Megapixels, use float math to prevent overflow */ - float img_size = ((float)img_w * (float)img_h) / (1024.0f * 1024.0f); - - if (U.image_gpubuffer_limit > (int)img_size) { - glColor4f(1.0, 1.0, 1.0, 1.0); - glaDrawPixelsTex(x, y, img_w, img_h, format, type, zoomfilter, rect); - return; - } + if (U.image_draw_method != IMAGE_DRAW_METHOD_DRAWPIXELS) { + glColor4f(1.0, 1.0, 1.0, 1.0); + glaDrawPixelsTex(x, y, img_w, img_h, format, type, zoomfilter, rect); + } + else { + glaDrawPixelsSafe(x, y, img_w, img_h, img_w, format, type, rect); } - glaDrawPixelsSafe(x, y, img_w, img_h, img_w, format, type, rect); } /* 2D Drawing Assistance */ @@ -1052,6 +1048,11 @@ void glaDrawImBuf_glsl(ImBuf *ibuf, float x, float y, int zoomfilter, /* Single channel images could not be transformed using GLSL yet */ force_fallback = ibuf->channels == 1; + /* If user decided not to use GLSL, fallback to glaDrawPixelsAuto */ + force_fallback = !ELEM(U.image_draw_method, + IMAGE_DRAW_METHOD_AUTO, + IMAGE_DRAW_METHOD_GLSL); + /* This is actually lots of crap, but currently not sure about * more clear way to bypass partial buffer update crappyness * while rendering. diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index a68d702594f..c7aa6254bc7 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -452,7 +452,7 @@ typedef struct UserDef { short ogl_multisamples; /* amount of samples for OpenGL FSA, if zero no FSA */ - short image_gpubuffer_limit; /* If set, amount of mega-pixels to use for texture drawing of images */ + short image_draw_method; /* Method to be used to draw the images (AUTO, GLSL, Textures or DrawPixels) */ float glalphaclip; @@ -753,7 +753,12 @@ typedef enum eMultiSample_Type { USER_MULTISAMPLE_16 = 16, } eMultiSample_Type; - +typedef enum eImageDrawMethod { + IMAGE_DRAW_METHOD_AUTO = 0, + IMAGE_DRAW_METHOD_GLSL = 1, + IMAGE_DRAW_METHOD_2DTEXTURE = 2, + IMAGE_DRAW_METHOD_DRAWPIXELS = 3, +} eImageDrawMethod; #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 42954937450..63765516650 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3374,6 +3374,14 @@ static void rna_def_userdef_system(BlenderRNA *brna) }; #endif + static EnumPropertyItem image_draw_methods[] = { + {IMAGE_DRAW_METHOD_AUTO, "AUTO", 0, "Auto", "Try to detect best drawing method automatically"}, + {IMAGE_DRAW_METHOD_GLSL, "GLSL", 0, "GLSL", "Use GLSL shaders for display transform and draw image with 2D texture"}, + {IMAGE_DRAW_METHOD_2DTEXTURE, "2DTEXTURE", 0, "2D Texture", "Use CPU for display transform and draw image with 2D texture"}, + {IMAGE_DRAW_METHOD_DRAWPIXELS, "DRAWPIXELS", 0, "DrawPixels", "Use CPU for display transform and draw image using DrawPixels"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "UserPreferencesSystem", NULL); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "UserPreferences"); @@ -3518,12 +3526,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "GPU Mipmap Generation", "Generate Image Mipmaps on the GPU"); RNA_def_property_update(prop, 0, "rna_userdef_gl_gpu_mipmaps"); - prop = RNA_def_property(srna, "image_gpubuffer_limit", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "image_gpubuffer_limit"); - RNA_def_property_range(prop, 0, 128); - RNA_def_property_ui_text(prop, "Image GPU draw limit", "If set, amount of Mega Pixels to use for drawing Images as GPU textures"); - - + prop = RNA_def_property(srna, "image_draw_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, image_draw_methods); + RNA_def_property_enum_sdna(prop, NULL, "image_draw_method"); + RNA_def_property_ui_text(prop, "Image Draw Method", "Method used for displaying images on the screen"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "use_vertex_buffer_objects", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_VBO); RNA_def_property_ui_text(prop, "VBOs",