Browse Source

GL: adapt Buffer/TransformFeedback to use ArrayView.

pull/594/head
Hugo Amiard 4 years ago committed by Vladimír Vondruš
parent
commit
62363094ae
  1. 8
      src/Magnum/GL/Buffer.cpp
  2. 18
      src/Magnum/GL/Buffer.h
  3. 4
      src/Magnum/GL/Implementation/TransformFeedbackState.h
  4. 18
      src/Magnum/GL/TransformFeedback.cpp
  5. 22
      src/Magnum/GL/TransformFeedback.h

8
src/Magnum/GL/Buffer.cpp

@ -151,13 +151,11 @@ void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std
Context::current().state().buffer.bindBasesImplementation(target, firstIndex, {nullptr, count});
}
/** @todoc const std::initializer_list makes Doxygen grumpy */
void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
void Buffer::bind(const Target target, const UnsignedInt firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
Context::current().state().buffer.bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()});
}
/** @todoc const std::initializer_list makes Doxygen grumpy */
void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
void Buffer::bind(const Target target, const UnsignedInt firstIndex, Containers::ArrayView<Buffer* const> buffers) {
Context::current().state().buffer.bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()});
}
@ -406,7 +404,6 @@ void Buffer::bindImplementationMulti(const Target target, const GLuint firstInde
}
#endif
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
void Buffer::bindImplementationFallback(const Target target, const GLuint firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
for(std::size_t i = 0; i != buffers.size(); ++i) {
if(buffers && std::get<0>(buffers[i]))
@ -416,7 +413,6 @@ void Buffer::bindImplementationFallback(const Target target, const GLuint firstI
}
#ifndef MAGNUM_TARGET_GLES
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
void Buffer::bindImplementationMulti(const Target target, const GLuint firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
/** @todo use ArrayTuple */
Containers::Array<GLuint> ids{buffers ? buffers.size() : 0};

18
src/Magnum/GL/Buffer.h

@ -766,7 +766,12 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/
static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
static void bind(Target target, UnsignedInt firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
/** @overload */
static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
return bind(target, firstIndex, Containers::arrayView(buffers));
}
/**
* @brief Bind buffers to given range of indexed targets
@ -796,7 +801,12 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
* WebGL 1.0, see particular @ref Target values for version
* requirements.
*/
static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers);
static void bind(Target target, UnsignedInt firstIndex, Containers::ArrayView<Buffer* const> buffers);
/** @overload */
static void bind(Target target, UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
return bind(target, firstIndex, Containers::arrayView(buffers));
}
/**
* @brief Copy one buffer to another
@ -1002,7 +1012,7 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
* @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation
* for more information.
* @see @ref bind(Target, UnsignedInt, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>>),
* @see @ref bind(Target, UnsignedInt, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>>),
* @ref maxAtomicCounterBindings(), @ref maxShaderStorageBindings(),
* @ref maxUniformBindings(), @ref shaderStorageOffsetAlignment(),
* @ref uniformOffsetAlignment(), @ref TransformFeedback::attachBuffer(),
@ -1028,7 +1038,7 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
* @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation
* for more information.
* @see @ref bind(Target, UnsignedInt, std::initializer_list<Buffer*>),
* @see @ref bind(Target, UnsignedInt, Containers::ArrayView<Buffer* const>),
* @ref maxAtomicCounterBindings(), @ref maxShaderStorageBindings(),
* @ref maxUniformBindings(), @ref TransformFeedback::attachBuffer(),
* @fn_gl_keyword{BindBufferBase}

4
src/Magnum/GL/Implementation/TransformFeedbackState.h

@ -63,8 +63,8 @@ struct TransformFeedbackState {
void(TransformFeedback::*createImplementation)();
void(TransformFeedback::*attachRangeImplementation)(GLuint, Buffer&, GLintptr, GLsizeiptr);
void(TransformFeedback::*attachBaseImplementation)(GLuint, Buffer&);
void(TransformFeedback::*attachRangesImplementation)(GLuint, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>>);
void(TransformFeedback::*attachBasesImplementation)(GLuint, std::initializer_list<Buffer*>);
void(TransformFeedback::*attachRangesImplementation)(GLuint, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>>);
void(TransformFeedback::*attachBasesImplementation)(GLuint, Containers::ArrayView<Buffer* const>);
};
}}}

18
src/Magnum/GL/TransformFeedback.cpp

@ -207,27 +207,23 @@ void TransformFeedback::attachImplementationDSA(const GLuint index, Buffer& buff
}
#endif
/** @todoc const std::initializer_list makes Doxygen grumpy */
TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
(this->*Context::current().state().transformFeedback.attachRangesImplementation)(firstIndex, buffers);
return *this;
}
/** @todoc const std::initializer_list makes Doxygen grumpy */
TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, Containers::ArrayView<Buffer* const> buffers) {
(this->*Context::current().state().transformFeedback.attachBasesImplementation)(firstIndex, buffers);
return *this;
}
/** @todoc const std::initializer_list makes Doxygen grumpy */
void TransformFeedback::attachImplementationFallback(const GLuint firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
void TransformFeedback::attachImplementationFallback(const GLuint firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
bindInternal();
Buffer::bind(Buffer::Target(GL_TRANSFORM_FEEDBACK_BUFFER), firstIndex, buffers);
}
#ifndef MAGNUM_TARGET_GLES
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
for(std::size_t i = 0; i != buffers.size(); ++i) {
Buffer* buffer;
GLintptr offset;
@ -239,15 +235,13 @@ void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, std::in
}
#endif
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
void TransformFeedback::attachImplementationFallback(const GLuint firstIndex, std::initializer_list<Buffer*> buffers) {
void TransformFeedback::attachImplementationFallback(const GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers) {
bindInternal();
Buffer::bind(Buffer::Target(GL_TRANSFORM_FEEDBACK_BUFFER), firstIndex, buffers);
}
#ifndef MAGNUM_TARGET_GLES
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, std::initializer_list<Buffer*> buffers) {
void TransformFeedback::attachImplementationDSA(const GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers) {
for(std::size_t i = 0; i != buffers.size(); ++i)
glTransformFeedbackBufferBase(_id, firstIndex + i, *(buffers.begin() + i) ? (*(buffers.begin() + i))->id() : 0);
}

22
src/Magnum/GL/TransformFeedback.h

@ -340,7 +340,12 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject {
* eventually @fn_gl{BindTransformFeedback} and
* @fn_gl_keyword{BindBuffersRange} or @fn_gl_keyword{BindBufferRange}
*/
TransformFeedback& attachBuffers(UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
TransformFeedback& attachBuffers(UnsignedInt firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
/** @overload */
TransformFeedback& attachBuffers(UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) {
return attachBuffers(firstIndex, Containers::arrayView(buffers));
}
/**
* @brief Attach buffers
@ -363,7 +368,12 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject {
* eventually @fn_gl{BindTransformFeedback} and
* @fn_gl_keyword{BindBuffersBase} or @fn_gl_keyword{BindBufferBase}
*/
TransformFeedback& attachBuffers(UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers);
TransformFeedback& attachBuffers(UnsignedInt firstIndex, Containers::ArrayView<Buffer* const> buffers);
/** @overload */
TransformFeedback& attachBuffers(UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) {
return attachBuffers(firstIndex, Containers::arrayView(buffers));
}
/**
* @brief Begin transform feedback
@ -429,11 +439,11 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject {
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint index, Buffer& buffer);
#endif
void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, std::initializer_list<Buffer*> buffers);
void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
void MAGNUM_GL_LOCAL attachImplementationFallback(GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, std::initializer_list<Buffer*> buffers);
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, Containers::ArrayView<const std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers);
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, Containers::ArrayView<Buffer* const> buffers);
#endif
GLuint _id;

Loading…
Cancel
Save