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/3880
Tested-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/common/MatrixStack.cpp b/src/OpenGL/common/MatrixStack.cpp
index 8d6c3b4..0cfcf74 100644
--- a/src/OpenGL/common/MatrixStack.cpp
+++ b/src/OpenGL/common/MatrixStack.cpp
@@ -24,6 +24,11 @@
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],
diff --git a/src/OpenGL/common/MatrixStack.hpp b/src/OpenGL/common/MatrixStack.hpp
index 56ac43b..eb2c1a1 100644
--- a/src/OpenGL/common/MatrixStack.hpp
+++ b/src/OpenGL/common/MatrixStack.hpp
@@ -1,5 +1,5 @@
-#ifndef OpenGL32_MatrixStack_hpp
-#define OpenGL32_MatrixStack_hpp
+#ifndef sw_MatrixStack_hpp
+#define sw_MatrixStack_hpp
#include "Renderer/Matrix.hpp"
@@ -13,6 +13,7 @@
~MatrixStack();
void identity();
+ void load(const Matrix &M);
void load(const float *M);
void load(const double *M);
@@ -41,4 +42,4 @@
};
}
-#endif // OpenGL32_MatrixStack_hpp
+#endif // sw_MatrixStack_hpp
diff --git a/src/OpenGL/common/Object.hpp b/src/OpenGL/common/Object.hpp
index 8c8ee7c..14b2975 100644
--- a/src/OpenGL/common/Object.hpp
+++ b/src/OpenGL/common/Object.hpp
@@ -51,7 +51,15 @@
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 @@
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; }
diff --git a/src/OpenGL/libGLES_CM/Context.cpp b/src/OpenGL/libGLES_CM/Context.cpp
index 1574f97..32c0cb5 100644
--- a/src/OpenGL/libGLES_CM/Context.cpp
+++ b/src/OpenGL/libGLES_CM/Context.cpp
@@ -2810,21 +2810,34 @@
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()