Browse Source

Warn about improper Buffer target hint in NaCl.

Slightly eases up the porting.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
4c1f226544
  1. 5
      doc/best-practices.dox
  2. 15
      src/Mesh.cpp

5
doc/best-practices.dox

@ -57,11 +57,14 @@ information.
As noted in the above link, buffers in NaCl implementation need to be bound
only to one unique target, i.e., Buffer bound to @ref Buffer::Target "Target::Array"
cannot be later rebound to @ref Buffer::Target "Target::Element". However,
cannot be later rebound to @ref Buffer::Target "Target::ElementArray". However,
%Magnum by default uses any sufficient target when binding the buffer
internally (e.g. for setting data or copying). To avoid this, set target hint
to desired target, either in constructor or using Buffer::setTargetHint().
To ease up the development, @ref Mesh checks proper target hint when adding
vertex and index buffers.
@subsection best-practices-powervr PowerVR hardware
- [PowerVR Performance Recommendations](http://www.imgtec.com/powervr/insider/docs/PowerVR.Performance%20Recommendations.1.0.28.External.pdf) [PDF]

15
src/Mesh.cpp

@ -118,6 +118,11 @@ Mesh& Mesh::operator=(Mesh&& other) {
}
Mesh* Mesh::setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end) {
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(buffer->targetHint() == Buffer::Target::ElementArray,
"Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer->targetHint(), this);
#endif
indexOffset = offset;
indexType = type;
#ifndef MAGNUM_TARGET_GLES2
@ -235,10 +240,20 @@ void Mesh::destroyImplementationVAO() {
}
void Mesh::attributePointerImplementationDefault(const Attribute& attribute) {
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array,
"Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), );
#endif
attributes.push_back(attribute);
}
void Mesh::attributePointerImplementationVAO(const Attribute& attribute) {
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array,
"Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), );
#endif
bindVAO(vao);
vertexAttribPointer(attribute);
}

Loading…
Cancel
Save