Browse Source

GL: make use of ARB_DSA in Mesh internals.

Last holdout of EXT_DSA is gone. I'm not even preserving the EXT_DSA
docs anymore. Now let's take the trash out.
pull/331/head
Vladimír Vondruš 7 years ago
parent
commit
21b2cac953
  1. 6
      doc/changelog.dox
  2. 37
      src/Magnum/GL/Implementation/MeshState.cpp
  3. 39
      src/Magnum/GL/Mesh.cpp
  4. 25
      src/Magnum/GL/Mesh.h

6
doc/changelog.dox

@ -124,6 +124,12 @@ See also:
- @ref DebugTools::textureSubImage() for float textures was updated to work - @ref DebugTools::textureSubImage() for float textures was updated to work
with SwiftShader (which has broken @glsl gl_VertexID @ce) with SwiftShader (which has broken @glsl gl_VertexID @ce)
@subsubsection changelog-latest-changes-gl GL library
- Reworked @ref GL::Mesh internals to make use of
@gl_extension{ARB,direct_state_access} instead of being the last code path
stuck on @gl_extension{EXT,direct_state_access}
@subsubsection changelog-latest-changes-math Math library @subsubsection changelog-latest-changes-math Math library
- @ref Math::BoolVector now implements component-wise @cpp && @ce, - @ref Math::BoolVector now implements component-wise @cpp && @ce,

37
src/Magnum/GL/Implementation/MeshState.cpp

@ -53,24 +53,31 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector<s
extensions.push_back(Extensions::OES::vertex_array_object::string()); extensions.push_back(Extensions::OES::vertex_array_object::string());
#endif #endif
createImplementation = &Mesh::createImplementationVAO;
moveConstructImplementation = &Mesh::moveConstructImplementationVAO;
moveAssignImplementation = &Mesh::moveAssignImplementationVAO;
destroyImplementation = &Mesh::destroyImplementationVAO;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(context.isExtensionSupported<Extensions::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::ARB::direct_state_access>()) {
extensions.emplace_back(Extensions::ARB::direct_state_access::string());
createImplementation = &Mesh::createImplementationVAODSA;
attributePointerImplementation = &Mesh::attributePointerImplementationVAODSA;
bindIndexBufferImplementation = &Mesh::bindIndexBufferImplementationVAODSA;
} else if(context.isExtensionSupported<Extensions::EXT::direct_state_access>()) {
extensions.emplace_back(Extensions::EXT::direct_state_access::string()); extensions.emplace_back(Extensions::EXT::direct_state_access::string());
attributePointerImplementation = &Mesh::attributePointerImplementationDSAEXT; createImplementation = &Mesh::createImplementationVAO;
attributePointerImplementation = &Mesh::attributePointerImplementationVAODSAEXT;
bindIndexBufferImplementation = &Mesh::bindIndexBufferImplementationVAO;
} else } else
#endif #endif
{ {
createImplementation = &Mesh::createImplementationVAO;
attributePointerImplementation = &Mesh::attributePointerImplementationVAO; attributePointerImplementation = &Mesh::attributePointerImplementationVAO;
bindIndexBufferImplementation = &Mesh::bindIndexBufferImplementationVAO;
} }
moveConstructImplementation = &Mesh::moveConstructImplementationVAO;
moveAssignImplementation = &Mesh::moveAssignImplementationVAO;
destroyImplementation = &Mesh::destroyImplementationVAO;
acquireVertexBufferImplementation = &Mesh::acquireVertexBufferImplementationVAO; acquireVertexBufferImplementation = &Mesh::acquireVertexBufferImplementationVAO;
bindIndexBufferImplementation = &Mesh::bindIndexBufferImplementationVAO;
bindVAOImplementation = &Mesh::bindVAOImplementationVAO; bindVAOImplementation = &Mesh::bindVAOImplementationVAO;
bindImplementation = &Mesh::bindImplementationVAO; bindImplementation = &Mesh::bindImplementationVAO;
unbindImplementation = &Mesh::unbindImplementationVAO; unbindImplementation = &Mesh::unbindImplementationVAO;
@ -90,14 +97,6 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector<s
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES
/* DSA create implementation (other cases handled above) */
if(context.isExtensionSupported<Extensions::ARB::direct_state_access>() && context.isExtensionSupported<Extensions::ARB::vertex_array_object>()) {
extensions.emplace_back(Extensions::ARB::direct_state_access::string());
createImplementation = &Mesh::createImplementationVAODSA;
}
#endif
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
/* Multi draw implementation on ES */ /* Multi draw implementation on ES */
@ -147,9 +146,11 @@ MeshState::MeshState(Context& context, ContextState& contextState, std::vector<s
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/* Partial EXT_DSA implementation of vertex attrib divisor */ /* Partial EXT_DSA implementation of vertex attrib divisor */
if(context.isExtensionSupported<Extensions::EXT::direct_state_access>()) { if(context.isExtensionSupported<Extensions::ARB::direct_state_access>()) {
vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationVAODSA;
} else if(context.isExtensionSupported<Extensions::EXT::direct_state_access>()) {
if(glVertexArrayVertexAttribDivisorEXT) if(glVertexArrayVertexAttribDivisorEXT)
vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationDSAEXT; vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationVAODSAEXT;
else vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationVAO; else vertexAttribDivisorImplementation = &Mesh::vertexAttribDivisorImplementationVAO;
} else vertexAttribDivisorImplementation = nullptr; } else vertexAttribDivisorImplementation = nullptr;
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)

39
src/Magnum/GL/Mesh.cpp

@ -688,7 +688,33 @@ void Mesh::attributePointerImplementationVAO(AttributeLayout&& attribute) {
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void Mesh::attributePointerImplementationDSAEXT(AttributeLayout&& attribute) { void Mesh::attributePointerImplementationVAODSA(AttributeLayout&& attribute) {
_flags |= ObjectFlag::Created;
glEnableVertexArrayAttrib(_id, attribute.location);
#ifndef MAGNUM_TARGET_GLES2
if(attribute.kind == DynamicAttribute::Kind::Integral)
glVertexArrayAttribIFormat(_id, attribute.location, attribute.size, attribute.type, 0);
#ifndef MAGNUM_TARGET_GLES
else if(attribute.kind == DynamicAttribute::Kind::Long)
glVertexArrayAttribLFormat(_id, attribute.location, attribute.size, attribute.type, 0);
#endif
else
#endif
{
glVertexArrayAttribFormat(_id, attribute.location, attribute.size, attribute.type, attribute.kind == DynamicAttribute::Kind::GenericNormalized, 0);
}
glVertexArrayAttribBinding(_id, attribute.location, attribute.location);
CORRADE_INTERNAL_ASSERT(attribute.stride != 0);
glVertexArrayVertexBuffer(_id, attribute.location, attribute.buffer.id(), attribute.offset, attribute.stride);
if(attribute.divisor)
(this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor);
}
void Mesh::attributePointerImplementationVAODSAEXT(AttributeLayout&& attribute) {
_flags |= ObjectFlag::Created; _flags |= ObjectFlag::Created;
glEnableVertexArrayAttribEXT(_id, attribute.location); glEnableVertexArrayAttribEXT(_id, attribute.location);
@ -741,7 +767,10 @@ void Mesh::vertexAttribDivisorImplementationVAO(const GLuint index, const GLuint
bindVAO(); bindVAO();
glVertexAttribDivisor(index, divisor); glVertexAttribDivisor(index, divisor);
} }
void Mesh::vertexAttribDivisorImplementationDSAEXT(const GLuint index, const GLuint divisor) { void Mesh::vertexAttribDivisorImplementationVAODSA(const GLuint index, const GLuint divisor) {
glVertexArrayBindingDivisor(_id, index, divisor);
}
void Mesh::vertexAttribDivisorImplementationVAODSAEXT(const GLuint index, const GLuint divisor) {
glVertexArrayVertexAttribDivisorEXT(_id, index, divisor); glVertexArrayVertexAttribDivisorEXT(_id, index, divisor);
} }
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
@ -787,6 +816,12 @@ void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) {
buffer.bindInternal(Buffer::TargetHint::ElementArray); buffer.bindInternal(Buffer::TargetHint::ElementArray);
} }
#ifndef MAGNUM_TARGET_GLES
void Mesh::bindIndexBufferImplementationVAODSA(Buffer& buffer) {
glVertexArrayElementBuffer(_id, buffer.id());
}
#endif
void Mesh::bindImplementationDefault() { void Mesh::bindImplementationDefault() {
/* Specify vertex attributes */ /* Specify vertex attributes */
for(AttributeLayout& attribute: *reinterpret_cast<std::vector<AttributeLayout>*>(&_attributes)) for(AttributeLayout& attribute: *reinterpret_cast<std::vector<AttributeLayout>*>(&_attributes))

25
src/Magnum/GL/Mesh.h

@ -280,7 +280,7 @@ and @fn_gl_keyword{UseProgram}. Mesh limits and implementation-defined values
(such as @ref maxElementIndex()) are cached, so repeated queries don't result (such as @ref maxElementIndex()) are cached, so repeated queries don't result
in repeated @fn_gl{Get} calls. in repeated @fn_gl{Get} calls.
If @gl_extension{EXT,direct_state_access} desktop extension and VAOs are If @gl_extension{ARB,direct_state_access} desktop extension and VAOs are
available, DSA functions are used for specifying attribute locations to avoid available, DSA functions are used for specifying attribute locations to avoid
unnecessary calls to @fn_gl{BindBuffer} and @fn_gl{BindVertexArray}. See unnecessary calls to @fn_gl{BindBuffer} and @fn_gl{BindVertexArray}. See
documentation of @ref addVertexBuffer() for more information. documentation of @ref addVertexBuffer() for more information.
@ -699,8 +699,10 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
* @ref setCount(), @fn_gl_keyword{BindVertexArray}, * @ref setCount(), @fn_gl_keyword{BindVertexArray},
* @fn_gl_keyword{EnableVertexAttribArray}, @fn_gl{BindBuffer}, * @fn_gl_keyword{EnableVertexAttribArray}, @fn_gl{BindBuffer},
* @fn_gl_keyword{VertexAttribPointer} or * @fn_gl_keyword{VertexAttribPointer} or
* @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl2{EnableVertexArrayAttrib,EnableVertexAttribArray},
* @fn_gl_extension_keyword{VertexArrayVertexAttribOffset,EXT,direct_state_access} * @fn_gl2{VertexArrayAttribFormat,VertexAttribFormat},
* @fn_gl2{VertexArrayAttribBinding,VertexAttribBinding} and
* @fn_gl2{VertexArrayVertexBuffer,BindVertexBuffer}
* @requires_gles In WebGL the data must be properly aligned (e.g. all * @requires_gles In WebGL the data must be properly aligned (e.g. all
* float data must start at addresses divisible by four). Also the * float data must start at addresses divisible by four). Also the
* maximum stride of attribute data must be at most 255 bytes. * maximum stride of attribute data must be at most 255 bytes.
@ -731,9 +733,11 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
* @fn_gl{BindVertexArray}, @fn_gl_keyword{EnableVertexAttribArray}, * @fn_gl{BindVertexArray}, @fn_gl_keyword{EnableVertexAttribArray},
* @fn_gl{BindBuffer}, @fn_gl_keyword{VertexAttribPointer}, * @fn_gl{BindBuffer}, @fn_gl_keyword{VertexAttribPointer},
* @fn_gl_keyword{VertexAttribDivisor} or * @fn_gl_keyword{VertexAttribDivisor} or
* @fn_gl_extension_keyword{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl2{EnableVertexArrayAttrib,EnableVertexAttribArray},
* @fn_gl_extension_keyword{VertexArrayVertexAttribOffset,EXT,direct_state_access}, * @fn_gl2{VertexArrayAttribFormat,VertexAttribFormat},
* @fn_gl_extension_keyword{VertexArrayVertexAttribDivisor,EXT,direct_state_access} * @fn_gl2{VertexArrayAttribBinding,VertexAttribBinding},
* @fn_gl2{VertexArrayVertexBuffer,BindVertexBuffer} and
* @fn_gl2{VertexArrayBindingDivisor,VertexBindingDivisor}
* @requires_gl33 Extension @gl_extension{ARB,instanced_arrays} * @requires_gl33 Extension @gl_extension{ARB,instanced_arrays}
* @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays}, * @requires_gles30 Extension @gl_extension{ANGLE,instanced_arrays},
* @gl_extension{EXT,instanced_arrays} or * @gl_extension{EXT,instanced_arrays} or
@ -1107,13 +1111,15 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
void MAGNUM_GL_LOCAL attributePointerImplementationDefault(AttributeLayout&& attribute); void MAGNUM_GL_LOCAL attributePointerImplementationDefault(AttributeLayout&& attribute);
void MAGNUM_GL_LOCAL attributePointerImplementationVAO(AttributeLayout&& attribute); void MAGNUM_GL_LOCAL attributePointerImplementationVAO(AttributeLayout&& attribute);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL attributePointerImplementationDSAEXT(AttributeLayout&& attribute); void MAGNUM_GL_LOCAL attributePointerImplementationVAODSA(AttributeLayout&& attribute);
void MAGNUM_GL_LOCAL attributePointerImplementationVAODSAEXT(AttributeLayout&& attribute);
#endif #endif
void MAGNUM_GL_LOCAL vertexAttribPointer(AttributeLayout& attribute); void MAGNUM_GL_LOCAL vertexAttribPointer(AttributeLayout& attribute);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAO(GLuint index, GLuint divisor); void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAO(GLuint index, GLuint divisor);
void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationDSAEXT(GLuint index, GLuint divisor); void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAODSA(GLuint index, GLuint divisor);
void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationVAODSAEXT(GLuint index, GLuint divisor);
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationANGLE(GLuint index, GLuint divisor); void MAGNUM_GL_LOCAL vertexAttribDivisorImplementationANGLE(GLuint index, GLuint divisor);
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
@ -1128,6 +1134,9 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
void MAGNUM_GL_LOCAL bindIndexBufferImplementationDefault(Buffer&); void MAGNUM_GL_LOCAL bindIndexBufferImplementationDefault(Buffer&);
void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAO(Buffer& buffer); void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAO(Buffer& buffer);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL bindIndexBufferImplementationVAODSA(Buffer& buffer);
#endif
void MAGNUM_GL_LOCAL bindImplementationDefault(); void MAGNUM_GL_LOCAL bindImplementationDefault();
void MAGNUM_GL_LOCAL bindImplementationVAO(); void MAGNUM_GL_LOCAL bindImplementationVAO();

Loading…
Cancel
Save