Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_draw.c
| Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Anisotropic filtering settings */ | /* Anisotropic filtering settings */ | ||||
| void GPU_set_anisotropic(Main *bmain, float value) | void GPU_set_anisotropic(Main *bmain, float value) | ||||
| { | { | ||||
| if (GTS.anisotropic != value) { | if (GTS.anisotropic != value) { | ||||
| GPU_free_images(bmain); | GPU_samplers_free(); | ||||
| /* Clamp value to the maximum value the graphics card supports */ | /* Clamp value to the maximum value the graphics card supports */ | ||||
| const float max = GPU_max_texture_anisotropy(); | const float max = GPU_max_texture_anisotropy(); | ||||
| if (value > max) { | if (value > max) { | ||||
| value = max; | value = max; | ||||
| } | } | ||||
| GTS.anisotropic = value; | GTS.anisotropic = value; | ||||
| GPU_samplers_init(); | |||||
| } | } | ||||
| } | } | ||||
| float GPU_get_anisotropic(void) | float GPU_get_anisotropic(void) | ||||
| { | { | ||||
| return GTS.anisotropic; | return GTS.anisotropic; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | if (ibuf) { | ||||
| if (scale_ibuf != NULL) { | if (scale_ibuf != NULL) { | ||||
| IMB_freeImBuf(scale_ibuf); | IMB_freeImBuf(scale_ibuf); | ||||
| } | } | ||||
| } | } | ||||
| BKE_image_release_ibuf(ima, ibuf, NULL); | 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()) { | if (GPU_get_mipmap()) { | ||||
| glGenerateMipmap(GL_TEXTURE_2D_ARRAY); | glGenerateMipmap(GL_TEXTURE_2D_ARRAY); | ||||
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); | |||||
| if (ima) { | if (ima) { | ||||
| ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE; | 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); | glBindTexture(GL_TEXTURE_2D_ARRAY, 0); | ||||
| return bindcode; | return bindcode; | ||||
| } | } | ||||
| static uint gpu_texture_create_from_ibuf(Image *ima, ImBuf *ibuf, int textarget) | static uint gpu_texture_create_from_ibuf(Image *ima, ImBuf *ibuf, int textarget) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 617 Lines • ▼ Show 20 Lines | if (textarget == GL_TEXTURE_2D) { | ||||
| if (frect) { | if (frect) { | ||||
| glTexImage2D(GL_TEXTURE_2D, 0, internal_format, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); | glTexImage2D(GL_TEXTURE_2D, 0, internal_format, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); | ||||
| } | } | ||||
| else { | else { | ||||
| glTexImage2D( | glTexImage2D( | ||||
| GL_TEXTURE_2D, 0, internal_format, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); | 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) { | if (GPU_get_mipmap() && mipmap) { | ||||
| glGenerateMipmap(GL_TEXTURE_2D); | glGenerateMipmap(GL_TEXTURE_2D); | ||||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); | |||||
| if (ima) { | if (ima) { | ||||
| ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE; | ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE; | ||||
| } | } | ||||
| } | } | ||||
| else { | |||||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |||||
| } | |||||
| } | } | ||||
| else if (textarget == GL_TEXTURE_CUBE_MAP) { | else if (textarget == GL_TEXTURE_CUBE_MAP) { | ||||
| int w = rectw / 3, h = recth / 2; | int w = rectw / 3, h = recth / 2; | ||||
| if (h == w && is_power_of_2_i(h) && !is_over_resolution_limit(textarget, h, w)) { | if (h == w && is_power_of_2_i(h) && !is_over_resolution_limit(textarget, h, w)) { | ||||
| void **cube_map = gpu_gen_cube_map(rect, frect, rectw, recth); | void **cube_map = gpu_gen_cube_map(rect, frect, rectw, recth); | ||||
| GLenum type = frect ? GL_FLOAT : GL_UNSIGNED_BYTE; | GLenum type = frect ? GL_FLOAT : GL_UNSIGNED_BYTE; | ||||
| if (cube_map) { | if (cube_map) { | ||||
| for (int i = 0; i < 6; i++) { | for (int i = 0; i < 6; i++) { | ||||
| glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, | glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, | ||||
| 0, | 0, | ||||
| internal_format, | internal_format, | ||||
| w, | w, | ||||
| h, | h, | ||||
| 0, | 0, | ||||
| GL_RGBA, | GL_RGBA, | ||||
| type, | type, | ||||
| cube_map[i]); | cube_map[i]); | ||||
| } | } | ||||
| } | } | ||||
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); | |||||
| if (GPU_get_mipmap() && mipmap) { | if (GPU_get_mipmap() && mipmap) { | ||||
| glGenerateMipmap(GL_TEXTURE_CUBE_MAP); | glGenerateMipmap(GL_TEXTURE_CUBE_MAP); | ||||
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); | |||||
| if (ima) { | if (ima) { | ||||
| ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE; | 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); | gpu_del_cube_map(cube_map); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("Incorrect envmap size\n"); | printf("Incorrect envmap size\n"); | ||||
| } | } | ||||
| } | } | ||||
| if (GLEW_EXT_texture_filter_anisotropic) { | |||||
| glTexParameterf(textarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); | |||||
| } | |||||
| glBindTexture(textarget, 0); | glBindTexture(textarget, 0); | ||||
| if (ibuf) { | if (ibuf) { | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| Show All 35 Lines | fprintf( | ||||
| stderr, | stderr, | ||||
| "Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); | "Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); | 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)); | 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; | blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16; | ||||
| for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); i++) { | for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); i++) { | ||||
| if (width == 0) { | if (width == 0) { | ||||
| width = 1; | width = 1; | ||||
| } | } | ||||
| if (height == 0) { | if (height == 0) { | ||||
| height = 1; | height = 1; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines | |||||