Commit ea0f3496 by Geoff Lang Committed by Commit Bot

GL: Update VertexArrayGL to not store per-context state.

Move StateManagerGL and FunctionsGL members out of VertexArrayGL and query them directly from the context in methods. Bug: angleproject:5577, chromium:1167179 Change-Id: I376f3eff15fbd9855c5956737064f56d54acbceb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2647868Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent f6925344
......@@ -115,7 +115,12 @@ BufferImpl *ContextGL::createBuffer(const gl::BufferState &state)
VertexArrayImpl *ContextGL::createVertexArray(const gl::VertexArrayState &data)
{
return new VertexArrayGL(data, getFunctions(), getStateManager());
const FunctionsGL *functions = getFunctions();
GLuint vao = 0;
functions->genVertexArrays(1, &vao);
return new VertexArrayGL(data, vao);
}
QueryImpl *ContextGL::createQuery(gl::QueryType type)
......@@ -216,7 +221,7 @@ ANGLE_INLINE angle::Result ContextGL::setDrawArraysState(const gl::Context *cont
first, count, instanceCount));
#if defined(ANGLE_STATE_VALIDATION_ENABLED)
vaoGL->validateState();
vaoGL->validateState(context);
#endif // ANGLE_STATE_VALIDATION_ENABLED
}
......@@ -266,7 +271,7 @@ ANGLE_INLINE angle::Result ContextGL::setDrawElementsState(const gl::Context *co
#if defined(ANGLE_STATE_VALIDATION_ENABLED)
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
vaoGL->validateState();
vaoGL->validateState(context);
#endif // ANGLE_STATE_VALIDATION_ENABLED
return angle::Result::Continue;
......
......@@ -1940,7 +1940,7 @@ angle::Result StateManagerGL::syncState(const gl::Context *context,
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(state.getVertexArray());
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
propagateProgramToVAO(state.getProgram(),
propagateProgramToVAO(context, state.getProgram(),
GetImplAs<VertexArrayGL>(state.getVertexArray()));
break;
}
......@@ -1998,7 +1998,7 @@ angle::Result StateManagerGL::syncState(const gl::Context *context,
if (!program ||
!program->getExecutable().hasLinkedShaderStage(gl::ShaderType::Compute))
{
propagateProgramToVAO(program,
propagateProgramToVAO(context, program,
GetImplAs<VertexArrayGL>(state.getVertexArray()));
}
break;
......@@ -2320,7 +2320,9 @@ void StateManagerGL::setTextureCubemapSeamlessEnabled(bool enabled)
}
}
void StateManagerGL::propagateProgramToVAO(const gl::Program *program, VertexArrayGL *vao)
void StateManagerGL::propagateProgramToVAO(const gl::Context *context,
const gl::Program *program,
VertexArrayGL *vao)
{
if (vao == nullptr)
{
......@@ -2335,14 +2337,14 @@ void StateManagerGL::propagateProgramToVAO(const gl::Program *program, VertexArr
{
programNumViews = program->getNumViews();
}
vao->applyNumViewsToDivisor(programNumViews);
vao->applyNumViewsToDivisor(context, programNumViews);
}
// Attribute enabled mask:
if (program)
{
vao->applyActiveAttribLocationsMask(
program->getExecutable().getActiveAttribLocationsMask());
context, program->getExecutable().getActiveAttribLocationsMask());
}
}
......
......@@ -268,7 +268,9 @@ class StateManagerGL final : angle::NonCopyable
private:
void setTextureCubemapSeamlessEnabled(bool enabled);
void propagateProgramToVAO(const gl::Program *program, VertexArrayGL *vao);
void propagateProgramToVAO(const gl::Context *context,
const gl::Program *program,
VertexArrayGL *vao);
void updateProgramTextureBindings(const gl::Context *context);
void updateProgramStorageBufferBindings(const gl::Context *context);
......
......@@ -24,9 +24,7 @@ class StateManagerGL;
class VertexArrayGL : public VertexArrayImpl
{
public:
VertexArrayGL(const gl::VertexArrayState &data,
const FunctionsGL *functions,
StateManagerGL *stateManager);
VertexArrayGL(const gl::VertexArrayState &data, GLuint id);
~VertexArrayGL() override;
void destroy(const gl::Context *context) override;
......@@ -53,10 +51,11 @@ class VertexArrayGL : public VertexArrayImpl
gl::VertexArray::DirtyAttribBitsArray *attribBits,
gl::VertexArray::DirtyBindingBitsArray *bindingBits) override;
void applyNumViewsToDivisor(int numViews);
void applyActiveAttribLocationsMask(const gl::AttributesMask &activeMask);
void applyNumViewsToDivisor(const gl::Context *context, int numViews);
void applyActiveAttribLocationsMask(const gl::Context *context,
const gl::AttributesMask &activeMask);
void validateState() const;
void validateState(const gl::Context *context) const;
private:
angle::Result syncDrawState(const gl::Context *context,
......@@ -99,26 +98,24 @@ class VertexArrayGL : public VertexArrayImpl
size_t bindingIndex,
const gl::VertexArray::DirtyBindingBits &dirtyBindingBits);
void updateAttribEnabled(size_t attribIndex);
void updateAttribEnabled(const gl::Context *context, size_t attribIndex);
void updateAttribPointer(const gl::Context *context, size_t attribIndex);
bool supportVertexAttribBinding() const;
bool supportVertexAttribBinding(const gl::Context *context) const;
void updateAttribFormat(size_t attribIndex);
void updateAttribBinding(size_t attribIndex);
void updateAttribFormat(const gl::Context *context, size_t attribIndex);
void updateAttribBinding(const gl::Context *context, size_t attribIndex);
void updateBindingBuffer(const gl::Context *context, size_t bindingIndex);
void updateBindingDivisor(size_t bindingIndex);
void updateBindingDivisor(const gl::Context *context, size_t bindingIndex);
void updateElementArrayBufferBinding(const gl::Context *context) const;
void callVertexAttribPointer(GLuint attribIndex,
void callVertexAttribPointer(const gl::Context *context,
GLuint attribIndex,
const gl::VertexAttribute &attrib,
GLsizei stride,
GLintptr offset) const;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
GLuint mVertexArrayID;
int mAppliedNumViews;
......
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