[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47747] trunk/blender: Add user preference "GPU Mipmap Generation" under the System/OpenGL
Antony Riakiotakis
kalast at gmail.com
Mon Jun 11 18:23:16 CEST 2012
Revision: 47747
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47747
Author: psy-fi
Date: 2012-06-11 16:23:10 +0000 (Mon, 11 Jun 2012)
Log Message:
-----------
Add user preference "GPU Mipmap Generation" under the System/OpenGL
subpanel to calculate image mipmapping on the GPU, saving upload and
calculation time. Default is off just in case.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
trunk/blender/source/blender/gpu/GPU_draw.h
trunk/blender/source/blender/gpu/intern/gpu_draw.c
trunk/blender/source/blender/makesdna/DNA_userdef_types.h
trunk/blender/source/blender/makesrna/intern/rna_userdef.c
trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2012-06-11 15:28:45 UTC (rev 47746)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2012-06-11 16:23:10 UTC (rev 47747)
@@ -434,6 +434,7 @@
col.label(text="OpenGL:")
col.prop(system, "gl_clip_alpha", slider=True)
col.prop(system, "use_mipmaps")
+ col.prop(system, "use_gpu_mipmap")
col.prop(system, "use_16bit_textures")
col.label(text="Anisotropic Filtering")
col.prop(system, "anisotropic_filter", text="")
Modified: trunk/blender/source/blender/gpu/GPU_draw.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_draw.h 2012-06-11 15:28:45 UTC (rev 47746)
+++ trunk/blender/source/blender/gpu/GPU_draw.h 2012-06-11 16:23:10 UTC (rev 47747)
@@ -112,6 +112,9 @@
void GPU_set_anisotropic(float value);
float GPU_get_anisotropic(void);
+/* enable gpu mipmapping */
+void GPU_set_gpu_mipmapping(int gpu_mipmap);
+
/* Image updates and free
* - these deal with images bound as opengl textures */
Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_draw.c 2012-06-11 15:28:45 UTC (rev 47746)
+++ trunk/blender/source/blender/gpu/intern/gpu_draw.c 2012-06-11 16:23:10 UTC (rev 47747)
@@ -234,11 +234,23 @@
int alphablend;
float anisotropic;
+ int gpu_mipmap;
MTFace *lasttface;
-} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.f, NULL};
+} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.f, 0, NULL};
/* Mipmap settings */
+void GPU_set_gpu_mipmapping(int gpu_mipmap){
+ int old_value = GTS.gpu_mipmap;
+
+ /* only actually enable if it's supported */
+ GTS.gpu_mipmap = gpu_mipmap && GLEW_EXT_framebuffer_object;
+
+ if(old_value != GTS.gpu_mipmap) {
+ GPU_free_images();
+ }
+}
+
void GPU_set_mipmap(int mipmap)
{
if (GTS.domipmap != (mipmap != 0)) {
@@ -632,10 +644,19 @@
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
}
else {
- if (use_high_bit_depth)
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect);
- else
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ if(GTS.gpu_mipmap) {
+ if (use_high_bit_depth)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
+ else
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
+ } else {
+ if (use_high_bit_depth)
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect);
+ else
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2012-06-11 15:28:45 UTC (rev 47746)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2012-06-11 16:23:10 UTC (rev 47747)
@@ -412,7 +412,7 @@
short widget_unit; /* defaults to 20 for 72 DPI setting */
short anisotropic_filter;
- short use_16bit_textures, pad8;
+ short use_16bit_textures, use_gpu_mipmap;
float ndof_sensitivity; /* overall sensitivity of 3D mouse */
int ndof_flag; /* flags for 3D mouse */
Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c 2012-06-11 15:28:45 UTC (rev 47746)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c 2012-06-11 16:23:10 UTC (rev 47747)
@@ -144,6 +144,11 @@
rna_userdef_update(bmain, scene, ptr);
}
+static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) {
+ GPU_set_gpu_mipmapping(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();
@@ -3143,6 +3148,11 @@
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, "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",
Modified: trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c 2012-06-11 15:28:45 UTC (rev 47746)
+++ trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c 2012-06-11 16:23:10 UTC (rev 47747)
@@ -178,7 +178,8 @@
GPU_extensions_init();
GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
GPU_set_anisotropic(U.anisotropic_filter);
-
+ GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
+
UI_init();
}
More information about the Bf-blender-cvs
mailing list