diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2017-09-13 11:21:33 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-09-22 09:42:50 +0000 |
commit | 3ae0aa042214321c3378e87c1edc490cfc4a2758 (patch) | |
tree | 7f6929f1f54660b02a7f55c253867ba23bbfe0cb /src | |
parent | 208ed2c5f160ea05c92acf4ad4ea54496caaef80 (diff) |
Rely on the attribute type for the binding point
Stop reading the buffer type from the buffer object and instead use the
attribute type to determine the binding point.
Change-Id: I95856776297252c6e332f842c2b5362d1467e420
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/graphicshelpers/graphicscontext.cpp | 22 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicscontext_p.h | 2 |
2 files changed, 8 insertions, 16 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 0eb37e789..814429504 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -120,22 +120,14 @@ static void logOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage) namespace { -GLBuffer::Type bufferTypeToGLBufferType(QBuffer::BufferType type) +GLBuffer::Type attributeTypeToGLBufferType(QAttribute::AttributeType type) { switch (type) { - case QBuffer::VertexBuffer: + case QAttribute::VertexAttribute: return GLBuffer::ArrayBuffer; - case QBuffer::IndexBuffer: + case QAttribute::IndexAttribute: return GLBuffer::IndexBuffer; - case QBuffer::PixelPackBuffer: - return GLBuffer::PixelPackBuffer; - case QBuffer::PixelUnpackBuffer: - return GLBuffer::PixelUnpackBuffer; - case QBuffer::UniformBuffer: - return GLBuffer::UniformBuffer; - case QBuffer::ShaderStorageBuffer: - return GLBuffer::ShaderStorageBuffer; - case QBuffer::DrawIndirectBuffer: + case QAttribute::DrawIndirectAttribute: return GLBuffer::DrawIndirectBuffer; default: Q_UNREACHABLE(); @@ -1287,7 +1279,7 @@ void GraphicsContext::enableAttribute(const VAOVertexAttribute &attr) // Bind buffer within the current VAO GLBuffer *buf = m_renderer->nodeManagers()->glBufferManager()->data(attr.bufferHandle); Q_ASSERT(buf); - bindGLBuffer(buf, attr.bufferType); + bindGLBuffer(buf, attr.attributeType); // Don't use QOpenGLShaderProgram::setAttributeBuffer() because of QTBUG-43199. // Use the introspection data and set the attribute explicitly @@ -1437,7 +1429,7 @@ void GraphicsContext::specifyAttribute(const Attribute *attribute, const GLint attributeDataType = glDataTypeFromAttributeDataType(attribute->vertexBaseType()); const HGLBuffer glBufferHandle = m_renderer->nodeManagers()->glBufferManager()->lookupHandle(buffer->peerId()); Q_ASSERT(!glBufferHandle.isNull()); - const GLBuffer::Type bufferType = bufferTypeToGLBufferType(buffer->type()); + const GLBuffer::Type attributeType = attributeTypeToGLBufferType(attribute->attributeType()); int typeSize = 0; int attrCount = 0; @@ -1457,7 +1449,7 @@ void GraphicsContext::specifyAttribute(const Attribute *attribute, for (int i = 0; i < attrCount; i++) { VAOVertexAttribute attr; attr.bufferHandle = glBufferHandle; - attr.bufferType = bufferType; + attr.attributeType = attributeType; attr.location = location + i; attr.dataType = attributeDataType; attr.byteOffset = attribute->byteOffset() + (i * attrCount * typeSize); diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h index 6e5ab8520..1b9438a6f 100644 --- a/src/render/graphicshelpers/graphicscontext_p.h +++ b/src/render/graphicshelpers/graphicscontext_p.h @@ -331,7 +331,7 @@ private: struct VAOVertexAttribute { HGLBuffer bufferHandle; - GLBuffer::Type bufferType; + GLBuffer::Type attributeType; int location; GLint dataType; uint byteOffset; |