Skip to content

Commit

Permalink
UPBGE: Remove display list and vertex array render storage.
Browse files Browse the repository at this point in the history
This render storage was using very old features which are deprecated since
plentiful versions.

The remove of these wasn't made previously in UPBGE and BFBGE because they was
still faster than new VBO. But in UPBGE some efforts was made to optimize
VBO and let VBO render faster than VA. This inversion was possible thanks to
VAO and bind less VBO.

It's now time to say good bye to vertex array and display list.

With the remove of VA storage, custom storage in UI are useless same as
RAS_IStorage in sources, they had removed so.
The previous fix for font objects which tryed to bind its display array is fixed
by simply forbid create a display array if the mesh and mesh material is to NULL,
which is the case only for font objects.
  • Loading branch information
panzergame committed Nov 6, 2016
1 parent 996ab30 commit b286d18
Show file tree
Hide file tree
Showing 31 changed files with 78 additions and 727 deletions.
29 changes: 10 additions & 19 deletions release/scripts/startup/bl_ui/properties_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,30 +404,21 @@ def draw(self, context):
layout = self.layout

gs = context.scene.game_settings
col = layout.column()
row = col.row()
col = row.column()
split = layout.split(percentage=0.4)

col = split.column()
col.prop(gs, "use_frame_rate")
col.prop(gs, "use_restrict_animation_updates")
col = row.column()
col.prop(gs, "use_display_lists")
col.active = gs.raster_storage != 'VERTEX_BUFFER_OBJECT'

row = layout.row()
row.prop(gs, "vsync")

row = layout.row()
row.prop(gs, "raster_storage")

row = layout.row()
row.prop(gs, "samples")

row = layout.row()
row.prop(gs, "hdr")
col = split.column()
col.prop(gs, "vsync")
col.prop(gs, "samples")
col.prop(gs, "hdr")

row = layout.row()
row.label("Exit Key")
row.prop(gs, "exit_key", text="", event=True)
col = row.column()
col.label("Exit Key:")
col.prop(gs, "exit_key", text="", event=True)


class RENDER_PT_game_display(RenderButtonsPanel, Panel):
Expand Down
11 changes: 1 addition & 10 deletions release/scripts/startup/bl_ui/properties_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def draw(self, context):
col.prop(game, "face_orientation", text="")
col.label(text="Alpha Blend:")
col.prop(game, "alpha_blend", text="")

col = split.column()
col.label(text="Constant Values:")
col.prop(mat, "use_constant_material")
Expand All @@ -683,15 +683,6 @@ def draw(self, context):
col.prop(mat, "use_constant_world")
col.prop(mat, "use_constant_mist")

col = layout.column()
col.label(text="Storage:")

row = col.row()
row.prop(game, "storage", text="")
col = row.column()
col.active = game.storage not in ("VERTEX_BUFFER_OBJECT", "SCENE")
col.prop(game, "use_display_lists")

class MATERIAL_PT_strand(MaterialButtonsPanel, Panel):
bl_label = "Strand"
bl_options = {'DEFAULT_CLOSED'}
Expand Down
2 changes: 0 additions & 2 deletions source/blender/blenkernel/intern/material.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ void BKE_material_init(Material *ma)
ma->game.flag = GEMAT_BACKCULL;
ma->game.alpha_blend = 0;
ma->game.face_orientation = 0;
ma->game.storage = GAME_STORAGE_SCENE;
ma->game.storage_flag = 0;

ma->depthtranspfactor = 1.0f;

Expand Down
3 changes: 0 additions & 3 deletions source/blender/blenkernel/intern/scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,6 @@ void BKE_scene_init(Scene *sce)
sce->gm.angulardeactthreshold = 1.0f;
sce->gm.deactivationtime = 0.0f;

sce->gm.raster_storage = GAME_STORAGE_VA;
sce->gm.flag = GAME_DISPLAY_LISTS;

sce->gm.obstacleSimulation = OBSTSIMULATION_NONE;
sce->gm.levelHeight = 2.f;

Expand Down
2 changes: 0 additions & 2 deletions source/blender/blenloader/intern/versioning_250.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
sce->gm.flag |= GAME_GLSL_NO_ENV_LIGHTING;
if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS)
sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS;

sce->gm.flag |= GAME_DISPLAY_LISTS;
}

for (ob = main->object.first; ob; ob = ob->id.next) {
Expand Down
12 changes: 0 additions & 12 deletions source/blender/blenloader/intern/versioning_upbge.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,12 @@ void blo_do_versions_upbge(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
if (!MAIN_VERSION_UPBGE_ATLEAST(main, 0, 10)) {
if (!DNA_struct_elem_find(fd->filesdna, "GameSettings", "short", "storage")) {
for (Material *ma = main->mat.first; ma; ma = ma->id.next) {
ma->game.storage = GAME_STORAGE_SCENE;
}
}

if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "depthtranspfactor")) {
for (Material *ma = main->mat.first; ma; ma = ma->id.next) {
ma->depthtranspfactor = 1.0f;
}
}

for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
if (scene->gm.raster_storage == GAME_STORAGE_AUTO || scene->gm.raster_storage == GAME_STORAGE_IMMEDIATE) {
scene->gm.raster_storage = GAME_STORAGE_VA;
}
}

if (!DNA_struct_elem_find(fd->filesdna, "EnvMap", "short", "flag")) {
for (Tex *tex = main->tex.first; tex; tex = tex->id.next) {
if (tex->env) {
Expand Down
14 changes: 1 addition & 13 deletions source/blender/makesdna/DNA_material_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ typedef struct GameSettings {
int flag;
int alpha_blend;
int face_orientation;
short storage;
short storage_flag;
int pad;
} GameSettings;

typedef struct TexPaintSlot {
Expand Down Expand Up @@ -251,17 +250,6 @@ typedef struct Material {
#define MA_CONSTANT_WORLD (1 << 3)
#define MA_CONSTANT_MIST (1 << 4)

/* Raster storage */
#ifdef DNA_DEPRECATED
# define GAME_STORAGE_AUTO 0
# define GAME_STORAGE_IMMEDIATE 1
#endif
#define GAME_STORAGE_VA 2
#define GAME_STORAGE_VBO 3
#define GAME_STORAGE_SCENE 4

#define GEMAT_DISPLAY_LISTS (1 << 0)

/* flag */
/* for render */
#define MA_IS_USED 1
Expand Down
6 changes: 2 additions & 4 deletions source/blender/makesdna/DNA_scene_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,21 +845,20 @@ typedef struct GameData {
* bit 5: (gameengine) : enable Bullet DBVT tree for view frustum culling
*/
int flag;
short mode, pad1;
short mode;
short occlusionRes; /* resolution of occlusion Z buffer in pixel */
short physicsEngine;
short exitkey;
short pythonkeys[4];
short vsync; /* Controls vsync: off, on, or adaptive (if supported) */
short ticrate, maxlogicstep, physubstep, maxphystep;
short obstacleSimulation;
short raster_storage;
float levelHeight;
float deactivationtime, lineardeactthreshold, angulardeactthreshold;

/* Scene LoD */
short lodflag, pad2;
int scehysteresis, pad5;
int scehysteresis;

} GameData;

Expand Down Expand Up @@ -894,7 +893,6 @@ typedef struct GameData {
#define GAME_SHOW_DEBUG_PROPS (1 << 2)
#define GAME_SHOW_FRAMERATE (1 << 3)
#define GAME_SHOW_PHYSICS (1 << 4)
#define GAME_DISPLAY_LISTS (1 << 5)
#define GAME_GLSL_NO_LIGHTS (1 << 6)
#define GAME_GLSL_NO_SHADERS (1 << 7)
#define GAME_GLSL_NO_SHADOWS (1 << 8)
Expand Down
18 changes: 0 additions & 18 deletions source/blender/makesrna/intern/rna_material.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,6 @@ static void rna_def_material_gamesettings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};

static EnumPropertyItem storage_items[] = {
{GAME_STORAGE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"},
{GAME_STORAGE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects",
"Typically slower than vertex arrays with display lists, requires at least OpenGL 1.4"},
{GAME_STORAGE_SCENE, "SCENE", 0, "Scene Default", "Use scene storage mode"},
{0, NULL, 0, NULL, NULL}
};

srna = RNA_def_struct(brna, "MaterialGameSettings", NULL);
RNA_def_struct_sdna(srna, "GameSettings");
RNA_def_struct_nested(brna, srna, "Material");
Expand All @@ -930,16 +922,6 @@ static void rna_def_material_gamesettings(BlenderRNA *brna)
prop = RNA_def_property(srna, "face_orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_face_orientation_items);
RNA_def_property_ui_text(prop, "Face Orientations", "Especial face orientation options");

prop = RNA_def_property(srna, "storage", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "storage");
RNA_def_property_enum_items(prop, storage_items);
RNA_def_property_ui_text(prop, "Storage", "Set the storage mode used by the rasterizer");

prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "storage_flag", GEMAT_DISPLAY_LISTS);
RNA_def_property_ui_text(prop, "Display Lists",
"Use display lists to speed up rendering by keeping geometry on the GPU");
}

static void rna_def_material_colors(StructRNA *srna)
Expand Down
21 changes: 2 additions & 19 deletions source/blender/makesrna/intern/rna_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ static void rna_def_gpencil_brush(BlenderRNA *brna)
RNA_def_property_range(prop, -M_PI_2, M_PI_2);
RNA_def_property_ui_text(prop, "Angle",
"Direction of the stroke at which brush gives maximal thickness "
"(0° for horizontal)");
"(0?? for horizontal)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);

/* Factor to change brush size depending of angle */
Expand Down Expand Up @@ -4422,12 +4422,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};

static EnumPropertyItem storage_items[] = {
{GAME_STORAGE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"},
{GAME_STORAGE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects",
"Typically slower than vertex arrays with display lists, requires at least OpenGL 1.4"},
{0, NULL, 0, NULL, NULL}};

srna = RNA_def_struct(brna, "SceneGameData", NULL);
RNA_def_struct_sdna(srna, "GameData");
RNA_def_struct_nested(brna, srna, "Scene");
Expand Down Expand Up @@ -4477,13 +4471,7 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, NULL, "rna_GameSettings_exit_key_set", NULL);
RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine");
RNA_def_property_update(prop, NC_SCENE, NULL);

prop = RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "raster_storage");
RNA_def_property_enum_items(prop, storage_items);
RNA_def_property_ui_text(prop, "Storage", "Set the storage mode used by the rasterizer");
RNA_def_property_update(prop, NC_SCENE, NULL);


/* Do we need it here ? (since we already have it in World */
prop = RNA_def_property(srna, "frequency", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "freqplay");
Expand Down Expand Up @@ -4677,11 +4665,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
"Respect the frame rate from the Physics panel in the world properties "
"rather than rendering as many frames as possible");

prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS);
RNA_def_property_ui_text(prop, "Display Lists",
"Use display lists to speed up rendering by keeping geometry on the GPU");

prop = RNA_def_property(srna, "use_deprecation_warnings", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS);
RNA_def_property_ui_text(prop, "Deprecation Warnings",
Expand Down
24 changes: 0 additions & 24 deletions source/gameengine/Ketsji/KX_BlenderMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,6 @@ KX_BlenderMaterial::KX_BlenderMaterial(
ME_MTEXFACE_CPY(m_mtexPoly, mtface);
}

short storage = game->storage;
// If the material storage is set to RAS_STORE_SCENE then we use the storage set in scene.
if (storage == GAME_STORAGE_SCENE) {
Scene *blenderScene = scene->GetBlenderScene();
storage = blenderScene->gm.raster_storage;
m_flag |= (blenderScene->gm.flag & GAME_DISPLAY_LISTS) ? RAS_DISPLAYLISTS : 0;
}
else {
m_flag |= (game->storage_flag & GEMAT_DISPLAY_LISTS) ? RAS_DISPLAYLISTS : 0;
}

switch (storage) {
case GAME_STORAGE_VA:
{
m_storageType = RAS_IRasterizer::RAS_STORAGE_VA;
break;
}
case GAME_STORAGE_VBO:
{
m_storageType = RAS_IRasterizer::RAS_STORAGE_VBO;
break;
}
};

// with ztransp enabled, enforce alpha blending mode
if ((mat->mode & MA_TRANSP) && (mat->mode & MA_ZTRANSP) && (m_alphablend == GEMAT_SOLID)) {
m_alphablend = GEMAT_ALPHA;
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Ketsji/KX_FontObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void KX_FontObject::AddMeshUser()
RAS_TexVertFormat format;
format.uvSize = 1;
format.colorSize = 1;
bucket->AddMesh(NULL, NULL, format);
bucket->NewMesh(NULL, NULL, format);
}

/* We copy the original mesh slot which is at the begin of the list, if it's not the case it
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Rasterizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ set(SRC
RAS_IDisplayArray.h
RAS_IPolygonMaterial.h
RAS_IRasterizer.h
RAS_IStorage.h
RAS_IStorageInfo.h
RAS_ILightObject.h
RAS_InstancingBuffer.h
RAS_ISync.h
Expand Down
8 changes: 4 additions & 4 deletions source/gameengine/Rasterizer/RAS_BucketManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ void RAS_BucketManager::RenderSortedBuckets(const MT_Transform& cameratrans, RAS
RAS_DisplayArrayBucket *displayArrayBucket = sit->m_ms->m_displayArrayBucket;

/* Unbind display array here before unset material to use the proper
* number of attributs in RAS_IStorage::Unbind since this variable is
* number of attributs in storage unbind since this variable is
* global and mutated by all material during its activation.
*/
if (displayArrayBucket != lastDisplayArrayBucket && lastDisplayArrayBucket) {
rasty->UnbindPrimitives(lastDisplayArrayBucket->GetStorageType(), lastDisplayArrayBucket);
rasty->UnbindPrimitives(lastDisplayArrayBucket);
}
if (bucket != lastMaterialBucket) {
if (matactivated) {
Expand All @@ -192,15 +192,15 @@ void RAS_BucketManager::RenderSortedBuckets(const MT_Transform& cameratrans, RAS
* proper attributs numbers, same as display array unbind before.
*/
if (displayArrayBucket != lastDisplayArrayBucket) {
rasty->BindPrimitives(displayArrayBucket->GetStorageType(), displayArrayBucket);
rasty->BindPrimitives(displayArrayBucket);
lastDisplayArrayBucket = displayArrayBucket;
}

bucket->RenderMeshSlot(cameratrans, rasty, sit->m_ms);
}

// Always unbind VBO or VA before unset the material to use the correct material attributs.
rasty->UnbindPrimitives(lastDisplayArrayBucket->GetStorageType(), lastDisplayArrayBucket);
rasty->UnbindPrimitives(lastDisplayArrayBucket);

if (matactivated) {
lastMaterialBucket->DesactivateMaterial(rasty);
Expand Down
Loading

0 comments on commit b286d18

Please sign in to comment.