Browse Source

GL: add a GL::AbstractShaderProgram::maxGeometryOutputVertices() query.

pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
dd07145fa2
  1. 3
      doc/changelog.dox
  2. 2
      doc/opengl-mapping.dox
  3. 17
      src/Magnum/GL/AbstractShaderProgram.cpp
  4. 15
      src/Magnum/GL/AbstractShaderProgram.h
  5. 2
      src/Magnum/GL/Implementation/ShaderProgramState.cpp
  6. 3
      src/Magnum/GL/Implementation/ShaderProgramState.h
  7. 1
      src/Magnum/Platform/gl-info.cpp

3
doc/changelog.dox

@ -106,7 +106,8 @@ See also:
more information.
- New @ref GL::Buffer::Buffer(Containers::ArrayView<const void>, 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

2
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()

17
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<Extensions::ARB::geometry_shader4>())
return 0;
#else
if(!Context::current().isExtensionSupported<Extensions::EXT::geometry_shader>())
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<Extensions::ARB::shader_atomic_counters>())

15
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
*

2
src/Magnum/GL/Implementation/ShaderProgramState.cpp

@ -36,7 +36,7 @@ namespace Magnum { namespace GL { namespace Implementation {
ShaderProgramState::ShaderProgramState(Context& context, std::vector<std::string>& 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

3
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,

1
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())

Loading…
Cancel
Save