diff --git a/doc/changelog.dox b/doc/changelog.dox index afb4ecd67..82ba7bd89 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -106,7 +106,8 @@ See also: more information. - New @ref GL::Buffer::Buffer(Containers::ArrayView, BufferUsage) constructor for directly creating buffers filled with data. -- New @ref GL::Mesh::maxVertexAttributeStride() limit query +- New @ref GL::Mesh::maxVertexAttributeStride() and + @ref GL::AbstractShaderProgram::maxGeometryOutputVertices() limit queries - Added a @ref GL::Shader::Shader(NoCreateT) constructor for consistency with other OpenGL wrapper objects diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index f46e876f4..c8b5431cd 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -496,7 +496,7 @@ glGet() parameter | Matching API @def_gl{MAX_FRAMEBUFFER_SAMPLES} | | @def_gl{MAX_FRAMEBUFFER_WIDTH} | | @def_gl{MAX_FRAGMENT_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_OUTPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VERTEX_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VARYING_VECTORS} | @ref GL::Shader::maxFragmentInputComponents(), \n @ref GL::Shader::maxGeometryInputComponents(), \n @ref GL::Shader::maxGeometryOutputComponents(), \n @ref GL::Shader::maxGeometryTotalOutputComponents(), \n @ref GL::Shader::maxTessellationControlInputComponents(), \n @ref GL::Shader::maxTessellationControlOutputComponents(), \n @ref GL::Shader::maxTessellationControlTotalOutputComponents(), \n @ref GL::Shader::maxTessellationEvaluationInputComponents(), \n @ref GL::Shader::maxTessellationEvaluationOutputComponents(), \n @ref GL::Shader::maxVertexOutputComponents() -@def_gl{MAX_GEOMETRY_OUTPUT_VERTICES} | | +@def_gl{MAX_GEOMETRY_OUTPUT_VERTICES} | @ref GL::AbstractShaderProgram::maxGeometryOutputVertices() @def_gl{MAX_GEOMETRY_SHADER_INVOCATIONS} | | @def_gl{MAX_IMAGE_SAMPLES} | @ref GL::AbstractShaderProgram::maxImageSamples() @def_gl{MAX_IMAGE_UNITS} | @ref GL::AbstractShaderProgram::maxImageUnits() diff --git a/src/Magnum/GL/AbstractShaderProgram.cpp b/src/Magnum/GL/AbstractShaderProgram.cpp index e7f8676e3..7324b0454 100644 --- a/src/Magnum/GL/AbstractShaderProgram.cpp +++ b/src/Magnum/GL/AbstractShaderProgram.cpp @@ -62,6 +62,23 @@ Int AbstractShaderProgram::maxVertexAttributes() { } #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +Int AbstractShaderProgram::maxGeometryOutputVertices() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + return 0; + #else + if(!Context::current().isExtensionSupported()) + return 0; + #endif + + GLint& value = Context::current().state().shaderProgram->maxGeometryOutputVertices; + + if(value == 0) + glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &value); + + return value; +} + Int AbstractShaderProgram::maxAtomicCounterBufferSize() { #ifndef MAGNUM_TARGET_GLES if(!Context::current().isExtensionSupported()) diff --git a/src/Magnum/GL/AbstractShaderProgram.h b/src/Magnum/GL/AbstractShaderProgram.h index 0b56733bd..3b20fcb16 100644 --- a/src/Magnum/GL/AbstractShaderProgram.h +++ b/src/Magnum/GL/AbstractShaderProgram.h @@ -462,6 +462,21 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject { static Int maxVertexAttributes(); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /** + * @brief Max supported count of vertices emitted by a geometry shader + * @m_since_latest + * + * The result is cached, repeated queries don't result in repeated + * OpenGL calls. If neither @gl_extension{ARB,geometry_shader4} (part of + * OpenGL 3.2) nor @gl_extension{ANDROID,extension_pack_es31a} / + * @gl_extension{EXT,geometry_shader} (part of OpenGL ES 3.2) is not + * available, returns @cpp 0 @ce. + * @see @fn_gl{Get} with @def_gl_keyword{MAX_GEOMETRY_OUTPUT_VERTICES} + * @requires_gles30 Not defined in OpenGL ES 2.0. + * @requires_gles Geometry shaders are not available in WebGL. + */ + static Int maxGeometryOutputVertices(); + /** * @brief Max supported atomic counter buffer size * diff --git a/src/Magnum/GL/Implementation/ShaderProgramState.cpp b/src/Magnum/GL/Implementation/ShaderProgramState.cpp index e2d091aba..b60bc0d65 100644 --- a/src/Magnum/GL/Implementation/ShaderProgramState.cpp +++ b/src/Magnum/GL/Implementation/ShaderProgramState.cpp @@ -36,7 +36,7 @@ namespace Magnum { namespace GL { namespace Implementation { ShaderProgramState::ShaderProgramState(Context& context, std::vector& extensions): current(0), maxVertexAttributes(0) #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL - , maxAtomicCounterBufferSize(0), maxComputeSharedMemorySize(0), maxComputeWorkGroupInvocations(0), maxImageUnits(0), maxCombinedShaderOutputResources(0), maxUniformLocations(0) + , maxGeometryOutputVertices{0}, maxAtomicCounterBufferSize(0), maxComputeSharedMemorySize(0), maxComputeWorkGroupInvocations(0), maxImageUnits(0), maxCombinedShaderOutputResources(0), maxUniformLocations(0) #endif , minTexelOffset(0), maxTexelOffset(0), maxUniformBlockSize(0) #ifndef MAGNUM_TARGET_WEBGL diff --git a/src/Magnum/GL/Implementation/ShaderProgramState.h b/src/Magnum/GL/Implementation/ShaderProgramState.h index f654ac109..db66de808 100644 --- a/src/Magnum/GL/Implementation/ShaderProgramState.h +++ b/src/Magnum/GL/Implementation/ShaderProgramState.h @@ -97,7 +97,8 @@ struct ShaderProgramState { GLint maxVertexAttributes; #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL - GLint maxAtomicCounterBufferSize, + GLint maxGeometryOutputVertices, + maxAtomicCounterBufferSize, maxComputeSharedMemorySize, maxComputeWorkGroupInvocations, maxImageUnits, diff --git a/src/Magnum/Platform/gl-info.cpp b/src/Magnum/Platform/gl-info.cpp index c7920d1c2..f470fa8e0 100644 --- a/src/Magnum/Platform/gl-info.cpp +++ b/src/Magnum/Platform/gl-info.cpp @@ -687,6 +687,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _h(EXT::geometry_shader) #endif + _l(GL::AbstractShaderProgram::maxGeometryOutputVertices()) _l(GL::Shader::maxGeometryInputComponents()) _l(GL::Shader::maxGeometryOutputComponents()) _l(GL::Shader::maxGeometryTotalOutputComponents())