[Bf-blender-cvs] [3246edc8b46] tmp-texture-sampler: GPU: Draw: Move filter parameters to sampler_state.

Clément Foucault noreply at git.blender.org
Mon May 25 10:49:45 CEST 2020


Commit: 3246edc8b46cad7f29c9ebcac9d5c9b3f63f0c6d
Author: Clément Foucault
Date:   Sat May 23 01:30:40 2020 +0200
Branches: tmp-texture-sampler
https://developer.blender.org/rB3246edc8b46cad7f29c9ebcac9d5c9b3f63f0c6d

GPU: Draw: Move filter parameters to sampler_state.

===================================================================

M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_texture.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 7871907a7d4..7a9b4bafc74 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -161,7 +161,7 @@ static GLenum gpu_get_mipmap_filter(bool mag)
 void GPU_set_anisotropic(Main *bmain, float value)
 {
   if (GTS.anisotropic != value) {
-    GPU_free_images(bmain);
+    GPU_samplers_free();
 
     /* Clamp value to the maximum value the graphics card supports */
     const float max = GPU_max_texture_anisotropy();
@@ -170,6 +170,8 @@ void GPU_set_anisotropic(Main *bmain, float value)
     }
 
     GTS.anisotropic = value;
+
+    GPU_samplers_init();
   }
 }
 
@@ -449,22 +451,12 @@ static uint gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
     BKE_image_release_ibuf(ima, ibuf, NULL);
   }
 
-  glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
-
   if (GPU_get_mipmap()) {
     glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
-    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
     if (ima) {
       ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
     }
   }
-  else {
-    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-  }
-
-  if (GLEW_EXT_texture_filter_anisotropic) {
-    glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
-  }
 
   glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
 
@@ -1098,18 +1090,12 @@ void GPU_create_gl_tex(uint *bind,
           GL_TEXTURE_2D, 0, internal_format, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
     }
 
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
-
     if (GPU_get_mipmap() && mipmap) {
       glGenerateMipmap(GL_TEXTURE_2D);
-      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
       if (ima) {
         ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
       }
     }
-    else {
-      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    }
   }
   else if (textarget == GL_TEXTURE_CUBE_MAP) {
     int w = rectw / 3, h = recth / 2;
@@ -1132,22 +1118,13 @@ void GPU_create_gl_tex(uint *bind,
         }
       }
 
-      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
-
       if (GPU_get_mipmap() && mipmap) {
         glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
-        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
 
         if (ima) {
           ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
         }
       }
-      else {
-        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-      }
-      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
 
       gpu_del_cube_map(cube_map);
     }
@@ -1156,10 +1133,6 @@ void GPU_create_gl_tex(uint *bind,
     }
   }
 
-  if (GLEW_EXT_texture_filter_anisotropic) {
-    glTexParameterf(textarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
-  }
-
   glBindTexture(textarget, 0);
 
   if (ibuf) {
@@ -1211,10 +1184,6 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf, bool use_srgb)
   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));
 
-  if (GLEW_EXT_texture_filter_anisotropic) {
-    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
-  }
-
   blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16;
   for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); i++) {
     if (width == 0) {
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index f5dd24219df..d58ced3f956 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -1181,6 +1181,10 @@ GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode)
   tex->target = textarget;
   tex->target_base = textarget;
   tex->samples = 0;
+  tex->sampler_state = GPU_SAMPLER_REPEAT;
+  if (GPU_get_mipmap()) {
+    tex->sampler_state |= (GPU_SAMPLER_MIPMAP | GPU_SAMPLER_FILTER);
+  }
 
   if (!glIsTexture(tex->bindcode)) {
     GPU_print_error_debug("Blender Texture Not Loaded");



More information about the Bf-blender-cvs mailing list