gl-finish

This commit is contained in:
David Rose 2008-04-10 20:18:20 +00:00
parent bd6d34a26e
commit aaa4e12223
5 changed files with 40 additions and 0 deletions

View File

@ -145,6 +145,21 @@ get_gl_version_release() const {
return _gl_version_release;
}
////////////////////////////////////////////////////////////////////
// Function: GLGraphicsStateGuardian::maybe_gl_finish
// Access: Protected
// Description: Calls glFinish() if the config variable gl-finish is
// set True.
////////////////////////////////////////////////////////////////////
INLINE void CLP(GraphicsStateGuardian)::
maybe_gl_finish() const {
#ifdef DO_PSTATS
if (CLP(finish)) {
GLP(Finish)();
}
#endif
}
////////////////////////////////////////////////////////////////////
// Function: CLP(GraphicsStateGuardian)::enable_multisample_antialias
// Access: Protected

View File

@ -253,6 +253,13 @@ CLP(GraphicsStateGuardian)(GraphicsPipe *pipe) :
// since we know this works properly in OpenGL, and we want the
// performance benefit it gives us.
_prepared_objects->_support_released_buffer_cache = true;
#ifdef DO_PSTATS
if (CLP(finish)) {
GLCAT.warning()
<< "The config variable gl-finish is set True. This may have a substantial negative impact your render performance.\n";
}
#endif // DO_PSTATS
}
////////////////////////////////////////////////////////////////////
@ -1686,6 +1693,7 @@ end_frame(Thread *current_thread) {
// will be finished drawing before we return to the application.
// It's not clear what effect this has on our total frame time.
gl_flush();
maybe_gl_finish();
report_my_gl_errors();
}
@ -2567,6 +2575,7 @@ end_draw_primitives() {
}
GraphicsStateGuardian::end_draw_primitives();
maybe_gl_finish();
report_my_gl_errors();
}
@ -3032,6 +3041,7 @@ apply_vertex_buffer(VertexBufferContext *vbc,
gvbc->mark_loaded(reader);
}
maybe_gl_finish();
report_my_gl_errors();
return true;
}
@ -3217,6 +3227,7 @@ apply_index_buffer(IndexBufferContext *ibc,
gibc->mark_loaded(reader);
}
maybe_gl_finish();
report_my_gl_errors();
return true;
}
@ -6206,6 +6217,8 @@ set_state_and_transform(const RenderState *target,
}
_state_rs = _target_rs;
maybe_gl_finish();
report_my_gl_errors();
}
////////////////////////////////////////////////////////////////////
@ -7079,6 +7092,8 @@ upload_texture(CLP(TextureContext) *gtc) {
false, 0, image_compression);
}
maybe_gl_finish();
if (success) {
gtc->_already_applied = true;
gtc->_uses_mipmaps = uses_mipmaps;

View File

@ -245,6 +245,7 @@ protected:
void do_issue_stencil();
virtual void gl_flush() const;
INLINE void maybe_gl_finish() const;
virtual GLenum gl_get_error() const;
static bool report_errors_loop(int line, const char *source_file,

View File

@ -121,6 +121,14 @@ ConfigVariableBool CLP(debug_buffers)
"glgsg, to enable debug messages about the creation and "
"destruction of OpenGL vertex buffers."));
ConfigVariableBool CLP(finish)
("gl-finish", false,
PRC_DESC("Set this true to force a call to glFinish() after every major "
"graphics operation. This is likely to slow down rendering "
"performance substantially, but it will make PStats graphs "
"more accurately reflect where the graphics bottlenecks are. "
"This variable is enabled only if PStats is compiled in."));
extern ConfigVariableBool CLP(parallel_arrays);
void CLP(init_classes)() {

View File

@ -38,6 +38,7 @@ extern ConfigVariableBool CLP(parallel_arrays);
extern ConfigVariableInt CLP(max_errors);
extern ConfigVariableEnum<GeomEnums::UsageHint> CLP(min_buffer_usage_hint);
extern ConfigVariableBool CLP(debug_buffers);
extern ConfigVariableBool CLP(finish);
extern EXPCL_GL void CLP(init_classes)();