Commit 2eb65034 by Jamie Madill Committed by Commit Bot

Add Context::getActiveBufferedAttribsMask.

This will enable more caching for ValidateDrawAttribs. It requires some minor refactoring of the GLES 1 code. Bug: angleproject:1391 Change-Id: I52b73c9384d14cdb90ba6337bfc1ab345866fff0 Reviewed-on: https://chromium-review.googlesource.com/1147436 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 67c388e6
...@@ -7531,6 +7531,28 @@ void Context::maxShaderCompilerThreads(GLuint count) ...@@ -7531,6 +7531,28 @@ void Context::maxShaderCompilerThreads(GLuint count)
mGLState.setMaxShaderCompilerThreads(count); mGLState.setMaxShaderCompilerThreads(count);
} }
bool Context::isGLES1() const
{
return mState.getClientVersion() < Version(2, 0);
}
AttributesMask Context::getActiveBufferedAttribsMask() const
{
// TODO(jmadill): Cache this. http://anglebug.com/1391
ASSERT(mGLState.getProgram() || isGLES1());
const AttributesMask &activeAttribs =
isGLES1() ? mGLState.gles1().getVertexArraysAttributeMask()
: mGLState.getProgram()->getActiveAttribLocationsMask();
const VertexArray *vao = mGLState.getVertexArray();
ASSERT(vao);
const AttributesMask &clientAttribs = vao->getEnabledClientMemoryAttribsMask();
return (activeAttribs & vao->getEnabledAttributesMask() & ~clientAttribs);
}
// ErrorSet implementation. // ErrorSet implementation.
ErrorSet::ErrorSet(Context *context) : mContext(context) ErrorSet::ErrorSet(Context *context) : mContext(context)
{ {
......
...@@ -1458,6 +1458,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable ...@@ -1458,6 +1458,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable
const Extensions &getExtensions() const { return mState.getExtensions(); } const Extensions &getExtensions() const { return mState.getExtensions(); }
const Limitations &getLimitations() const { return mState.getLimitations(); } const Limitations &getLimitations() const { return mState.getLimitations(); }
bool skipValidation() const { return mSkipValidation; } bool skipValidation() const { return mSkipValidation; }
bool isGLES1() const;
// Specific methods needed for validation. // Specific methods needed for validation.
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams); bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
...@@ -1488,11 +1489,12 @@ class Context final : public egl::LabeledObject, angle::NonCopyable ...@@ -1488,11 +1489,12 @@ class Context final : public egl::LabeledObject, angle::NonCopyable
// GLES1 emulation: Renderer level (for validation) // GLES1 emulation: Renderer level (for validation)
int vertexArrayIndex(ClientVertexArrayType type) const; int vertexArrayIndex(ClientVertexArrayType type) const;
static int TexCoordArrayIndex(unsigned int unit); static int TexCoordArrayIndex(unsigned int unit);
AttributesMask getVertexArraysAttributeMask() const;
// GL_KHR_parallel_shader_compile // GL_KHR_parallel_shader_compile
void maxShaderCompilerThreads(GLuint count); void maxShaderCompilerThreads(GLuint count);
AttributesMask getActiveBufferedAttribsMask() const;
private: private:
void initialize(); void initialize();
......
...@@ -709,7 +709,7 @@ void Context::texGenxv(GLenum coord, GLenum pname, const GLint *params) ...@@ -709,7 +709,7 @@ void Context::texGenxv(GLenum coord, GLenum pname, const GLint *params)
int Context::vertexArrayIndex(ClientVertexArrayType type) const int Context::vertexArrayIndex(ClientVertexArrayType type) const
{ {
return mGLES1Renderer->vertexArrayIndex(type, &mGLState); return GLES1Renderer::VertexArrayIndex(type, mGLState.gles1());
} }
// static // static
...@@ -717,11 +717,4 @@ int Context::TexCoordArrayIndex(unsigned int unit) ...@@ -717,11 +717,4 @@ int Context::TexCoordArrayIndex(unsigned int unit)
{ {
return GLES1Renderer::TexCoordArrayIndex(unit); return GLES1Renderer::TexCoordArrayIndex(unit);
} }
AttributesMask Context::getVertexArraysAttributeMask() const
{
return mGLES1Renderer->getVertexArraysAttributeMask(&mGLState);
}
// static
} // namespace gl } // namespace gl
...@@ -397,7 +397,8 @@ Error GLES1Renderer::prepareForDraw(PrimitiveMode mode, Context *context, State ...@@ -397,7 +397,8 @@ Error GLES1Renderer::prepareForDraw(PrimitiveMode mode, Context *context, State
return NoError(); return NoError();
} }
int GLES1Renderer::vertexArrayIndex(ClientVertexArrayType type, const State *glState) const // static
int GLES1Renderer::VertexArrayIndex(ClientVertexArrayType type, const GLES1State &gles1)
{ {
switch (type) switch (type)
{ {
...@@ -410,7 +411,7 @@ int GLES1Renderer::vertexArrayIndex(ClientVertexArrayType type, const State *glS ...@@ -410,7 +411,7 @@ int GLES1Renderer::vertexArrayIndex(ClientVertexArrayType type, const State *glS
case ClientVertexArrayType::PointSize: case ClientVertexArrayType::PointSize:
return kPointSizeAttribIndex; return kPointSizeAttribIndex;
case ClientVertexArrayType::TextureCoord: case ClientVertexArrayType::TextureCoord:
return kTextureCoordAttribIndexBase + glState->gles1().getClientTextureUnit(); return kTextureCoordAttribIndexBase + gles1.getClientTextureUnit();
default: default:
UNREACHABLE(); UNREACHABLE();
return 0; return 0;
...@@ -423,29 +424,6 @@ int GLES1Renderer::TexCoordArrayIndex(unsigned int unit) ...@@ -423,29 +424,6 @@ int GLES1Renderer::TexCoordArrayIndex(unsigned int unit)
return kTextureCoordAttribIndexBase + unit; return kTextureCoordAttribIndexBase + unit;
} }
AttributesMask GLES1Renderer::getVertexArraysAttributeMask(const State *glState) const
{
AttributesMask res;
const GLES1State &gles1 = glState->gles1();
ClientVertexArrayType nonTexcoordArrays[] = {
ClientVertexArrayType::Vertex, ClientVertexArrayType::Normal, ClientVertexArrayType::Color,
ClientVertexArrayType::PointSize,
};
for (const ClientVertexArrayType attrib : nonTexcoordArrays)
{
res.set(vertexArrayIndex(attrib, glState), gles1.isClientStateEnabled(attrib));
}
for (unsigned int i = 0; i < kTexUnitCount; i++)
{
res.set(TexCoordArrayIndex(i), gles1.isTexCoordArrayEnabled(i));
}
return res;
}
void GLES1Renderer::drawTexture(Context *context, void GLES1Renderer::drawTexture(Context *context,
State *glState, State *glState,
float x, float x,
...@@ -476,7 +454,7 @@ void GLES1Renderer::drawTexture(Context *context, ...@@ -476,7 +454,7 @@ void GLES1Renderer::drawTexture(Context *context,
mDrawTextureEnabled = true; mDrawTextureEnabled = true;
AttributesMask prevAttributesMask = getVertexArraysAttributeMask(glState); AttributesMask prevAttributesMask = glState->gles1().getVertexArraysAttributeMask();
setAttributesEnabled(context, glState, AttributesMask()); setAttributesEnabled(context, glState, AttributesMask());
...@@ -832,7 +810,7 @@ void GLES1Renderer::setAttributesEnabled(Context *context, State *glState, Attri ...@@ -832,7 +810,7 @@ void GLES1Renderer::setAttributesEnabled(Context *context, State *glState, Attri
for (const ClientVertexArrayType attrib : nonTexcoordArrays) for (const ClientVertexArrayType attrib : nonTexcoordArrays)
{ {
int index = vertexArrayIndex(attrib, glState); int index = VertexArrayIndex(attrib, glState->gles1());
if (mask.test(index)) if (mask.test(index))
{ {
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
namespace gl namespace gl
{ {
class Context; class Context;
class GLES1State;
class Program; class Program;
class State; class State;
class Shader; class Shader;
...@@ -37,9 +37,8 @@ class GLES1Renderer final : angle::NonCopyable ...@@ -37,9 +37,8 @@ class GLES1Renderer final : angle::NonCopyable
Error prepareForDraw(PrimitiveMode mode, Context *context, State *glState); Error prepareForDraw(PrimitiveMode mode, Context *context, State *glState);
int vertexArrayIndex(ClientVertexArrayType type, const State *glState) const; static int VertexArrayIndex(ClientVertexArrayType type, const GLES1State &gles1);
static int TexCoordArrayIndex(unsigned int unit); static int TexCoordArrayIndex(unsigned int unit);
AttributesMask getVertexArraysAttributeMask(const State *glState) const;
void drawTexture(Context *context, void drawTexture(Context *context,
State *glState, State *glState,
...@@ -49,6 +48,8 @@ class GLES1Renderer final : angle::NonCopyable ...@@ -49,6 +48,8 @@ class GLES1Renderer final : angle::NonCopyable
float width, float width,
float height); float height);
static constexpr int kTexUnitCount = 4;
private: private:
using Mat4Uniform = float[16]; using Mat4Uniform = float[16];
using Vec4Uniform = float[4]; using Vec4Uniform = float[4];
...@@ -84,7 +85,6 @@ class GLES1Renderer final : angle::NonCopyable ...@@ -84,7 +85,6 @@ class GLES1Renderer final : angle::NonCopyable
void setAttributesEnabled(Context *context, State *glState, AttributesMask mask); void setAttributesEnabled(Context *context, State *glState, AttributesMask mask);
static constexpr int kTexUnitCount = 4;
static constexpr int kLightCount = 8; static constexpr int kLightCount = 8;
static constexpr int kClipPlaneCount = 6; static constexpr int kClipPlaneCount = 6;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "libANGLE/GLES1State.h" #include "libANGLE/GLES1State.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/GLES1Renderer.h"
namespace gl namespace gl
{ {
...@@ -416,4 +417,26 @@ const PointParameters &GLES1State::pointParameters() const ...@@ -416,4 +417,26 @@ const PointParameters &GLES1State::pointParameters() const
return mPointParameters; return mPointParameters;
} }
AttributesMask GLES1State::getVertexArraysAttributeMask() const
{
AttributesMask attribsMask;
ClientVertexArrayType nonTexcoordArrays[] = {
ClientVertexArrayType::Vertex, ClientVertexArrayType::Normal, ClientVertexArrayType::Color,
ClientVertexArrayType::PointSize,
};
for (const ClientVertexArrayType attrib : nonTexcoordArrays)
{
attribsMask.set(GLES1Renderer::VertexArrayIndex(attrib, *this),
isClientStateEnabled(attrib));
}
for (unsigned int i = 0; i < GLES1Renderer::kTexUnitCount; i++)
{
attribsMask.set(GLES1Renderer::TexCoordArrayIndex(i), isTexCoordArrayEnabled(i));
}
return attribsMask;
}
} // namespace gl } // namespace gl
...@@ -190,6 +190,8 @@ class GLES1State final : angle::NonCopyable ...@@ -190,6 +190,8 @@ class GLES1State final : angle::NonCopyable
PointParameters &pointParameters(); PointParameters &pointParameters();
const PointParameters &pointParameters() const; const PointParameters &pointParameters() const;
AttributesMask getVertexArraysAttributeMask() const;
private: private:
friend class State; friend class State;
friend class GLES1Renderer; friend class GLES1Renderer;
......
...@@ -118,11 +118,7 @@ bool ValidateDrawAttribs(Context *context, GLint primcount, GLint maxVertex, GLi ...@@ -118,11 +118,7 @@ bool ValidateDrawAttribs(Context *context, GLint primcount, GLint maxVertex, GLi
const auto &vertexAttribs = vao->getVertexAttributes(); const auto &vertexAttribs = vao->getVertexAttributes();
const auto &vertexBindings = vao->getVertexBindings(); const auto &vertexBindings = vao->getVertexBindings();
bool isGLES1 = context->getClientVersion() < Version(2, 0); const AttributesMask &activeAttribs = context->getActiveBufferedAttribsMask();
const AttributesMask &activeAttribs = ((isGLES1 ? context->getVertexArraysAttributeMask()
: program->getActiveAttribLocationsMask()) &
vao->getEnabledAttributesMask() & ~clientAttribs);
for (size_t attributeIndex : activeAttribs) for (size_t attributeIndex : activeAttribs)
{ {
...@@ -130,7 +126,7 @@ bool ValidateDrawAttribs(Context *context, GLint primcount, GLint maxVertex, GLi ...@@ -130,7 +126,7 @@ bool ValidateDrawAttribs(Context *context, GLint primcount, GLint maxVertex, GLi
ASSERT(attrib.enabled); ASSERT(attrib.enabled);
const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; const VertexBinding &binding = vertexBindings[attrib.bindingIndex];
ASSERT(isGLES1 || program->isAttribLocationActive(attributeIndex)); ASSERT(context->isGLES1() || program->isAttribLocationActive(attributeIndex));
GLint maxVertexElement = maxVertex; GLint maxVertexElement = maxVertex;
GLuint divisor = binding.getDivisor(); GLuint divisor = binding.getDivisor();
......
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