Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2012-06-11 20:23:10 +0400
committerAntony Riakiotakis <kalast@gmail.com>2012-06-11 20:23:10 +0400
commit854502d2e3dc5d0c08721bc3a6a4e08be6189fda (patch)
tree87578809c8356bd587a63448b5ff493cb2b74cdc /source
parentedecf49d8408f565963ed03bc795b7eff712ac5d (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/GPU_draw.h3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c31
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c10
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c3
5 files changed, 42 insertions, 7 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 89976699114..438cfd6b741 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -112,6 +112,9 @@ void GPU_paint_set_mipmap(int mipmap);
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 */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 3e53f2f3836..a1bd8dcb3a3 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -234,11 +234,23 @@ static struct GPUTextureState {
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 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
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));
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 5465dbf6e3c..1c2844cd8a7 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -412,7 +412,7 @@ typedef struct UserDef {
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 */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 84723e95e80..42eb06b137a 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -144,6 +144,11 @@ 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(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 @@ 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, "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",
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index ab377d53ec7..c82cae8ac92 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -178,7 +178,8 @@ void WM_init(bContext *C, int argc, const char **argv)
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();
}