2011-02-23 10:52:22 +00:00
|
|
|
/*
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2011-11-29 10:54:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup gpu
|
2014-01-19 23:14:24 +11:00
|
|
|
*
|
|
|
|
* Wrap OpenGL features such as textures, shaders and GLSL
|
|
|
|
* with checks for drivers and GPU support.
|
2011-02-27 20:25:53 +00:00
|
|
|
*/
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-12-16 09:25:07 +00:00
|
|
|
#include "BLI_math_base.h"
|
2015-03-30 14:14:32 +02:00
|
|
|
#include "BLI_math_vector.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BKE_global.h"
|
2018-10-22 12:58:11 +02:00
|
|
|
#include "MEM_guardedalloc.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "GPU_extensions.h"
|
2018-10-22 12:58:11 +02:00
|
|
|
#include "GPU_framebuffer.h"
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_glew.h"
|
|
|
|
#include "GPU_texture.h"
|
2019-10-03 16:21:23 +02:00
|
|
|
#include "GPU_platform.h"
|
2014-10-07 15:46:19 -05:00
|
|
|
|
2015-02-16 21:19:12 +01:00
|
|
|
#include "intern/gpu_private.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-04-15 07:54:07 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
# include "BLI_winstuff.h"
|
|
|
|
#endif
|
2011-03-07 00:49:21 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* Extensions support */
|
|
|
|
|
2015-11-22 13:22:47 -05:00
|
|
|
/* -- extension: version of GL that absorbs it
|
2016-08-04 21:11:45 -04:00
|
|
|
* EXT_gpu_shader4: 3.0
|
2015-11-22 13:22:47 -05:00
|
|
|
* ARB_framebuffer object: 3.0
|
|
|
|
* EXT_framebuffer_multisample_blit_scaled: ???
|
|
|
|
* ARB_draw_instanced: 3.1
|
|
|
|
* ARB_texture_multisample: 3.2
|
|
|
|
* ARB_texture_query_lod: 4.0
|
2012-03-09 18:28:30 +00:00
|
|
|
*/
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2008-10-12 18:32:26 +00:00
|
|
|
static struct GPUGlobal {
|
2019-04-17 06:17:24 +02:00
|
|
|
GLint maxtexsize;
|
|
|
|
GLint maxtexlayers;
|
|
|
|
GLint maxcubemapsize;
|
|
|
|
GLint maxtextures;
|
|
|
|
GLint maxtexturesfrag;
|
|
|
|
GLint maxtexturesgeom;
|
|
|
|
GLint maxtexturesvert;
|
|
|
|
GLint maxubosize;
|
|
|
|
GLint maxubobinds;
|
|
|
|
int samples_color_texture_max;
|
|
|
|
float line_width_range[2];
|
|
|
|
/* workaround for different calculation of dfdy factors on GPUs. Some GPUs/drivers
|
|
|
|
* calculate dfdy in shader differently when drawing to an offscreen buffer. First
|
|
|
|
* number is factor on screen and second is off-screen */
|
|
|
|
float dfdyfactors[2];
|
|
|
|
float max_anisotropy;
|
2019-07-31 16:35:06 -03:00
|
|
|
/* Some Intel drivers have limited support for `GLEW_ARB_base_instance` so in
|
|
|
|
* these cases it is best to indicate that it is not supported. See T67951 */
|
|
|
|
bool glew_arb_base_instance_is_supported;
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Some Intel drivers have issues with using mips as framebuffer targets if
|
|
|
|
* GL_TEXTURE_MAX_LEVEL is higher than the target mip.
|
|
|
|
* We need a workaround in this cases. */
|
|
|
|
bool mip_render_workaround;
|
|
|
|
/* There is an issue with the glBlitFramebuffer on MacOS with radeon pro graphics.
|
|
|
|
* Blitting depth with GL_DEPTH24_STENCIL8 is buggy so the workaround is to use
|
|
|
|
* GPU_DEPTH32F_STENCIL8. Then Blitting depth will work but blitting stencil will
|
|
|
|
* still be broken. */
|
|
|
|
bool depth_blitting_workaround;
|
|
|
|
/* Crappy driver don't know how to map framebuffer slot to output vars...
|
|
|
|
* We need to have no "holes" in the output buffer slots. */
|
|
|
|
bool unused_fb_slot_workaround;
|
2020-02-18 17:30:05 +01:00
|
|
|
bool broken_amd_driver;
|
2019-06-05 13:06:11 -03:00
|
|
|
/* Some crappy Intel drivers don't work well with shaders created in different
|
|
|
|
* rendering contexts. */
|
|
|
|
bool context_local_shaders_workaround;
|
2012-05-01 02:50:17 +00:00
|
|
|
} GG = {1, 0};
|
2008-10-12 18:32:26 +00:00
|
|
|
|
2018-10-22 12:58:11 +02:00
|
|
|
static void gpu_detect_mip_render_workaround(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int cube_size = 2;
|
|
|
|
float *source_pix = MEM_callocN(sizeof(float) * 4 * 6 * cube_size * cube_size, __func__);
|
|
|
|
float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
GPUTexture *tex = GPU_texture_create_cube(cube_size, GPU_RGBA16F, source_pix, NULL);
|
|
|
|
MEM_freeN(source_pix);
|
|
|
|
|
|
|
|
GPU_texture_bind(tex, 0);
|
|
|
|
GPU_texture_generate_mipmap(tex);
|
|
|
|
glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_BASE_LEVEL, 0);
|
|
|
|
glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, 0);
|
|
|
|
GPU_texture_unbind(tex);
|
|
|
|
|
|
|
|
GPUFrameBuffer *fb = GPU_framebuffer_create();
|
|
|
|
GPU_framebuffer_texture_attach(fb, tex, 0, 1);
|
|
|
|
GPU_framebuffer_bind(fb);
|
|
|
|
GPU_framebuffer_clear_color(fb, clear_color);
|
|
|
|
GPU_framebuffer_restore();
|
|
|
|
GPU_framebuffer_free(fb);
|
|
|
|
|
|
|
|
float *data = GPU_texture_read(tex, GPU_DATA_FLOAT, 1);
|
|
|
|
GG.mip_render_workaround = !equals_v4v4(clear_color, data);
|
|
|
|
|
|
|
|
MEM_freeN(data);
|
|
|
|
GPU_texture_free(tex);
|
2018-10-22 12:58:11 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 23:45:51 +00:00
|
|
|
/* GPU Extensions */
|
|
|
|
|
2013-04-13 00:43:49 +00:00
|
|
|
int GPU_max_texture_size(void)
|
2013-04-12 17:56:07 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxtexsize;
|
2013-04-12 17:56:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-27 13:56:07 +02:00
|
|
|
int GPU_max_texture_layers(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxtexlayers;
|
2018-07-27 13:56:07 +02:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
int GPU_max_textures(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxtextures;
|
2015-12-06 21:20:19 +01:00
|
|
|
}
|
|
|
|
|
2018-09-18 14:22:42 +02:00
|
|
|
int GPU_max_textures_frag(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxtexturesfrag;
|
2018-09-18 14:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_textures_geom(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxtexturesgeom;
|
2018-09-18 14:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_textures_vert(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxtexturesvert;
|
2018-09-18 14:22:42 +02:00
|
|
|
}
|
|
|
|
|
2016-01-07 11:21:08 -05:00
|
|
|
float GPU_max_texture_anisotropy(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.max_anisotropy;
|
2016-01-07 11:21:08 -05:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
int GPU_max_color_texture_samples(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.samples_color_texture_max;
|
2015-12-06 21:20:19 +01:00
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
int GPU_max_cube_map_size(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxcubemapsize;
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
int GPU_max_ubo_binds(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxubobinds;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_ubo_size(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.maxubosize;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
2018-11-02 14:58:49 +01:00
|
|
|
float GPU_max_line_width(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.line_width_range[1];
|
2018-11-02 14:58:49 +01:00
|
|
|
}
|
|
|
|
|
2015-03-30 14:14:32 +02:00
|
|
|
void GPU_get_dfdy_factors(float fac[2])
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
copy_v2_v2(fac, GG.dfdyfactors);
|
2015-03-30 14:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-31 16:35:06 -03:00
|
|
|
bool GPU_arb_base_instance_is_supported(void)
|
|
|
|
{
|
|
|
|
return GG.glew_arb_base_instance_is_supported;
|
|
|
|
}
|
|
|
|
|
2018-10-22 12:58:11 +02:00
|
|
|
bool GPU_mip_render_workaround(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.mip_render_workaround;
|
2018-10-22 12:58:11 +02:00
|
|
|
}
|
|
|
|
|
2018-10-25 21:57:40 +02:00
|
|
|
bool GPU_depth_blitting_workaround(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.depth_blitting_workaround;
|
2018-10-25 21:57:40 +02:00
|
|
|
}
|
|
|
|
|
2018-12-04 20:29:30 +01:00
|
|
|
bool GPU_unused_fb_slot_workaround(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return GG.unused_fb_slot_workaround;
|
2018-12-04 20:29:30 +01:00
|
|
|
}
|
|
|
|
|
2019-06-05 13:06:11 -03:00
|
|
|
bool GPU_context_local_shaders_workaround(void)
|
|
|
|
{
|
|
|
|
return GG.context_local_shaders_workaround;
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:18:57 -03:00
|
|
|
bool GPU_crappy_amd_driver(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Currently are the same drivers with the `unused_fb_slot` problem. */
|
2020-02-18 17:30:05 +01:00
|
|
|
return GG.broken_amd_driver;
|
2019-03-04 10:18:57 -03:00
|
|
|
}
|
|
|
|
|
2014-10-07 15:46:19 -05:00
|
|
|
void gpu_extensions_init(void)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* during 2.8 development each platform has its own OpenGL minimum requirements
|
|
|
|
* final 2.8 release will be unified on OpenGL 3.3 core profile, no required extensions
|
|
|
|
* see developer.blender.org/T49012 for details
|
|
|
|
*/
|
|
|
|
BLI_assert(GLEW_VERSION_3_3);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &GG.maxtexturesfrag);
|
|
|
|
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &GG.maxtexturesvert);
|
|
|
|
glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &GG.maxtexturesgeom);
|
|
|
|
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &GG.maxtextures);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
|
|
|
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &GG.maxtexlayers);
|
|
|
|
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &GG.maxcubemapsize);
|
2013-04-12 17:56:07 +00:00
|
|
|
|
2019-04-22 09:32:37 +10:00
|
|
|
if (GLEW_EXT_texture_filter_anisotropic) {
|
2019-04-17 06:17:24 +02:00
|
|
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GG.max_anisotropy);
|
2019-04-22 09:32:37 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
GG.max_anisotropy = 1.0f;
|
2019-04-22 09:32:37 +10:00
|
|
|
}
|
2016-01-07 11:21:08 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &GG.maxubobinds);
|
|
|
|
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GG.maxubosize);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, GG.line_width_range);
|
2018-11-02 14:58:49 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &GG.samples_color_texture_max);
|
2015-10-14 10:33:30 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
const char *vendor = (const char *)glGetString(GL_VENDOR);
|
|
|
|
const char *renderer = (const char *)glGetString(GL_RENDERER);
|
|
|
|
const char *version = (const char *)glGetString(GL_VERSION);
|
2010-01-31 23:45:51 +00:00
|
|
|
|
2019-10-03 16:21:23 +02:00
|
|
|
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_OFFICIAL)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (strstr(version, "4.5.13399") || strstr(version, "4.5.13417") ||
|
|
|
|
strstr(version, "4.5.13422")) {
|
|
|
|
/* The renderers include:
|
|
|
|
* Mobility Radeon HD 5000;
|
|
|
|
* Radeon HD 7500M;
|
|
|
|
* Radeon HD 7570M;
|
|
|
|
* Radeon HD 7600M;
|
|
|
|
* And many others... */
|
|
|
|
|
|
|
|
GG.unused_fb_slot_workaround = true;
|
2020-02-18 17:30:05 +01:00
|
|
|
GG.broken_amd_driver = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-10-03 16:21:23 +02:00
|
|
|
}
|
2018-12-04 20:29:30 +01:00
|
|
|
|
2019-10-03 16:21:23 +02:00
|
|
|
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (strstr(renderer, "AMD Radeon Pro") || strstr(renderer, "AMD Radeon R9") ||
|
|
|
|
strstr(renderer, "AMD Radeon RX")) {
|
|
|
|
GG.depth_blitting_workaround = true;
|
|
|
|
}
|
|
|
|
}
|
2013-02-26 00:49:42 +00:00
|
|
|
|
2019-07-31 16:35:06 -03:00
|
|
|
GG.glew_arb_base_instance_is_supported = GLEW_ARB_base_instance;
|
2019-04-17 06:17:24 +02:00
|
|
|
gpu_detect_mip_render_workaround();
|
|
|
|
|
|
|
|
if (G.debug & G_DEBUG_GPU_FORCE_WORKAROUNDS) {
|
|
|
|
printf("\n");
|
|
|
|
printf("GPU: Bypassing workaround detection.\n");
|
|
|
|
printf("GPU: OpenGL identification strings\n");
|
|
|
|
printf("GPU: vendor: %s\n", vendor);
|
|
|
|
printf("GPU: renderer: %s\n", renderer);
|
|
|
|
printf("GPU: version: %s\n\n", version);
|
|
|
|
GG.mip_render_workaround = true;
|
|
|
|
GG.depth_blitting_workaround = true;
|
|
|
|
GG.unused_fb_slot_workaround = true;
|
2019-09-30 12:11:35 -03:00
|
|
|
GG.context_local_shaders_workaround = GLEW_ARB_get_program_binary;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* df/dy calculation factors, those are dependent on driver */
|
2019-09-06 19:02:15 +02:00
|
|
|
GG.dfdyfactors[0] = 1.0;
|
|
|
|
GG.dfdyfactors[1] = 1.0;
|
|
|
|
|
2019-10-03 16:21:23 +02:00
|
|
|
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY) &&
|
|
|
|
strstr(version, "3.3.10750")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
GG.dfdyfactors[0] = 1.0;
|
|
|
|
GG.dfdyfactors[1] = -1.0;
|
|
|
|
}
|
2019-10-03 16:21:23 +02:00
|
|
|
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY)) {
|
2019-06-05 13:06:11 -03:00
|
|
|
if (strstr(version, "4.0.0 - Build 10.18.10.3308") ||
|
|
|
|
strstr(version, "4.0.0 - Build 9.18.10.3186") ||
|
|
|
|
strstr(version, "4.0.0 - Build 9.18.10.3165") ||
|
|
|
|
strstr(version, "3.1.0 - Build 9.17.10.3347") ||
|
|
|
|
strstr(version, "3.1.0 - Build 9.17.10.4101") ||
|
|
|
|
strstr(version, "3.3.0 - Build 8.15.10.2618")) {
|
|
|
|
GG.dfdyfactors[0] = -1.0;
|
|
|
|
GG.dfdyfactors[1] = 1.0;
|
|
|
|
}
|
|
|
|
|
2019-08-01 20:43:13 +02:00
|
|
|
if (strstr(version, "Build 10.18.10.3") || strstr(version, "Build 10.18.10.4") ||
|
2019-09-09 11:32:07 -03:00
|
|
|
strstr(version, "Build 10.18.10.5") || strstr(version, "Build 10.18.14.4") ||
|
|
|
|
strstr(version, "Build 10.18.14.5")) {
|
2019-07-31 16:35:06 -03:00
|
|
|
/* Maybe not all of these drivers have problems with `GLEW_ARB_base_instance`.
|
|
|
|
* But it's hard to test each case. */
|
|
|
|
GG.glew_arb_base_instance_is_supported = false;
|
2019-06-05 13:06:11 -03:00
|
|
|
GG.context_local_shaders_workaround = true;
|
|
|
|
}
|
2019-09-24 08:46:33 -03:00
|
|
|
|
|
|
|
if (strstr(version, "Build 20.19.15.4285")) {
|
|
|
|
/* Somehow fixes armature display issues (see T69743). */
|
|
|
|
GG.context_local_shaders_workaround = true;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-02-18 17:30:05 +01:00
|
|
|
else if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) &&
|
|
|
|
(strstr(version, "Mesa 18.") || strstr(version, "Mesa 19.0") ||
|
|
|
|
strstr(version, "Mesa 19.1") || strstr(version, "Mesa 19.2"))) {
|
2019-09-25 15:54:55 +02:00
|
|
|
/* See T70187: merging vertices fail. This has been tested from 18.2.2 till 19.3.0~dev of the
|
|
|
|
* Mesa driver */
|
|
|
|
GG.unused_fb_slot_workaround = true;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
GPU_invalid_tex_init();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 15:46:19 -05:00
|
|
|
void gpu_extensions_exit(void)
|
2011-12-23 07:10:01 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
GPU_invalid_tex_free();
|
2011-12-23 07:10:01 +00:00
|
|
|
}
|
2015-12-06 18:00:22 -05:00
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
bool GPU_mem_stats_supported(void)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return (GLEW_NVX_gpu_memory_info || GLEW_ATI_meminfo) && (G.debug & G_DEBUG_GPU_MEM);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
void GPU_mem_stats_get(int *totalmem, int *freemem)
|
2015-02-12 18:54:41 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* TODO(merwin): use Apple's platform API to get this info */
|
|
|
|
|
|
|
|
if (GLEW_NVX_gpu_memory_info) {
|
|
|
|
/* returned value in Kb */
|
|
|
|
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, totalmem);
|
|
|
|
|
|
|
|
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, freemem);
|
|
|
|
}
|
|
|
|
else if (GLEW_ATI_meminfo) {
|
|
|
|
int stats[4];
|
|
|
|
|
|
|
|
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, stats);
|
|
|
|
*freemem = stats[0];
|
|
|
|
*totalmem = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*totalmem = 0;
|
|
|
|
*freemem = 0;
|
|
|
|
}
|
2015-04-24 14:11:05 +02:00
|
|
|
}
|