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
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/blender/gpu
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/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_draw.h3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c31
2 files changed, 29 insertions, 5 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));