Commit cf0e85b5 by Nicolas Capens

Fix avoiding VBO use in glDrawTex().

The glDrawTex() implementation intends to use vertex array pointers, so set the array buffer to null to prevent it from taking precedence. Also save/restore projection and modelview matrices. Bug 23021204 Change-Id: I6b3e59d737a9b75180e6f03e9a686871640f7edd Reviewed-on: https://swiftshader-review.googlesource.com/3880Tested-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent a0355b74
......@@ -24,6 +24,11 @@ namespace sw
stack[top] = 1;
}
void MatrixStack::load(const Matrix &M)
{
stack[top] = M;
}
void MatrixStack::load(const float *M)
{
stack[top] = Matrix(M[0], M[4], M[8], M[12],
......
#ifndef OpenGL32_MatrixStack_hpp
#define OpenGL32_MatrixStack_hpp
#ifndef sw_MatrixStack_hpp
#define sw_MatrixStack_hpp
#include "Renderer/Matrix.hpp"
......@@ -13,6 +13,7 @@ namespace sw
~MatrixStack();
void identity();
void load(const Matrix &M);
void load(const float *M);
void load(const double *M);
......@@ -41,4 +42,4 @@ namespace sw
};
}
#endif // OpenGL32_MatrixStack_hpp
#endif // sw_MatrixStack_hpp
......@@ -51,7 +51,15 @@ class BindingPointer
public:
BindingPointer() : object(nullptr) { }
~BindingPointer() { ASSERT(!object); } // Objects have to be released before the resource manager is destroyed, so they must be explicitly cleaned up.
BindingPointer(const BindingPointer<ObjectType> &other) : object(nullptr)
{
operator=(other.object);
}
~BindingPointer()
{
ASSERT(!object); // Objects have to be released before the resource manager is destroyed, so they must be explicitly cleaned up. Assign null to all binding pointers to make the reference count go to zero.
}
ObjectType *operator=(ObjectType *newObject)
{
......@@ -62,6 +70,12 @@ public:
return object;
}
ObjectType *operator=(const BindingPointer<ObjectType> &other)
{
return operator=(other.object);
}
operator ObjectType*() const { return object; }
ObjectType *operator->() const { return object; }
GLuint name() const { return object ? object->name : 0; }
......
......@@ -2810,21 +2810,34 @@ void Context::drawTexture(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloa
VertexAttribute oldPositionAttribute = mState.vertexAttribute[sw::Position];
VertexAttribute oldTexCoord0Attribute = mState.vertexAttribute[sw::TexCoord0];
gl::BindingPointer<Buffer> oldArrayBuffer = mState.arrayBuffer;
mState.arrayBuffer = nullptr;
glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(float), texCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
textureStack0.push();
textureStack0.identity(); // Disable texture coordinate transformation
sw::Matrix P = projectionStack.current();
sw::Matrix M = modelViewStack.current();
sw::Matrix T = textureStack0.current();
projectionStack.identity();
modelViewStack.identity();
textureStack0.identity();
drawArrays(GL_TRIANGLE_STRIP, 0, 4);
// Restore state
mState.vertexAttribute[sw::Position] = oldPositionAttribute;
mState.vertexAttribute[sw::TexCoord0] = oldTexCoord0Attribute;
textureStack0.pop();
mState.arrayBuffer = oldArrayBuffer;
oldArrayBuffer = nullptr;
oldPositionAttribute.mBoundBuffer = nullptr;
oldTexCoord0Attribute.mBoundBuffer = nullptr;
textureStack0.load(T);
modelViewStack.load(M);
projectionStack.load(P);
}
void Context::finish()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment