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
|
|
|
*/
|
|
|
|
|
2020-07-29 18:13:19 +02:00
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
2020-09-07 19:35:56 +02:00
|
|
|
#include "GPU_capabilities.h"
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-07 19:35:56 +02:00
|
|
|
#include "gpu_capabilities_private.hh"
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
#include "gl_backend.hh" /* TODO remove */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
namespace blender::gpu {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
GPUCapabilities GCaps;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-22 12:58:11 +02:00
|
|
|
}
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
using namespace blender::gpu;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Capabilities
|
|
|
|
* \{ */
|
2010-01-31 23:45:51 +00:00
|
|
|
|
2013-04-13 00:43:49 +00:00
|
|
|
int GPU_max_texture_size(void)
|
2013-04-12 17:56:07 +00:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.max_texture_size;
|
2013-04-12 17:56:07 +00:00
|
|
|
}
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
int GPU_texture_size_with_limit(int res)
|
2020-09-04 02:36:56 +02:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
int size = GPU_max_texture_size();
|
|
|
|
int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, size) : size;
|
|
|
|
return min_ii(reslimit, res);
|
2020-09-04 02:36:56 +02:00
|
|
|
}
|
|
|
|
|
2018-07-27 13:56:07 +02:00
|
|
|
int GPU_max_texture_layers(void)
|
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.max_texture_layers;
|
2018-09-18 14:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_textures_vert(void)
|
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.max_textures_vert;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
int GPU_max_textures_geom(void)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.max_textures_geom;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
int GPU_max_textures_frag(void)
|
2015-03-30 14:14:32 +02:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.max_textures_frag;
|
2015-03-30 14:14:32 +02:00
|
|
|
}
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
int GPU_max_textures(void)
|
2019-07-31 16:35:06 -03:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.max_textures;
|
2019-07-31 16:35:06 -03:00
|
|
|
}
|
|
|
|
|
2018-10-22 12:58:11 +02:00
|
|
|
bool GPU_mip_render_workaround(void)
|
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.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)
|
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.depth_blitting_workaround;
|
2018-12-04 20:29:30 +01:00
|
|
|
}
|
|
|
|
|
2020-08-05 15:26:49 +02:00
|
|
|
bool GPU_use_main_context_workaround(void)
|
2019-06-05 13:06:11 -03:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
return GCaps.use_main_context_workaround;
|
2020-06-08 12:03:11 +02:00
|
|
|
}
|
|
|
|
|
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-09-07 18:52:30 +02:00
|
|
|
return GCaps.broken_amd_driver;
|
2020-07-29 18:13:19 +02:00
|
|
|
}
|
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
/** \} */
|
2013-04-12 17:56:07 +00:00
|
|
|
|
2020-09-07 18:52:30 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Memory statistics
|
|
|
|
* \{ */
|
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
|
|
|
{
|
2020-03-11 14:52:57 +11:00
|
|
|
#ifndef GPU_STANDALONE
|
2020-07-18 07:49:25 -07:00
|
|
|
return (GLEW_NVX_gpu_memory_info || GLEW_ATI_meminfo);
|
2020-03-11 14:52:57 +11:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
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
|
|
|
}
|
2020-07-16 03:01:07 +02:00
|
|
|
|
|
|
|
/* Return support for the active context + window. */
|
|
|
|
bool GPU_stereo_quadbuffer_support(void)
|
|
|
|
{
|
2020-09-07 19:52:22 +02:00
|
|
|
return GPU_context_active_get()->front_right != nullptr;
|
2020-07-16 03:01:07 +02:00
|
|
|
}
|
2020-09-07 18:52:30 +02:00
|
|
|
|
|
|
|
/** \} */
|