mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
gl-min-buffer-usage-hint, gl-debug-buffers
This commit is contained in:
parent
d517b00688
commit
78a08bafcd
@ -57,8 +57,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define DEBUG_BUFFERS false
|
|
||||||
|
|
||||||
TypeHandle CLP(GraphicsStateGuardian)::_type_handle;
|
TypeHandle CLP(GraphicsStateGuardian)::_type_handle;
|
||||||
|
|
||||||
PStatCollector CLP(GraphicsStateGuardian)::_load_display_list_pcollector("Draw:Transfer data:Display lists");
|
PStatCollector CLP(GraphicsStateGuardian)::_load_display_list_pcollector("Draw:Transfer data:Display lists");
|
||||||
@ -1644,8 +1642,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
// Before we compile or call a display list, make sure the current
|
// Before we compile or call a display list, make sure the current
|
||||||
// buffers are unbound, or the nVidia drivers may crash.
|
// buffers are unbound, or the nVidia drivers may crash.
|
||||||
if (_current_vbuffer_index != 0) {
|
if (_current_vbuffer_index != 0) {
|
||||||
if (GLCAT.is_spam()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.spam()
|
GLCAT.debug()
|
||||||
<< "unbinding vertex buffer\n";
|
<< "unbinding vertex buffer\n";
|
||||||
}
|
}
|
||||||
_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
@ -2770,7 +2768,7 @@ prepare_vertex_buffer(GeomVertexArrayData *data) {
|
|||||||
CLP(VertexBufferContext) *gvbc = new CLP(VertexBufferContext)(_prepared_objects, data);
|
CLP(VertexBufferContext) *gvbc = new CLP(VertexBufferContext)(_prepared_objects, data);
|
||||||
_glGenBuffers(1, &gvbc->_index);
|
_glGenBuffers(1, &gvbc->_index);
|
||||||
|
|
||||||
if (DEBUG_BUFFERS && GLCAT.is_debug()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.debug()
|
GLCAT.debug()
|
||||||
<< "creating vertex buffer " << gvbc->_index << ": "
|
<< "creating vertex buffer " << gvbc->_index << ": "
|
||||||
<< data->get_num_rows() << " vertices "
|
<< data->get_num_rows() << " vertices "
|
||||||
@ -2799,8 +2797,8 @@ apply_vertex_buffer(VertexBufferContext *vbc,
|
|||||||
CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), vbc);
|
CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), vbc);
|
||||||
|
|
||||||
if (_current_vbuffer_index != gvbc->_index) {
|
if (_current_vbuffer_index != gvbc->_index) {
|
||||||
if (GLCAT.is_spam()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.spam()
|
GLCAT.debug()
|
||||||
<< "binding vertex buffer " << gvbc->_index << "\n";
|
<< "binding vertex buffer " << gvbc->_index << "\n";
|
||||||
}
|
}
|
||||||
_glBindBuffer(GL_ARRAY_BUFFER, gvbc->_index);
|
_glBindBuffer(GL_ARRAY_BUFFER, gvbc->_index);
|
||||||
@ -2810,8 +2808,8 @@ apply_vertex_buffer(VertexBufferContext *vbc,
|
|||||||
|
|
||||||
if (gvbc->was_modified(reader)) {
|
if (gvbc->was_modified(reader)) {
|
||||||
int num_bytes = reader->get_data_size_bytes();
|
int num_bytes = reader->get_data_size_bytes();
|
||||||
if (GLCAT.is_spam()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.spam()
|
GLCAT.debug()
|
||||||
<< "copying " << num_bytes
|
<< "copying " << num_bytes
|
||||||
<< " bytes into vertex buffer " << gvbc->_index << "\n";
|
<< " bytes into vertex buffer " << gvbc->_index << "\n";
|
||||||
}
|
}
|
||||||
@ -2853,7 +2851,7 @@ release_vertex_buffer(VertexBufferContext *vbc) {
|
|||||||
|
|
||||||
CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), vbc);
|
CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), vbc);
|
||||||
|
|
||||||
if (DEBUG_BUFFERS && GLCAT.is_debug()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.debug()
|
GLCAT.debug()
|
||||||
<< "deleting vertex buffer " << gvbc->_index << "\n";
|
<< "deleting vertex buffer " << gvbc->_index << "\n";
|
||||||
}
|
}
|
||||||
@ -2863,8 +2861,8 @@ release_vertex_buffer(VertexBufferContext *vbc) {
|
|||||||
// help out a flaky driver, and we need to keep our internal state
|
// help out a flaky driver, and we need to keep our internal state
|
||||||
// consistent anyway.
|
// consistent anyway.
|
||||||
if (_current_vbuffer_index == gvbc->_index) {
|
if (_current_vbuffer_index == gvbc->_index) {
|
||||||
if (GLCAT.is_spam()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.spam()
|
GLCAT.debug()
|
||||||
<< "unbinding vertex buffer\n";
|
<< "unbinding vertex buffer\n";
|
||||||
}
|
}
|
||||||
_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
@ -2907,12 +2905,12 @@ setup_array_data(const unsigned char *&client_pointer,
|
|||||||
return (client_pointer != NULL);
|
return (client_pointer != NULL);
|
||||||
}
|
}
|
||||||
if (!vertex_buffers || _geom_display_list != 0 ||
|
if (!vertex_buffers || _geom_display_list != 0 ||
|
||||||
array_reader->get_usage_hint() == Geom::UH_client) {
|
array_reader->get_usage_hint() < CLP(min_buffer_usage_hint)) {
|
||||||
// The array specifies client rendering only, or buffer objects
|
// The array specifies client rendering only, or buffer objects
|
||||||
// are configured off.
|
// are configured off.
|
||||||
if (_current_vbuffer_index != 0) {
|
if (_current_vbuffer_index != 0) {
|
||||||
if (GLCAT.is_spam()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.spam()
|
GLCAT.debug()
|
||||||
<< "unbinding vertex buffer\n";
|
<< "unbinding vertex buffer\n";
|
||||||
}
|
}
|
||||||
_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
@ -2953,7 +2951,7 @@ prepare_index_buffer(GeomPrimitive *data) {
|
|||||||
CLP(IndexBufferContext) *gibc = new CLP(IndexBufferContext)(_prepared_objects, data);
|
CLP(IndexBufferContext) *gibc = new CLP(IndexBufferContext)(_prepared_objects, data);
|
||||||
_glGenBuffers(1, &gibc->_index);
|
_glGenBuffers(1, &gibc->_index);
|
||||||
|
|
||||||
if (DEBUG_BUFFERS && GLCAT.is_debug()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.debug()
|
GLCAT.debug()
|
||||||
<< "creating index buffer " << gibc->_index << ": "
|
<< "creating index buffer " << gibc->_index << ": "
|
||||||
<< data->get_num_vertices() << " indices ("
|
<< data->get_num_vertices() << " indices ("
|
||||||
@ -3038,7 +3036,7 @@ release_index_buffer(IndexBufferContext *ibc) {
|
|||||||
|
|
||||||
CLP(IndexBufferContext) *gibc = DCAST(CLP(IndexBufferContext), ibc);
|
CLP(IndexBufferContext) *gibc = DCAST(CLP(IndexBufferContext), ibc);
|
||||||
|
|
||||||
if (DEBUG_BUFFERS && GLCAT.is_debug()) {
|
if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
||||||
GLCAT.debug()
|
GLCAT.debug()
|
||||||
<< "deleting index buffer " << gibc->_index << "\n";
|
<< "deleting index buffer " << gibc->_index << "\n";
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,27 @@ ConfigVariableInt CLP(max_errors)
|
|||||||
"detect and report before it shuts down rendering. Set it to "
|
"detect and report before it shuts down rendering. Set it to "
|
||||||
"-1 for no limit."));
|
"-1 for no limit."));
|
||||||
|
|
||||||
|
ConfigVariableEnum<GeomEnums::UsageHint> CLP(min_buffer_usage_hint)
|
||||||
|
("gl-min-buffer-usage-hint", GeomEnums::UH_stream,
|
||||||
|
PRC_DESC("This specifies the first usage hint value that will be "
|
||||||
|
"loaded as a vertex buffer, instead of directly from the "
|
||||||
|
"client. Normally, this should be \"stream\", which means "
|
||||||
|
"to load the vertex buffer using GL_STREAM_DRAW. If this "
|
||||||
|
"is set to \"dynamic\", or \"static\", then only usage hints "
|
||||||
|
"at that level or higher will be loaded as a vertex buffer, "
|
||||||
|
"and stream or lower will be rendered directly from the "
|
||||||
|
"client array. If changing this results in a remarkable "
|
||||||
|
"performance improvement, you may have code that is "
|
||||||
|
"creating and destroying vertex buffers every frame, instead "
|
||||||
|
"of reusing the same buffers. Consider increasing "
|
||||||
|
"released-vbuffer-cache-size instead."));
|
||||||
|
|
||||||
|
ConfigVariableBool CLP(debug_buffers)
|
||||||
|
("gl-debug-buffers", false,
|
||||||
|
PRC_DESC("Set this true, in addition to enabling debug notify for "
|
||||||
|
"glgsg, to enable debug messages about the creation and "
|
||||||
|
"destruction of OpenGL vertex buffers."));
|
||||||
|
|
||||||
extern ConfigVariableBool CLP(parallel_arrays);
|
extern ConfigVariableBool CLP(parallel_arrays);
|
||||||
|
|
||||||
void CLP(init_classes)() {
|
void CLP(init_classes)() {
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include "pandabase.h"
|
#include "pandabase.h"
|
||||||
#include "configVariableBool.h"
|
#include "configVariableBool.h"
|
||||||
|
#include "configVariableInt.h"
|
||||||
|
#include "configVariableEnum.h"
|
||||||
|
#include "geomEnums.h"
|
||||||
|
|
||||||
//#define GSG_VERBOSE 1
|
//#define GSG_VERBOSE 1
|
||||||
|
|
||||||
@ -33,6 +36,8 @@ extern ConfigVariableBool CLP(compile_and_execute);
|
|||||||
extern ConfigVariableBool CLP(interleaved_arrays);
|
extern ConfigVariableBool CLP(interleaved_arrays);
|
||||||
extern ConfigVariableBool CLP(parallel_arrays);
|
extern ConfigVariableBool CLP(parallel_arrays);
|
||||||
extern ConfigVariableInt CLP(max_errors);
|
extern ConfigVariableInt CLP(max_errors);
|
||||||
|
extern ConfigVariableEnum<GeomEnums::UsageHint> CLP(min_buffer_usage_hint);
|
||||||
|
extern ConfigVariableBool CLP(debug_buffers);
|
||||||
|
|
||||||
extern EXPCL_GL void CLP(init_classes)();
|
extern EXPCL_GL void CLP(init_classes)();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user