mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
prevent GL error; fix indentation issues etc.
This commit is contained in:
parent
a3c8f13920
commit
f42935b8e9
@ -41,8 +41,7 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
|
|
||||||
if ( glgsg->get_supports_framebuffer_multisample() && glgsg->get_supports_framebuffer_blit() ) {
|
if ( glgsg->get_supports_framebuffer_multisample() && glgsg->get_supports_framebuffer_blit() ) {
|
||||||
_requested_multisamples = fb_prop.get_multisamples();
|
_requested_multisamples = fb_prop.get_multisamples();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_requested_multisamples = 0;
|
_requested_multisamples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,24 +51,22 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
if ( (_requested_coverage_samples <= 8) && (_requested_coverage_samples > 0) ) {
|
if ( (_requested_coverage_samples <= 8) && (_requested_coverage_samples > 0) ) {
|
||||||
_requested_multisamples = 4;
|
_requested_multisamples = 4;
|
||||||
_requested_coverage_samples = 8;
|
_requested_coverage_samples = 8;
|
||||||
}
|
} else if (_requested_coverage_samples > 8) {
|
||||||
else if (_requested_coverage_samples > 8) {
|
if (_requested_multisamples < 8) {
|
||||||
if (_requested_multisamples < 8)
|
|
||||||
_requested_multisamples = 4;
|
_requested_multisamples = 4;
|
||||||
else
|
} else {
|
||||||
_requested_multisamples = 8;
|
_requested_multisamples = 8;
|
||||||
|
}
|
||||||
_requested_coverage_samples = 16;
|
_requested_coverage_samples = 16;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
_requested_coverage_samples = 0;
|
_requested_coverage_samples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float maxMultisamples = 0.0f;
|
if (_requested_multisamples > glgsg->_max_fb_samples) {
|
||||||
glGetFloatv(GL_MAX_SAMPLES_EXT, &maxMultisamples);
|
_requested_multisamples = glgsg->_max_fb_samples;
|
||||||
|
}
|
||||||
if (_requested_multisamples > maxMultisamples)
|
|
||||||
_requested_multisamples = maxMultisamples;
|
|
||||||
|
|
||||||
_rb_size_x = 0;
|
_rb_size_x = 0;
|
||||||
_rb_size_y = 0;
|
_rb_size_y = 0;
|
||||||
@ -85,6 +82,7 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
_shared_depth_buffer = 0;
|
_shared_depth_buffer = 0;
|
||||||
|
report_my_gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -874,6 +872,7 @@ select_cube_map(int cube_map_index) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool CLP(GraphicsBuffer)::
|
bool CLP(GraphicsBuffer)::
|
||||||
open_buffer() {
|
open_buffer() {
|
||||||
|
report_my_gl_errors();
|
||||||
|
|
||||||
// Double check that we have a host
|
// Double check that we have a host
|
||||||
nassertr(_host != 0, false);
|
nassertr(_host != 0, false);
|
||||||
@ -934,6 +933,7 @@ void CLP(GraphicsBuffer)::
|
|||||||
close_buffer() {
|
close_buffer() {
|
||||||
|
|
||||||
check_host_valid();
|
check_host_valid();
|
||||||
|
report_my_gl_errors();
|
||||||
|
|
||||||
_active = false;
|
_active = false;
|
||||||
if (_gsg == 0) {
|
if (_gsg == 0) {
|
||||||
|
@ -45,10 +45,12 @@ report_errors(int line, const char *source_file) {
|
|||||||
INLINE void CLP(GraphicsStateGuardian)::
|
INLINE void CLP(GraphicsStateGuardian)::
|
||||||
report_my_errors(int line, const char *source_file) {
|
report_my_errors(int line, const char *source_file) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
GLenum error_code = gl_get_error();
|
if (_track_errors) {
|
||||||
if (error_code != GL_NO_ERROR) {
|
GLenum error_code = gl_get_error();
|
||||||
if (!report_errors_loop(line, source_file, error_code, _error_count)) {
|
if (error_code != GL_NO_ERROR) {
|
||||||
panic_deactivate();
|
if (!report_errors_loop(line, source_file, error_code, _error_count)) {
|
||||||
|
panic_deactivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,10 +75,6 @@ PStatCollector CLP(GraphicsStateGuardian)::_primitive_batches_display_list_pcoll
|
|||||||
PStatCollector CLP(GraphicsStateGuardian)::_vertices_display_list_pcollector("Vertices:Display lists");
|
PStatCollector CLP(GraphicsStateGuardian)::_vertices_display_list_pcollector("Vertices:Display lists");
|
||||||
PStatCollector CLP(GraphicsStateGuardian)::_vertices_immediate_pcollector("Vertices:Immediate mode");
|
PStatCollector CLP(GraphicsStateGuardian)::_vertices_immediate_pcollector("Vertices:Immediate mode");
|
||||||
|
|
||||||
// KZL hack. These track PRC settings.
|
|
||||||
bool _track_errors = 1;
|
|
||||||
bool _allow_flush = 1;
|
|
||||||
|
|
||||||
// The following noop functions are assigned to the corresponding
|
// The following noop functions are assigned to the corresponding
|
||||||
// glext function pointers in the class, in case the functions are not
|
// glext function pointers in the class, in case the functions are not
|
||||||
// defined by the GL, just so it will always be safe to call the
|
// defined by the GL, just so it will always be safe to call the
|
||||||
@ -273,6 +269,10 @@ CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) :
|
|||||||
// the window tells us otherwise.
|
// the window tells us otherwise.
|
||||||
_is_hardware = true;
|
_is_hardware = true;
|
||||||
|
|
||||||
|
// calling glGetError() forces a sync, this turns it off if you want to.
|
||||||
|
_track_errors = !CLP(force_no_error);
|
||||||
|
_allow_flush = !CLP(force_no_flush);
|
||||||
|
|
||||||
#ifdef DO_PSTATS
|
#ifdef DO_PSTATS
|
||||||
if (CLP(finish)) {
|
if (CLP(finish)) {
|
||||||
GLCAT.warning()
|
GLCAT.warning()
|
||||||
@ -824,22 +824,25 @@ reset() {
|
|||||||
get_extension_func(GLPREFIX_QUOTED, "GenerateMipmapEXT");
|
get_extension_func(GLPREFIX_QUOTED, "GenerateMipmapEXT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_supports_framebuffer_multisample = false;
|
||||||
if ( has_extension("GL_EXT_framebuffer_multisample") ) {
|
if ( has_extension("GL_EXT_framebuffer_multisample") ) {
|
||||||
_supports_framebuffer_multisample = true;
|
_supports_framebuffer_multisample = true;
|
||||||
_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
|
_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
|
||||||
get_extension_func(GLPREFIX_QUOTED, "RenderbufferStorageMultisampleEXT");
|
get_extension_func(GLPREFIX_QUOTED, "RenderbufferStorageMultisampleEXT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_supports_framebuffer_multisample_coverage_nv = false;
|
||||||
if ( has_extension("GL_NV_framebuffer_multisample_coverage") ) {
|
if ( has_extension("GL_NV_framebuffer_multisample_coverage") ) {
|
||||||
_supports_framebuffer_multisample_coverage_nv = true;
|
_supports_framebuffer_multisample_coverage_nv = true;
|
||||||
_glRenderbufferStorageMultisampleCoverage = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC)
|
_glRenderbufferStorageMultisampleCoverage = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC)
|
||||||
get_extension_func(GLPREFIX_QUOTED, "RenderbufferStorageMultisampleCoverageNV");
|
get_extension_func(GLPREFIX_QUOTED, "RenderbufferStorageMultisampleCoverageNV");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_supports_framebuffer_blit = false;
|
||||||
if ( has_extension("GL_EXT_framebuffer_blit") ) {
|
if ( has_extension("GL_EXT_framebuffer_blit") ) {
|
||||||
_supports_framebuffer_blit = true;
|
_supports_framebuffer_blit = true;
|
||||||
_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFEREXTPROC)
|
_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFEREXTPROC)
|
||||||
get_extension_func(GLPREFIX_QUOTED, "BlitFramebufferEXT");
|
get_extension_func(GLPREFIX_QUOTED, "BlitFramebufferEXT");
|
||||||
}
|
}
|
||||||
|
|
||||||
_glDrawBuffers = NULL;
|
_glDrawBuffers = NULL;
|
||||||
@ -858,6 +861,13 @@ reset() {
|
|||||||
_maximum_simultaneous_render_targets = max_draw_buffers;
|
_maximum_simultaneous_render_targets = max_draw_buffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_max_fb_samples = 0;
|
||||||
|
if (_supports_framebuffer_multisample) {
|
||||||
|
GLfloat max_samples;
|
||||||
|
GLP(GetFloatv)(GL_MAX_SAMPLES_EXT, &max_samples);
|
||||||
|
_max_fb_samples = max_samples;
|
||||||
|
}
|
||||||
|
|
||||||
_supports_occlusion_query = false;
|
_supports_occlusion_query = false;
|
||||||
if (CLP(support_occlusion_query)) {
|
if (CLP(support_occlusion_query)) {
|
||||||
if (is_at_least_gl_version(1, 5)) {
|
if (is_at_least_gl_version(1, 5)) {
|
||||||
@ -1175,16 +1185,6 @@ reset() {
|
|||||||
#endif // OPENGLES_1
|
#endif // OPENGLES_1
|
||||||
_dithering_enabled = false;
|
_dithering_enabled = false;
|
||||||
|
|
||||||
// calling glGetError() forces a sync, this turns it off if you want to.
|
|
||||||
if (ConfigVariableBool("gl-force-no-error", false, PRC_DESC("make the gl GSG not report errors, as doing so is a performance hit.")))
|
|
||||||
_track_errors = false;
|
|
||||||
else
|
|
||||||
_track_errors = true;
|
|
||||||
if (ConfigVariableBool("gl-force-no-flush", false, PRC_DESC("make the gl GSG not flush, as doing so is a performance hit. This is a dangerour setting.")))
|
|
||||||
_allow_flush = false;
|
|
||||||
else
|
|
||||||
_allow_flush = true;
|
|
||||||
|
|
||||||
_current_shader = (Shader *)NULL;
|
_current_shader = (Shader *)NULL;
|
||||||
_current_shader_context = (CLP(ShaderContext) *)NULL;
|
_current_shader_context = (CLP(ShaderContext) *)NULL;
|
||||||
_vertex_array_shader = (Shader *)NULL;
|
_vertex_array_shader = (Shader *)NULL;
|
||||||
@ -1365,6 +1365,7 @@ reset() {
|
|||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
clear(DrawableRegion *clearable) {
|
clear(DrawableRegion *clearable) {
|
||||||
PStatTimer timer(_clear_pcollector);
|
PStatTimer timer(_clear_pcollector);
|
||||||
|
report_my_gl_errors();
|
||||||
|
|
||||||
if ((!clearable->get_clear_color_active())&&
|
if ((!clearable->get_clear_color_active())&&
|
||||||
(!clearable->get_clear_depth_active())&&
|
(!clearable->get_clear_depth_active())&&
|
||||||
@ -1603,6 +1604,7 @@ begin_frame(Thread *current_thread) {
|
|||||||
if (!GraphicsStateGuardian::begin_frame(current_thread)) {
|
if (!GraphicsStateGuardian::begin_frame(current_thread)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
report_my_gl_errors();
|
||||||
|
|
||||||
#ifdef DO_PSTATS
|
#ifdef DO_PSTATS
|
||||||
_vertices_display_list_pcollector.clear_level();
|
_vertices_display_list_pcollector.clear_level();
|
||||||
@ -1705,6 +1707,7 @@ end_scene() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
end_frame(Thread *current_thread) {
|
end_frame(Thread *current_thread) {
|
||||||
|
report_my_gl_errors();
|
||||||
#ifdef DO_PSTATS
|
#ifdef DO_PSTATS
|
||||||
// Check for textures, etc., that are no longer resident. These
|
// Check for textures, etc., that are no longer resident. These
|
||||||
// calls might be measurably expensive, and they don't have any
|
// calls might be measurably expensive, and they don't have any
|
||||||
@ -4540,8 +4543,9 @@ draw_immediate_composite_primitives(const GeomPrimitivePipelineReader *reader, G
|
|||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
gl_flush() const {
|
gl_flush() const {
|
||||||
PStatTimer timer(_flush_pcollector);
|
PStatTimer timer(_flush_pcollector);
|
||||||
if (_allow_flush)
|
if (_allow_flush) {
|
||||||
GLP(Flush)();
|
GLP(Flush)();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -4551,10 +4555,11 @@ gl_flush() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
GLenum CLP(GraphicsStateGuardian)::
|
GLenum CLP(GraphicsStateGuardian)::
|
||||||
gl_get_error() const {
|
gl_get_error() const {
|
||||||
if (_track_errors)
|
if (_track_errors) {
|
||||||
return GLP(GetError)();
|
return GLP(GetError)();
|
||||||
else
|
} else {
|
||||||
return GL_NO_ERROR;
|
return GL_NO_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -4568,8 +4573,6 @@ gl_get_error() const {
|
|||||||
bool CLP(GraphicsStateGuardian)::
|
bool CLP(GraphicsStateGuardian)::
|
||||||
report_errors_loop(int line, const char *source_file, GLenum error_code,
|
report_errors_loop(int line, const char *source_file, GLenum error_code,
|
||||||
int &error_count) {
|
int &error_count) {
|
||||||
if (!_track_errors)
|
|
||||||
return GL_NO_ERROR;
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
while ((CLP(max_errors) < 0 || error_count < CLP(max_errors)) &&
|
while ((CLP(max_errors) < 0 || error_count < CLP(max_errors)) &&
|
||||||
(error_code != GL_NO_ERROR)) {
|
(error_code != GL_NO_ERROR)) {
|
||||||
@ -6252,6 +6255,7 @@ end_bind_clip_planes() {
|
|||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
set_state_and_transform(const RenderState *target,
|
set_state_and_transform(const RenderState *target,
|
||||||
const TransformState *transform) {
|
const TransformState *transform) {
|
||||||
|
report_my_gl_errors();
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (gsg_cat.is_spam()) {
|
if (gsg_cat.is_spam()) {
|
||||||
gsg_cat.spam() << "Setting GSG state to " << (void *)target << ":\n";
|
gsg_cat.spam() << "Setting GSG state to " << (void *)target << ":\n";
|
||||||
@ -8652,16 +8656,15 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now see if we were successful.
|
// Now see if we were successful.
|
||||||
if (_track_errors)
|
if (_track_errors) {
|
||||||
{
|
|
||||||
GLenum error_code = GLP(GetError)();
|
GLenum error_code = GLP(GetError)();
|
||||||
if (error_code != GL_NO_ERROR) {
|
if (error_code != GL_NO_ERROR) {
|
||||||
GLCAT.error()
|
GLCAT.error()
|
||||||
<< "Unable to extract texture for " << *tex
|
<< "Unable to extract texture for " << *tex
|
||||||
<< ", mipmap level " << n
|
<< ", mipmap level " << n
|
||||||
<< " : " << get_error_string(error_code) << "\n";
|
<< " : " << get_error_string(error_code) << "\n";
|
||||||
nassertr(false, false);
|
nassertr(false, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -518,6 +518,7 @@ public:
|
|||||||
PFNGLBLITFRAMEBUFFEREXTPROC _glBlitFramebuffer;
|
PFNGLBLITFRAMEBUFFEREXTPROC _glBlitFramebuffer;
|
||||||
PFNGLDRAWBUFFERSPROC _glDrawBuffers;
|
PFNGLDRAWBUFFERSPROC _glDrawBuffers;
|
||||||
int _max_draw_buffers;
|
int _max_draw_buffers;
|
||||||
|
int _max_fb_samples;
|
||||||
|
|
||||||
PFNGLGENQUERIESPROC _glGenQueries;
|
PFNGLGENQUERIESPROC _glGenQueries;
|
||||||
PFNGLBEGINQUERYPROC _glBeginQuery;
|
PFNGLBEGINQUERYPROC _glBeginQuery;
|
||||||
@ -542,6 +543,9 @@ public:
|
|||||||
|
|
||||||
RenderState::SlotMask _inv_state_mask;
|
RenderState::SlotMask _inv_state_mask;
|
||||||
|
|
||||||
|
bool _track_errors;
|
||||||
|
bool _allow_flush;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool _show_texture_usage;
|
bool _show_texture_usage;
|
||||||
int _show_texture_usage_max_size;
|
int _show_texture_usage_max_size;
|
||||||
|
@ -148,6 +148,14 @@ ConfigVariableBool CLP(matrix_palette)
|
|||||||
("gl-matrix-palette", false,
|
("gl-matrix-palette", false,
|
||||||
PRC_DESC("Temporary hack variable protecting untested code. See glGraphicsStateGuardian_src.cxx."));
|
PRC_DESC("Temporary hack variable protecting untested code. See glGraphicsStateGuardian_src.cxx."));
|
||||||
|
|
||||||
|
ConfigVariableBool CLP(force_no_error)
|
||||||
|
("gl-force-no-error", false,
|
||||||
|
PRC_DESC("Avoid reporting OpenGL errors, for a small performance benefit."));
|
||||||
|
|
||||||
|
ConfigVariableBool CLP(force_no_flush)
|
||||||
|
("gl-force-no-flush", false,
|
||||||
|
PRC_DESC("Avoid calling glFlush(), for a potential performance benefit. This may be a little dangerous."));
|
||||||
|
|
||||||
extern ConfigVariableBool CLP(parallel_arrays);
|
extern ConfigVariableBool CLP(parallel_arrays);
|
||||||
|
|
||||||
void CLP(init_classes)() {
|
void CLP(init_classes)() {
|
||||||
|
@ -39,6 +39,8 @@ extern ConfigVariableBool CLP(debug_buffers);
|
|||||||
extern ConfigVariableBool CLP(finish);
|
extern ConfigVariableBool CLP(finish);
|
||||||
extern ConfigVariableBool CLP(force_depth_stencil);
|
extern ConfigVariableBool CLP(force_depth_stencil);
|
||||||
extern ConfigVariableBool CLP(matrix_palette);
|
extern ConfigVariableBool CLP(matrix_palette);
|
||||||
|
extern ConfigVariableBool CLP(force_no_error);
|
||||||
|
extern ConfigVariableBool CLP(force_no_flush);
|
||||||
|
|
||||||
extern EXPCL_GL void CLP(init_classes)();
|
extern EXPCL_GL void CLP(init_classes)();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user