From bac5401a9d2bb5977f7f8cfedb6dfdc187ef5255 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Oct 2015 13:18:12 +0100 Subject: [PATCH] Add GL function pointers for indirect draw --- panda/src/display/graphicsStateGuardian.I | 12 ++++++++++++ panda/src/display/graphicsStateGuardian.cxx | 1 + panda/src/display/graphicsStateGuardian.h | 2 ++ .../glstuff/glGraphicsStateGuardian_src.cxx | 18 ++++++++++++++++++ .../src/glstuff/glGraphicsStateGuardian_src.h | 5 +++++ 5 files changed, 38 insertions(+) diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 1646f4a741..8a3a5b6f5b 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -808,6 +808,18 @@ get_supports_geometry_instancing() const { return _supports_geometry_instancing; } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsStateGuardian::get_supports_indirect_draw +// Access: Published +// Description: Returns true if this particular GSG supports +// draw calls for which the information comes from a +// buffer. +//////////////////////////////////////////////////////////////////// +INLINE bool GraphicsStateGuardian:: +get_supports_indirect_draw() const { + return _supports_indirect_draw; +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::get_supports_occlusion_query // Access: Published diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index b804613d9e..c55b988125 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -245,6 +245,7 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _supports_stencil_wrap = false; _supports_two_sided_stencil = false; _supports_geometry_instancing = false; + _supports_indirect_draw = false; // Assume a maximum of 1 render target in absence of MRT. _max_color_targets = 1; diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index b657d867e9..50ef6f0f2d 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -160,6 +160,7 @@ PUBLISHED: INLINE bool get_supports_stencil() const; INLINE bool get_supports_two_sided_stencil() const; INLINE bool get_supports_geometry_instancing() const; + INLINE bool get_supports_indirect_draw() const; INLINE bool get_supports_occlusion_query() const; INLINE bool get_supports_timer_query() const; @@ -538,6 +539,7 @@ protected: bool _supports_stencil_wrap; bool _supports_two_sided_stencil; bool _supports_geometry_instancing; + bool _supports_indirect_draw; int _max_color_targets; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index d24272383c..614dbec469 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1757,6 +1757,24 @@ reset() { } #endif + // Check if we support indirect draw. + _supports_indirect_draw = false; +#ifndef OPENGLES + if (is_at_least_gl_version(4, 0) || has_extension("GL_ARB_draw_indirect")) { + _glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC) + get_extension_func("glDrawArraysIndirect"); + _glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) + get_extension_func("glDrawElementsIndirect"); + + if (_glDrawArraysIndirect == NULL || _glDrawElementsIndirect == NULL) { + GLCAT.warning() + << "Indirect draw advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; + } else { + _supports_indirect_draw = true; + } + } +#endif + #ifdef OPENGLES_2 // In OpenGL ES 2.x, FBO's are supported in the core. _supports_framebuffer_object = true; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index fcfe13c56a..62df6fe84c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -763,6 +763,11 @@ public: PFNGLDELETEVERTEXARRAYSPROC _glDeleteVertexArrays; PFNGLGENVERTEXARRAYSPROC _glGenVertexArrays; +#ifndef OPENGLES + PFNGLDRAWARRAYSINDIRECTPROC _glDrawArraysIndirect; + PFNGLDRAWELEMENTSINDIRECTPROC _glDrawElementsIndirect; +#endif + bool _supports_framebuffer_object; PFNGLISRENDERBUFFEREXTPROC _glIsRenderbuffer; PFNGLBINDRENDERBUFFEREXTPROC _glBindRenderbuffer;