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:53:48 +02:00
|
|
|
#include "gpu_context_private.hh"
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-07 19:53:48 +02:00
|
|
|
#include "gpu_capabilities_private.hh"
|
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
|
|
|
}
|
|
|
|
|
2021-02-08 15:42:59 +01:00
|
|
|
int GPU_texture_size_with_limit(int res, bool limit_gl_texture_size)
|
2020-09-04 02:36:56 +02:00
|
|
|
{
|
2020-09-07 18:52:30 +02:00
|
|
|
int size = GPU_max_texture_size();
|
2021-02-08 15:42:59 +01:00
|
|
|
int reslimit = (limit_gl_texture_size && (U.glreslimit != 0)) ? min_ii(U.glreslimit, size) :
|
|
|
|
size;
|
2020-09-07 18:52:30 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-05-14 11:15:00 -03:00
|
|
|
int GPU_max_uniforms_vert(void)
|
|
|
|
{
|
|
|
|
return GCaps.max_uniforms_vert;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_uniforms_frag(void)
|
|
|
|
{
|
|
|
|
return GCaps.max_uniforms_frag;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_batch_indices(void)
|
|
|
|
{
|
|
|
|
return GCaps.max_batch_indices;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_batch_vertices(void)
|
|
|
|
{
|
|
|
|
return GCaps.max_batch_vertices;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_vertex_attribs(void)
|
|
|
|
{
|
|
|
|
return GCaps.max_vertex_attribs;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_max_varying_floats(void)
|
|
|
|
{
|
|
|
|
return GCaps.max_varying_floats;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_extensions_len(void)
|
|
|
|
{
|
|
|
|
return GCaps.extensions_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *GPU_extension_get(int i)
|
|
|
|
{
|
|
|
|
return GCaps.extension_get ? GCaps.extension_get(i) : "\0";
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2021-01-04 11:41:54 +01:00
|
|
|
bool GPU_use_hq_normals_workaround(void)
|
|
|
|
{
|
|
|
|
return GCaps.use_hq_normals_workaround;
|
|
|
|
}
|
|
|
|
|
2020-09-12 06:10:11 +02:00
|
|
|
bool GPU_shader_image_load_store_support(void)
|
|
|
|
{
|
|
|
|
return GCaps.shader_image_load_store_support;
|
|
|
|
}
|
|
|
|
|
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-09-07 19:53:48 +02:00
|
|
|
return GCaps.mem_stats_support;
|
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
|
|
|
{
|
2020-09-08 04:12:12 +02:00
|
|
|
Context::get()->memory_statistics_get(totalmem, freemem);
|
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-08 04:12:12 +02:00
|
|
|
return Context::get()->front_right != nullptr;
|
2020-07-16 03:01:07 +02:00
|
|
|
}
|
2020-09-07 18:52:30 +02:00
|
|
|
|
|
|
|
/** \} */
|