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
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Brecht Van Lommel.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:25:53 +00:00
|
|
|
/** \file blender/gpu/intern/gpu_extensions.c
|
|
|
|
* \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
|
|
|
*/
|
|
|
|
|
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 "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
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"
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_basic_shader.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 "GPU_draw.h"
|
|
|
|
#include "GPU_extensions.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
|
|
|
|
* ARB_framebuffer object: 3.0
|
2015-12-08 02:14:09 -05:00
|
|
|
* EXT_framebuffer_object: 3.0
|
2015-11-22 13:22:47 -05:00
|
|
|
* EXT_framebuffer_blit: 3.0
|
2015-12-08 02:14:09 -05:00
|
|
|
* EXT_framebuffer_multisample: 3.0
|
2015-11-22 13:22:47 -05:00
|
|
|
* EXT_framebuffer_multisample_blit_scaled: ???
|
|
|
|
* ARB_draw_instanced: 3.1
|
|
|
|
* ARB_texture_multisample: 3.2
|
|
|
|
* EXT_geometry_shader4: 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;
|
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;
|
2015-11-25 11:49:46 -05:00
|
|
|
bool extdisabled;
|
2010-07-04 12:24:19 +00:00
|
|
|
int colordepth;
|
2015-10-14 10:33:30 +11:00
|
|
|
int samples_color_texture_max;
|
2010-01-31 23:45:51 +00:00
|
|
|
GPUDeviceType device;
|
|
|
|
GPUOSType os;
|
|
|
|
GPUDriverType driver;
|
2015-03-30 14:14:32 +02:00
|
|
|
float dfdyfactors[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 */
|
2016-01-07 11:21:08 -05:00
|
|
|
float max_anisotropy;
|
2012-05-01 02:50:17 +00:00
|
|
|
} GG = {1, 0};
|
2008-10-12 18:32:26 +00:00
|
|
|
|
2010-01-31 23:45:51 +00:00
|
|
|
/* GPU Types */
|
|
|
|
|
2015-03-16 22:57:56 -04:00
|
|
|
bool GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
|
2010-01-31 23:45:51 +00:00
|
|
|
{
|
|
|
|
return (GG.device & device) && (GG.os & os) && (GG.driver & driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GPU Extensions */
|
|
|
|
|
2011-02-13 15:02:21 +00:00
|
|
|
void GPU_extensions_disable(void)
|
2008-10-12 18:32:26 +00:00
|
|
|
{
|
2015-11-25 11:49:46 -05:00
|
|
|
GG.extdisabled = true;
|
2008-10-12 18:32:26 +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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
int GPU_max_textures(void)
|
|
|
|
{
|
|
|
|
return GG.maxtextures;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-30 14:14:32 +02:00
|
|
|
void GPU_get_dfdy_factors(float fac[2])
|
|
|
|
{
|
|
|
|
copy_v2_v2(fac, GG.dfdyfactors);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-11-22 13:22:47 -05:00
|
|
|
/* BLI_assert(GLEW_VERSION_2_1); */
|
|
|
|
/* ^-- maybe a bit extreme? */
|
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-11-22 13:22:47 -05:00
|
|
|
glGetIntegerv(GL_MAX_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);
|
|
|
|
|
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;
|
|
|
|
|
2015-11-25 11:49:46 -05:00
|
|
|
GLint r, g, b;
|
2010-07-04 12:24:19 +00:00
|
|
|
glGetIntegerv(GL_RED_BITS, &r);
|
|
|
|
glGetIntegerv(GL_GREEN_BITS, &g);
|
|
|
|
glGetIntegerv(GL_BLUE_BITS, &b);
|
2015-03-23 15:29:42 -04:00
|
|
|
GG.colordepth = r + g + b; /* assumes same depth for RGB */
|
2011-04-21 13:11:51 +00:00
|
|
|
|
2015-11-22 13:22:47 -05:00
|
|
|
if (GLEW_VERSION_3_2 || GLEW_ARB_texture_multisample) {
|
2016-01-10 07:12:10 +11: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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (strstr(vendor, "ATI")) {
|
2010-01-31 23:45:51 +00:00
|
|
|
GG.device = GPU_DEVICE_ATI;
|
|
|
|
GG.driver = GPU_DRIVER_OFFICIAL;
|
|
|
|
}
|
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;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (strstr(renderer, "Mesa DRI R") || (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI "))) {
|
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;
|
|
|
|
}
|
|
|
|
else {
|
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
|
|
|
}
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* make sure double side isn't used by default and only getting enabled in places where it's
|
2012-02-25 18:09:39 +00:00
|
|
|
* really needed to prevent different unexpected behaviors like with intel gme965 card (sergey) */
|
2012-02-25 21:27:45 +00:00
|
|
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
2012-02-25 18:09:39 +00:00
|
|
|
|
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
|
|
|
|
2014-06-10 01:36:53 +03:00
|
|
|
|
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();
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shaders_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
|
|
|
{
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shaders_exit();
|
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
|
|
|
bool GPU_legacy_support(void)
|
|
|
|
{
|
2016-01-04 01:03:47 -05:00
|
|
|
/* return whether or not current GL context is compatible with legacy OpenGL */
|
|
|
|
static bool checked = false;
|
|
|
|
static bool support = true;
|
2015-12-06 18:00:22 -05:00
|
|
|
|
2016-01-04 01:03:47 -05:00
|
|
|
if (!checked) {
|
|
|
|
if (GLEW_VERSION_3_2) {
|
|
|
|
GLint profile;
|
2015-12-06 18:00:22 -05:00
|
|
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
|
2016-01-04 01:03:47 -05:00
|
|
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
|
|
|
printf("GL_CONTEXT_PROFILE_MASK = %#x (%s profile)\n", profile,
|
|
|
|
profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT ? "compatibility" :
|
|
|
|
profile & GL_CONTEXT_CORE_PROFILE_BIT ? "core" : "unknown");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (profile == 0) {
|
|
|
|
/* workaround for nVidia's Linux driver */
|
|
|
|
support = GLEW_ARB_compatibility;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
support = profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GLEW_VERSION_3_1) {
|
|
|
|
support = GLEW_ARB_compatibility;
|
2015-12-06 18:00:22 -05:00
|
|
|
}
|
|
|
|
|
2016-01-04 01:03:47 -05:00
|
|
|
/* any OpenGL version <= 3.0 is legacy, so support remains true */
|
|
|
|
|
|
|
|
checked = true;
|
2015-12-06 18:00:22 -05:00
|
|
|
}
|
2016-01-04 01:03:47 -05:00
|
|
|
|
|
|
|
return support;
|
2015-12-06 18:00:22 -05:00
|
|
|
}
|
|
|
|
|
2015-03-16 22:57:56 -04:00
|
|
|
bool GPU_glsl_support(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
|
|
|
{
|
2015-11-25 11:49:46 -05:00
|
|
|
/* always supported, still queried by game engine */
|
|
|
|
return true;
|
2009-10-19 10:10:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:41:21 +01:00
|
|
|
bool GPU_full_non_power_of_two_support(void)
|
2009-10-19 10:10:05 +00:00
|
|
|
{
|
2015-12-06 21:41:21 +01:00
|
|
|
/* always supported on full GL but still relevant for OpenGL ES 2.0 where
|
|
|
|
* NPOT textures can't use mipmaps or repeat wrap mode */
|
2015-11-25 11:49:46 -05:00
|
|
|
return true;
|
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-03-16 22:57:56 -04:00
|
|
|
bool GPU_display_list_support(void)
|
2013-09-11 23:24:45 +00:00
|
|
|
{
|
2015-11-25 11:49:46 -05:00
|
|
|
/* deprecated in GL 3
|
|
|
|
* supported on older GL and compatibility profile
|
|
|
|
* still queried by game engine
|
|
|
|
*/
|
|
|
|
return true;
|
2013-09-11 23:24:45 +00:00
|
|
|
}
|
|
|
|
|
2015-03-16 22:57:56 -04:00
|
|
|
bool GPU_bicubic_bump_support(void)
|
|
|
|
{
|
2015-11-22 13:22:47 -05:00
|
|
|
return GLEW_VERSION_4_0 || (GLEW_ARB_texture_query_lod && GLEW_VERSION_3_0);
|
2015-03-16 22:57:56 -04:00
|
|
|
}
|
|
|
|
|
2015-03-03 17:47:31 +01:00
|
|
|
bool GPU_geometry_shader_support(void)
|
|
|
|
{
|
2015-11-22 20:40:54 -05:00
|
|
|
/* in GL 3.2 geometry shaders are fully supported
|
|
|
|
* core profile clashes with our other shaders so accept compatibility only
|
|
|
|
* other GL versions can use EXT_geometry_shader4 if available
|
|
|
|
*/
|
2015-12-06 18:00:22 -05:00
|
|
|
return (GLEW_VERSION_3_2 && GPU_legacy_support()) || GLEW_EXT_geometry_shader4;
|
2015-11-22 13:22:47 -05:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
bool GPU_geometry_shader_support_via_extension(void)
|
2015-11-22 13:22:47 -05:00
|
|
|
{
|
2015-12-06 18:00:22 -05:00
|
|
|
return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GPU_legacy_support());
|
2015-03-03 17:47:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GPU_instanced_drawing_support(void)
|
|
|
|
{
|
2015-11-22 13:22:47 -05:00
|
|
|
return GLEW_VERSION_3_1 || GLEW_ARB_draw_instanced;
|
2015-03-03 17:47:31 +01: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
|
|
|
{
|
2015-12-06 21:20:19 +01: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
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|