Commit d7576737 by Jamie Madill Committed by Commit Bot

Refactor VAO entry points.

This also touches the extension EPs for ES2. BUG=angleproject:747 Change-Id: Iaa04d97465e518f6b0496e64bc7a737914709b8f Reviewed-on: https://chromium-review.googlesource.com/637124Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent c8c95817
...@@ -624,13 +624,6 @@ GLuint Context::createPaths(GLsizei range) ...@@ -624,13 +624,6 @@ GLuint Context::createPaths(GLsizei range)
return resultOrError.getResult(); return resultOrError.getResult();
} }
GLuint Context::createVertexArray()
{
GLuint vertexArray = mVertexArrayHandleAllocator.allocate();
mVertexArrayMap.assign(vertexArray, nullptr);
return vertexArray;
}
GLuint Context::createSampler() GLuint Context::createSampler()
{ {
return mState.mSamplers->createSampler(); return mState.mSamplers->createSampler();
...@@ -796,21 +789,6 @@ void Context::setPathStencilFunc(GLenum func, GLint ref, GLuint mask) ...@@ -796,21 +789,6 @@ void Context::setPathStencilFunc(GLenum func, GLint ref, GLuint mask)
mGLState.setPathStencilFunc(func, ref, mask); mGLState.setPathStencilFunc(func, ref, mask);
} }
void Context::deleteVertexArray(GLuint vertexArray)
{
VertexArray *vertexArrayObject = nullptr;
if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject))
{
if (vertexArrayObject != nullptr)
{
detachVertexArray(vertexArray);
vertexArrayObject->onDestroy(this);
}
mVertexArrayHandleAllocator.release(vertexArray);
}
}
void Context::deleteSampler(GLuint sampler) void Context::deleteSampler(GLuint sampler)
{ {
if (mState.mSamplers->getSampler(sampler)) if (mState.mSamplers->getSampler(sampler))
...@@ -5010,4 +4988,48 @@ void Context::uniformMatrix4x3fv(GLint location, ...@@ -5010,4 +4988,48 @@ void Context::uniformMatrix4x3fv(GLint location,
program->setUniformMatrix4x3fv(location, count, transpose, value); program->setUniformMatrix4x3fv(location, count, transpose, value);
} }
void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays)
{
for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
{
GLuint vertexArray = arrays[arrayIndex];
if (arrays[arrayIndex] != 0)
{
VertexArray *vertexArrayObject = nullptr;
if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject))
{
if (vertexArrayObject != nullptr)
{
detachVertexArray(vertexArray);
vertexArrayObject->onDestroy(this);
}
mVertexArrayHandleAllocator.release(vertexArray);
}
}
}
}
void Context::genVertexArrays(GLsizei n, GLuint *arrays)
{
for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
{
GLuint vertexArray = mVertexArrayHandleAllocator.allocate();
mVertexArrayMap.assign(vertexArray, nullptr);
arrays[arrayIndex] = vertexArray;
}
}
bool Context::isVertexArray(GLuint array)
{
if (array == 0)
{
return GL_FALSE;
}
VertexArray *vao = getVertexArray(array);
return (vao != nullptr ? GL_TRUE : GL_FALSE);
}
} // namespace gl } // namespace gl
...@@ -120,10 +120,6 @@ class Context final : public ValidationContext ...@@ -120,10 +120,6 @@ class Context final : public ValidationContext
GLuint createFenceNV(); GLuint createFenceNV();
void deleteFenceNV(GLuint fence); void deleteFenceNV(GLuint fence);
// Vertex arrays are owned by the Context
GLuint createVertexArray();
void deleteVertexArray(GLuint vertexArray);
void bindArrayBuffer(GLuint bufferHandle); void bindArrayBuffer(GLuint bufferHandle);
void bindElementArrayBuffer(GLuint bufferHandle); void bindElementArrayBuffer(GLuint bufferHandle);
void bindTexture(GLenum target, GLuint handle); void bindTexture(GLenum target, GLuint handle);
...@@ -814,6 +810,10 @@ class Context final : public ValidationContext ...@@ -814,6 +810,10 @@ class Context final : public ValidationContext
GLboolean transpose, GLboolean transpose,
const GLfloat *value); const GLfloat *value);
void deleteVertexArrays(GLsizei n, const GLuint *arrays);
void genVertexArrays(GLsizei n, GLuint *arrays);
bool isVertexArray(GLuint array);
void getProgramBinary(GLuint program, void getProgramBinary(GLuint program,
GLsizei bufSize, GLsizei bufSize,
GLsizei *length, GLsizei *length,
......
...@@ -1765,7 +1765,7 @@ bool ValidateBindVertexArrayOES(Context *context, GLuint array) ...@@ -1765,7 +1765,7 @@ bool ValidateBindVertexArrayOES(Context *context, GLuint array)
return ValidateBindVertexArrayBase(context, array); return ValidateBindVertexArrayBase(context, array);
} }
bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n) bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n, const GLuint *arrays)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
...@@ -1776,7 +1776,7 @@ bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n) ...@@ -1776,7 +1776,7 @@ bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n)
return ValidateGenOrDelete(context, n); return ValidateGenOrDelete(context, n);
} }
bool ValidateGenVertexArraysOES(Context *context, GLsizei n) bool ValidateGenVertexArraysOES(Context *context, GLsizei n, GLuint *arrays)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
...@@ -1787,7 +1787,7 @@ bool ValidateGenVertexArraysOES(Context *context, GLsizei n) ...@@ -1787,7 +1787,7 @@ bool ValidateGenVertexArraysOES(Context *context, GLsizei n)
return ValidateGenOrDelete(context, n); return ValidateGenOrDelete(context, n);
} }
bool ValidateIsVertexArrayOES(Context *context) bool ValidateIsVertexArrayOES(Context *context, GLuint array)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
......
...@@ -32,9 +32,9 @@ bool ValidateDiscardFramebufferEXT(Context *context, ...@@ -32,9 +32,9 @@ bool ValidateDiscardFramebufferEXT(Context *context,
bool ValidateDrawBuffersEXT(ValidationContext *context, GLsizei n, const GLenum *bufs); bool ValidateDrawBuffersEXT(ValidationContext *context, GLsizei n, const GLenum *bufs);
bool ValidateBindVertexArrayOES(Context *context, GLuint array); bool ValidateBindVertexArrayOES(Context *context, GLuint array);
bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n); bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n, const GLuint *arrays);
bool ValidateGenVertexArraysOES(Context *context, GLsizei n); bool ValidateGenVertexArraysOES(Context *context, GLsizei n, GLuint *arrays);
bool ValidateIsVertexArrayOES(Context *context); bool ValidateIsVertexArrayOES(Context *context, GLuint array);
bool ValidateProgramBinaryOES(Context *context, bool ValidateProgramBinaryOES(Context *context,
GLuint program, GLuint program,
......
...@@ -1398,11 +1398,11 @@ bool ValidateBindVertexArray(Context *context, GLuint array) ...@@ -1398,11 +1398,11 @@ bool ValidateBindVertexArray(Context *context, GLuint array)
return ValidateBindVertexArrayBase(context, array); return ValidateBindVertexArrayBase(context, array);
} }
bool ValidateIsVertexArray(Context *context) bool ValidateIsVertexArray(Context *context, GLuint array)
{ {
if (context->getClientMajorVersion() < 3) if (context->getClientMajorVersion() < 3)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false; return false;
} }
......
...@@ -202,7 +202,7 @@ bool ValidateCompressedTexImage3DRobustANGLE(Context *context, ...@@ -202,7 +202,7 @@ bool ValidateCompressedTexImage3DRobustANGLE(Context *context,
const void *data); const void *data);
bool ValidateBindVertexArray(Context *context, GLuint array); bool ValidateBindVertexArray(Context *context, GLuint array);
bool ValidateIsVertexArray(Context *context); bool ValidateIsVertexArray(Context *context, GLuint array);
bool ValidateBindBufferBase(Context *context, GLenum target, GLuint index, GLuint buffer); bool ValidateBindBufferBase(Context *context, GLenum target, GLuint index, GLuint buffer);
bool ValidateBindBufferRange(Context *context, bool ValidateBindBufferRange(Context *context,
......
...@@ -1057,7 +1057,7 @@ void GL_APIENTRY BindVertexArrayOES(GLuint array) ...@@ -1057,7 +1057,7 @@ void GL_APIENTRY BindVertexArrayOES(GLuint array)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateBindVertexArrayOES(context, array)) if (!context->skipValidation() && !ValidateBindVertexArrayOES(context, array))
{ {
return; return;
} }
...@@ -1073,18 +1073,12 @@ void GL_APIENTRY DeleteVertexArraysOES(GLsizei n, const GLuint *arrays) ...@@ -1073,18 +1073,12 @@ void GL_APIENTRY DeleteVertexArraysOES(GLsizei n, const GLuint *arrays)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateDeleteVertexArraysOES(context, n)) if (!context->skipValidation() && !ValidateDeleteVertexArraysOES(context, n, arrays))
{ {
return; return;
} }
for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) context->deleteVertexArrays(n, arrays);
{
if (arrays[arrayIndex] != 0)
{
context->deleteVertexArray(arrays[arrayIndex]);
}
}
} }
} }
...@@ -1095,15 +1089,12 @@ void GL_APIENTRY GenVertexArraysOES(GLsizei n, GLuint *arrays) ...@@ -1095,15 +1089,12 @@ void GL_APIENTRY GenVertexArraysOES(GLsizei n, GLuint *arrays)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateGenVertexArraysOES(context, n)) if (!context->skipValidation() && !ValidateGenVertexArraysOES(context, n, arrays))
{ {
return; return;
} }
for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) context->genVertexArrays(n, arrays);
{
arrays[arrayIndex] = context->createVertexArray();
}
} }
} }
...@@ -1114,19 +1105,12 @@ GLboolean GL_APIENTRY IsVertexArrayOES(GLuint array) ...@@ -1114,19 +1105,12 @@ GLboolean GL_APIENTRY IsVertexArrayOES(GLuint array)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateIsVertexArrayOES(context)) if (!context->skipValidation() && !ValidateIsVertexArrayOES(context, array))
{ {
return GL_FALSE; return GL_FALSE;
} }
if (array == 0) return context->isVertexArray(array);
{
return GL_FALSE;
}
VertexArray *vao = context->getVertexArray(array);
return (vao != nullptr ? GL_TRUE : GL_FALSE);
} }
return GL_FALSE; return GL_FALSE;
......
...@@ -686,13 +686,7 @@ void GL_APIENTRY DeleteVertexArrays(GLsizei n, const GLuint *arrays) ...@@ -686,13 +686,7 @@ void GL_APIENTRY DeleteVertexArrays(GLsizei n, const GLuint *arrays)
return; return;
} }
for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) context->deleteVertexArrays(n, arrays);
{
if (arrays[arrayIndex] != 0)
{
context->deleteVertexArray(arrays[arrayIndex]);
}
}
} }
} }
...@@ -708,10 +702,7 @@ void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint *arrays) ...@@ -708,10 +702,7 @@ void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint *arrays)
return; return;
} }
for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) context->genVertexArrays(n, arrays);
{
arrays[arrayIndex] = context->createVertexArray();
}
} }
} }
...@@ -722,19 +713,12 @@ GLboolean GL_APIENTRY IsVertexArray(GLuint array) ...@@ -722,19 +713,12 @@ GLboolean GL_APIENTRY IsVertexArray(GLuint array)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateIsVertexArray(context)) if (!context->skipValidation() && !ValidateIsVertexArray(context, array))
{ {
return GL_FALSE; return GL_FALSE;
} }
if (array == 0) return context->isVertexArray(array);
{
return GL_FALSE;
}
VertexArray *vao = context->getVertexArray(array);
return (vao != nullptr ? GL_TRUE : GL_FALSE);
} }
return GL_FALSE; return GL_FALSE;
......
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