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"
|
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 {
|
2013-04-12 17:56:07 +00:00
|
|
|
GLint maxtexsize;
|
2018-07-27 13:56:07 +02:00
|
|
|
GLint maxtexlayers;
|
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
|
|
|
GLint maxcubemapsize;
|
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
|
|
|
GLint maxtextures;
|
2018-09-18 14:22:42 +02:00
|
|
|
GLint maxtexturesfrag;
|
|
|
|
GLint maxtexturesgeom;
|
|
|
|
GLint maxtexturesvert;
|
2017-02-07 11:20:15 +01:00
|
|
|
GLint maxubosize;
|
|
|
|
GLint maxubobinds;
|
2010-07-04 12:24:19 +00:00
|
|
|
int colordepth;
|
2015-10-14 10:33:30 +11:00
|
|
|
int samples_color_texture_max;
|
2019-01-23 14:15:43 +11:00
|
|
|
eGPUDeviceType device;
|
|
|
|
eGPUOSType os;
|
|
|
|
eGPUDriverType driver;
|
2018-11-02 14:58:49 +01:00
|
|
|
float line_width_range[2];
|
2016-07-15 02:36:21 +10:00
|
|
|
/* 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];
|
2016-01-07 11:21:08 -05:00
|
|
|
float max_anisotropy;
|
2018-10-22 12:58:11 +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;
|
2018-10-25 21:57:40 +02:00
|
|
|
/* 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;
|
2018-12-04 20:29:30 +01:00
|
|
|
/* 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;
|
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)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-01-31 23:45:51 +00:00
|
|
|
/* GPU Types */
|
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver)
|
2010-01-31 23:45:51 +00:00
|
|
|
{
|
|
|
|
return (GG.device & device) && (GG.os & os) && (GG.driver & driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GPU Extensions */
|
|
|
|
|
2013-04-13 00:43:49 +00:00
|
|
|
int GPU_max_texture_size(void)
|
2013-04-12 17:56:07 +00:00
|
|
|
{
|
|
|
|
return GG.maxtexsize;
|
|
|
|
}
|
|
|
|
|
2018-07-27 13:56:07 +02:00
|
|
|
int GPU_max_texture_layers(void)
|
|
|
|
{
|
|
|
|
return GG.maxtexlayers;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
int GPU_max_textures(void)
|
|
|
|
{
|
|
|
|
return GG.maxtextures;
|
|
|
|
}
|
|
|
|
|
2018-09-18 14:22:42 +02:00
|
|
|
int GPU_max_textures_frag(void)
|
|
|
|
{
|
|
|
|
return GG.maxtexturesfrag;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_textures_geom(void)
|
|
|
|
{
|
|
|
|
return GG.maxtexturesgeom;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_textures_vert(void)
|
|
|
|
{
|
|
|
|
return GG.maxtexturesvert;
|
|
|
|
}
|
|
|
|
|
2016-01-07 11:21:08 -05:00
|
|
|
float GPU_max_texture_anisotropy(void)
|
|
|
|
{
|
|
|
|
return GG.max_anisotropy;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
int GPU_max_color_texture_samples(void)
|
|
|
|
{
|
|
|
|
return GG.samples_color_texture_max;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return GG.maxcubemapsize;
|
|
|
|
}
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
int GPU_max_ubo_binds(void)
|
|
|
|
{
|
|
|
|
return GG.maxubobinds;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_ubo_size(void)
|
|
|
|
{
|
|
|
|
return GG.maxubosize;
|
|
|
|
}
|
|
|
|
|
2018-11-02 14:58:49 +01:00
|
|
|
float GPU_max_line_width(void)
|
|
|
|
{
|
|
|
|
return GG.line_width_range[1];
|
|
|
|
}
|
|
|
|
|
2015-03-30 14:14:32 +02:00
|
|
|
void GPU_get_dfdy_factors(float fac[2])
|
|
|
|
{
|
|
|
|
copy_v2_v2(fac, GG.dfdyfactors);
|
|
|
|
}
|
|
|
|
|
2018-10-22 12:58:11 +02:00
|
|
|
bool GPU_mip_render_workaround(void)
|
|
|
|
{
|
|
|
|
return GG.mip_render_workaround;
|
|
|
|
}
|
|
|
|
|
2018-10-25 21:57:40 +02:00
|
|
|
bool GPU_depth_blitting_workaround(void)
|
|
|
|
{
|
|
|
|
return GG.depth_blitting_workaround;
|
|
|
|
}
|
|
|
|
|
2018-12-04 20:29:30 +01:00
|
|
|
bool GPU_unused_fb_slot_workaround(void)
|
|
|
|
{
|
|
|
|
return GG.unused_fb_slot_workaround;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2016-09-30 19:10:30 -04:00
|
|
|
/* during 2.8 development each platform has its own OpenGL minimum requirements
|
2016-10-16 03:18:17 -04:00
|
|
|
* final 2.8 release will be unified on OpenGL 3.3 core profile, no required extensions
|
2016-09-30 19:10:30 -04:00
|
|
|
* see developer.blender.org/T49012 for details
|
|
|
|
*/
|
2016-10-16 03:18:17 -04:00
|
|
|
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
|
|
|
|
2018-09-18 14:22:42 +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
|
|
|
|
2013-04-12 17:56:07 +00:00
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
|
2018-07-27 13:56:07 +02:00
|
|
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &GG.maxtexlayers);
|
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
|
|
|
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &GG.maxcubemapsize);
|
2013-04-12 17:56:07 +00:00
|
|
|
|
2016-01-07 11:21:08 -05:00
|
|
|
if (GLEW_EXT_texture_filter_anisotropic)
|
|
|
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GG.max_anisotropy);
|
|
|
|
else
|
|
|
|
GG.max_anisotropy = 1.0f;
|
|
|
|
|
2018-03-09 23:50:30 +01:00
|
|
|
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &GG.maxubobinds);
|
2017-02-07 11:20:15 +01:00
|
|
|
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GG.maxubosize);
|
|
|
|
|
2018-11-02 14:58:49 +01:00
|
|
|
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, GG.line_width_range);
|
|
|
|
|
2017-05-19 14:10:10 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
GLint ret;
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &ret);
|
|
|
|
/* We expect FRONT_LEFT to be the default buffer. */
|
2017-05-19 14:39:27 +02:00
|
|
|
BLI_assert(ret == GL_FRAMEBUFFER_DEFAULT);
|
2017-05-19 14:10:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
GLint r, g, b;
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &r);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, &g);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, &b);
|
|
|
|
GG.colordepth = r + g + b; /* Assumes same depth for RGB. */
|
2011-04-21 13:11:51 +00:00
|
|
|
|
2018-09-18 14:22:42 +02:00
|
|
|
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &GG.samples_color_texture_max);
|
2015-10-14 10:33:30 +11:00
|
|
|
|
2015-11-25 11:49:46 -05: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
|
|
|
|
2018-06-04 15:14:52 +02:00
|
|
|
if (strstr(vendor, "ATI") || strstr(vendor, "AMD")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_ATI;
|
|
|
|
GG.driver = GPU_DRIVER_OFFICIAL;
|
2018-10-25 21:57:40 +02:00
|
|
|
|
2018-12-04 20:29:30 +01:00
|
|
|
#ifdef _WIN32
|
2018-12-05 21:22:12 -02:00
|
|
|
if (strstr(version, "4.5.13399") ||
|
2018-12-25 14:36:22 -02:00
|
|
|
strstr(version, "4.5.13417") ||
|
|
|
|
strstr(version, "4.5.13422"))
|
2018-12-04 20:29:30 +01:00
|
|
|
{
|
2018-12-06 10:05:42 -02:00
|
|
|
/* The renderers include:
|
|
|
|
* Mobility Radeon HD 5000;
|
|
|
|
* Radeon HD 7500M;
|
|
|
|
* Radeon HD 7570M;
|
|
|
|
* Radeon HD 7600M;
|
|
|
|
* And many others... */
|
|
|
|
|
2018-12-04 20:29:30 +01:00
|
|
|
GG.unused_fb_slot_workaround = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-10-25 21:57:40 +02:00
|
|
|
#if defined(__APPLE__)
|
2018-11-28 13:19:04 +01:00
|
|
|
if (strstr(renderer, "AMD Radeon Pro") ||
|
|
|
|
strstr(renderer, "AMD Radeon R9") ||
|
|
|
|
strstr(renderer, "AMD Radeon RX"))
|
|
|
|
{
|
2018-10-25 21:57:40 +02:00
|
|
|
GG.depth_blitting_workaround = true;
|
|
|
|
}
|
|
|
|
#endif
|
2010-01-31 23:45:51 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(vendor, "NVIDIA")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_NVIDIA;
|
|
|
|
GG.driver = GPU_DRIVER_OFFICIAL;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(vendor, "Intel") ||
|
2016-01-10 07:12:10 +11:00
|
|
|
/* src/mesa/drivers/dri/intel/intel_context.c */
|
|
|
|
strstr(renderer, "Mesa DRI Intel") ||
|
|
|
|
strstr(renderer, "Mesa DRI Mobile Intel"))
|
|
|
|
{
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_INTEL;
|
|
|
|
GG.driver = GPU_DRIVER_OFFICIAL;
|
2018-12-02 01:57:22 +01:00
|
|
|
|
2018-12-05 04:22:32 +01:00
|
|
|
if (strstr(renderer, "UHD Graphics") ||
|
2018-12-17 08:56:38 +01:00
|
|
|
/* Not UHD but affected by the same bugs. */
|
|
|
|
strstr(renderer, "HD Graphics 530") ||
|
2018-12-05 04:22:32 +01:00
|
|
|
strstr(renderer, "Kaby Lake GT2"))
|
|
|
|
{
|
2018-12-02 01:57:22 +01:00
|
|
|
GG.device |= GPU_DEVICE_INTEL_UHD;
|
|
|
|
}
|
2010-01-31 23:45:51 +00:00
|
|
|
}
|
2016-11-22 11:38:27 +01:00
|
|
|
else if ((strstr(renderer, "Mesa DRI R")) ||
|
2018-06-04 15:14:52 +02:00
|
|
|
(strstr(renderer, "Radeon") && strstr(vendor, "X.Org")) ||
|
2016-11-22 11:38:27 +01:00
|
|
|
(strstr(renderer, "Gallium ") && strstr(renderer, " on ATI ")) ||
|
|
|
|
(strstr(renderer, "Gallium ") && strstr(renderer, " on AMD ")))
|
|
|
|
{
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_ATI;
|
|
|
|
GG.driver = GPU_DRIVER_OPENSOURCE;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(renderer, "Nouveau") || strstr(vendor, "nouveau")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_NVIDIA;
|
|
|
|
GG.driver = GPU_DRIVER_OPENSOURCE;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(vendor, "Mesa")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_SOFTWARE;
|
|
|
|
GG.driver = GPU_DRIVER_SOFTWARE;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(vendor, "Microsoft")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_SOFTWARE;
|
|
|
|
GG.driver = GPU_DRIVER_SOFTWARE;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(renderer, "Apple Software Renderer")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_SOFTWARE;
|
|
|
|
GG.driver = GPU_DRIVER_SOFTWARE;
|
|
|
|
}
|
2019-01-04 12:41:35 +01:00
|
|
|
else if (strstr(renderer, "llvmpipe")) {
|
|
|
|
GG.device = GPU_DEVICE_SOFTWARE;
|
|
|
|
GG.driver = GPU_DRIVER_SOFTWARE;
|
|
|
|
}
|
2010-01-31 23:45:51 +00:00
|
|
|
else {
|
2018-06-04 15:14:52 +02:00
|
|
|
printf("Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
|
2019-01-04 12:50:05 +01:00
|
|
|
printf("Detected OpenGL configuration:\n");
|
|
|
|
printf("Vendor: %s\n", vendor);
|
|
|
|
printf("Renderer: %s\n", renderer);
|
2010-07-16 10:13:04 +00:00
|
|
|
GG.device = GPU_DEVICE_ANY;
|
|
|
|
GG.driver = GPU_DRIVER_ANY;
|
2010-01-31 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
GG.os = GPU_OS_WIN;
|
2012-03-08 04:38:35 +00:00
|
|
|
#elif defined(__APPLE__)
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.os = GPU_OS_MAC;
|
2012-03-08 04:38:35 +00:00
|
|
|
#else
|
|
|
|
GG.os = GPU_OS_UNIX;
|
2010-01-31 23:45:51 +00:00
|
|
|
#endif
|
2013-02-26 00:49:42 +00:00
|
|
|
|
2018-10-22 12:58:11 +02:00
|
|
|
gpu_detect_mip_render_workaround();
|
2014-06-10 01:36:53 +03:00
|
|
|
|
2018-12-05 03:05:39 +01:00
|
|
|
if (G.debug & G_DEBUG_GPU_FORCE_WORKAROUNDS) {
|
2018-12-05 04:03:40 +01:00
|
|
|
printf("\n");
|
|
|
|
printf("GPU: Bypassing workaround detection.\n");
|
2019-01-04 12:51:10 +01:00
|
|
|
printf("GPU: OpenGL identification strings\n");
|
2018-12-05 04:03:40 +01:00
|
|
|
printf("GPU: vendor: %s\n", vendor);
|
|
|
|
printf("GPU: renderer: %s\n", renderer);
|
|
|
|
printf("GPU: version: %s\n\n", version);
|
2018-12-05 03:05:39 +01:00
|
|
|
GG.mip_render_workaround = true;
|
|
|
|
GG.depth_blitting_workaround = true;
|
|
|
|
GG.unused_fb_slot_workaround = true;
|
|
|
|
}
|
|
|
|
|
2015-03-30 14:14:32 +02:00
|
|
|
/* df/dy calculation factors, those are dependent on driver */
|
|
|
|
if ((strstr(vendor, "ATI") && strstr(version, "3.3.10750"))) {
|
|
|
|
GG.dfdyfactors[0] = 1.0;
|
|
|
|
GG.dfdyfactors[1] = -1.0;
|
|
|
|
}
|
2016-01-10 07:12:10 +11:00
|
|
|
else if ((GG.device == GPU_DEVICE_INTEL) && (GG.os == GPU_OS_WIN) &&
|
|
|
|
(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")))
|
2015-05-18 22:05:38 +02:00
|
|
|
{
|
|
|
|
GG.dfdyfactors[0] = -1.0;
|
|
|
|
GG.dfdyfactors[1] = 1.0;
|
2015-03-30 14:14:32 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
GG.dfdyfactors[0] = 1.0;
|
|
|
|
GG.dfdyfactors[1] = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-10 01:36:53 +03: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
|
|
|
{
|
2014-06-10 01:36:53 +03:00
|
|
|
GPU_invalid_tex_free();
|
2011-12-23 07:10:01 +00:00
|
|
|
}
|
2015-12-06 18:00:22 -05:00
|
|
|
|
2011-02-13 15:02:21 +00:00
|
|
|
int GPU_color_depth(void)
|
2010-04-05 10:25:40 +00:00
|
|
|
{
|
2011-04-21 13:11:51 +00:00
|
|
|
return GG.colordepth;
|
2010-04-05 10:25:40 +00: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
|
|
|
{
|
2017-04-15 19:43:56 -04: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
|
|
|
{
|
2017-04-15 19:43:56 -04:00
|
|
|
/* TODO(merwin): use Apple's platform API to get this info */
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
if (GLEW_NVX_gpu_memory_info) {
|
|
|
|
/* returned value in Kb */
|
|
|
|
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, totalmem);
|
2015-03-03 17:47:31 +01:00
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, freemem);
|
2015-03-03 17:47:31 +01:00
|
|
|
}
|
2015-12-06 21:20:19 +01:00
|
|
|
else if (GLEW_ATI_meminfo) {
|
|
|
|
int stats[4];
|
2015-02-12 18:54:41 +01:00
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, stats);
|
|
|
|
*freemem = stats[0];
|
|
|
|
*totalmem = 0;
|
2015-04-24 14:11:05 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
*totalmem = 0;
|
|
|
|
*freemem = 0;
|
|
|
|
}
|
|
|
|
}
|