Preferences: always do GPU accelerated mipmapping, remove preference.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 16 Jan 2019 14:10:19 +0000 (15:10 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 16 Jan 2019 15:16:42 +0000 (16:16 +0100)
This setting was added long ago to be cautious in case some GPUs did not
support this propertly, no reason to have it anymore.

release/scripts/startup/bl_ui/space_userpref.py
source/blender/gpu/GPU_draw.h
source/blender/gpu/intern/gpu_draw.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_init_exit.c

index a4feabf72544556e78f930e7cf405fed0c9baace..115d9d2710701531c7469655201ba9c42ec24689 100644 (file)
@@ -657,7 +657,6 @@ class USERPREF_PT_system_opengl_textures(PreferencePanel):
         flow.prop(system, "image_draw_method", text="Image Display Method")
 
         flow.prop(system, "use_16bit_textures")
-        flow.prop(system, "use_gpu_mipmap")
 
 
 class USERPREF_PT_system_opengl_selection(PreferencePanel):
index 008f4199b027fc3a5c11aaa0aa638fb069009c53..4b94b79022b4caee5b2ec876bd2307e9657086b9 100644 (file)
@@ -80,9 +80,6 @@ void GPU_paint_set_mipmap(struct Main *bmain, bool mipmap);
 void GPU_set_anisotropic(struct Main *bmain, float value);
 float GPU_get_anisotropic(void);
 
-/* enable gpu mipmapping */
-void GPU_set_gpu_mipmapping(struct Main *bmain, int gpu_mipmap);
-
 /* Image updates and free
  * - these deal with images bound as opengl textures */
 
index 6f9392617299127e72d75763f23f24ca24480a7f..cf9cbc8ca8983106edac8eafa6c43883318a5354 100644 (file)
@@ -125,23 +125,10 @@ static struct GPUTextureState {
        bool texpaint;
 
        float anisotropic;
-       int gpu_mipmap;
-} GTS = {1, 0, 0, 1.0f, 0};
+} GTS = {1, 0, 0, 1.0f};
 
 /* Mipmap settings */
 
-void GPU_set_gpu_mipmapping(Main *bmain, int gpu_mipmap)
-{
-       int old_value = GTS.gpu_mipmap;
-
-       /* only actually enable if it's supported */
-       GTS.gpu_mipmap = gpu_mipmap;
-
-       if (old_value != GTS.gpu_mipmap) {
-               GPU_free_images(bmain);
-       }
-}
-
 void GPU_set_mipmap(Main *bmain, bool mipmap)
 {
        if (GTS.domipmap != mipmap) {
@@ -479,31 +466,7 @@ void GPU_create_gl_tex(
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
 
                if (GPU_get_mipmap() && mipmap) {
-                       if (GTS.gpu_mipmap) {
-                               glGenerateMipmap(GL_TEXTURE_2D);
-                       }
-                       else {
-                               int i;
-                               if (!ibuf) {
-                                       if (use_high_bit_depth) {
-                                               ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy);
-                                       }
-                                       else {
-                                               ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy);
-                                       }
-                               }
-                               IMB_makemipmap(ibuf, true);
-
-                               for (i = 1; i < ibuf->miptot; i++) {
-                                       ImBuf *mip = ibuf->mipmap[i - 1];
-                                       if (use_high_bit_depth) {
-                                               glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16F, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
-                                       }
-                                       else {
-                                               glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA8, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
-                                       }
-                               }
-                       }
+                       glGenerateMipmap(GL_TEXTURE_2D);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
                        if (ima)
                                ima->tpageflag |= IMA_MIPMAP_COMPLETE;
@@ -527,38 +490,7 @@ void GPU_create_gl_tex(
                        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
 
                        if (GPU_get_mipmap() && mipmap) {
-                               if (GTS.gpu_mipmap) {
-                                       glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
-                               }
-                               else {
-                                       if (!ibuf) {
-                                               if (use_high_bit_depth) {
-                                                       ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy);
-                                               }
-                                               else {
-                                                       ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy);
-                                               }
-                                       }
-
-                                       IMB_makemipmap(ibuf, true);
-
-                                       for (int i = 1; i < ibuf->miptot; i++) {
-                                               ImBuf *mip = ibuf->mipmap[i - 1];
-                                               void **mip_cube_map = gpu_gen_cube_map(
-                                                       mip->rect, mip->rect_float,
-                                                       mip->x, mip->y, use_high_bit_depth);
-                                               int mipw = mip->x / 3, miph = mip->y / 2;
-
-                                               if (mip_cube_map) {
-                                                       for (int j = 0; j < 6; j++) {
-                                                               glTexImage2D(
-                                                                       GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, i,
-                                                                       informat, mipw, miph, 0, GL_RGBA, type, mip_cube_map[j]);
-                                                       }
-                                               }
-                                               gpu_del_cube_map(mip_cube_map);
-                                       }
-                               }
+                               glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
                                glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
 
                                if (ima)
@@ -799,8 +731,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
 {
        ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
 
-       if ((!GTS.gpu_mipmap && GPU_get_mipmap()) ||
-           (ima->gputexture[TEXTARGET_TEXTURE_2D] == NULL) ||
+       if ((ima->gputexture[TEXTARGET_TEXTURE_2D] == NULL) ||
            (ibuf == NULL) ||
            (w == 0) || (h == 0))
        {
@@ -829,8 +760,6 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
 
                        MEM_freeN(buffer);
 
-                       /* we have already accounted for the case where GTS.gpu_mipmap is false
-                        * so we will be using GPU mipmap generation here */
                        if (GPU_get_mipmap()) {
                                glGenerateMipmap(GL_TEXTURE_2D);
                        }
index 996cfeb76b479bb2ae2ab5c87e717f78658ae3c3..854b7b7afc89a48f7476e79a8ec689e14577f84b 100644 (file)
@@ -694,12 +694,12 @@ typedef struct UserDef {
        /** Seconds to zoom around current frame. */
        float view_frame_seconds;
 
-       char _pad1[2];
+       char _pad1[4];
 
        /** Private, defaults to 20 for 72 DPI setting. */
        short widget_unit;
        short anisotropic_filter;
-       short use_16bit_textures, use_gpu_mipmap;
+       short use_16bit_textures;
 
        /** Tablet API to use (Windows only). */
        short tablet_api;
index eea2595d2a789c05a94c45550b895a2b4364fa0c..8f8b42faf70e50f2095c387fcf8b3bd911b81429 100644 (file)
@@ -185,12 +185,6 @@ static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA
        rna_userdef_update(bmain, scene, ptr);
 }
 
-static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-       GPU_set_gpu_mipmapping(bmain, U.use_gpu_mipmap);
-       rna_userdef_update(bmain, scene, ptr);
-}
-
 static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        GPU_free_images(bmain);
@@ -4484,11 +4478,6 @@ static void rna_def_userdef_system(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "16 Bit Float Textures", "Use 16 bit per component texture for float images");
        RNA_def_property_update(prop, 0, "rna_userdef_gl_use_16bit_textures");
 
-       prop = RNA_def_property(srna, "use_gpu_mipmap", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "use_gpu_mipmap", 1);
-       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_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");
index 2a99d06e9f9dd28634426ed3ad88f5d7c3cb9e44..134a1e31fcea2247790866d57c88110215f96a40 100644 (file)
@@ -187,7 +187,6 @@ void WM_init_opengl(Main *bmain)
        GPU_set_mipmap(bmain, true);
        GPU_set_linear_mipmap(true);
        GPU_set_anisotropic(bmain, U.anisotropic_filter);
-       GPU_set_gpu_mipmapping(bmain, U.use_gpu_mipmap);
 
        GPU_pass_cache_init();