Commit d6e50872 by Geoff Lang

Add a StateManagerGL method to sync state required for a draw call.

BUG=angle:883 Change-Id: Iabeb25aef2228a1900bd0209422ddce21771c688 Reviewed-on: https://chromium-review.googlesource.com/252802Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ba4c4a85
...@@ -58,16 +58,25 @@ gl::Error RendererGL::finish() ...@@ -58,16 +58,25 @@ gl::Error RendererGL::finish()
gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode, gl::Error RendererGL::drawArrays(const gl::Data &data, GLenum mode,
GLint first, GLsizei count, GLsizei instances) GLint first, GLsizei count, GLsizei instances)
{ {
UNIMPLEMENTED(); mStateManager->setDrawState(*data.state);
return gl::Error(GL_INVALID_OPERATION); mFunctions->drawArrays(mode, first, count);
return gl::Error(GL_NO_ERROR);
} }
gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type, gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) const RangeUI &indexRange)
{ {
UNIMPLEMENTED(); if (instances > 0)
return gl::Error(GL_INVALID_OPERATION); {
UNIMPLEMENTED();
}
mStateManager->setDrawState(*data.state);
mFunctions->drawElements(mode, count, type, indices);
return gl::Error(GL_NO_ERROR);
} }
CompilerImpl *RendererGL::createCompiler(const gl::Data &data) CompilerImpl *RendererGL::createCompiler(const gl::Data &data)
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
#include "libANGLE/renderer/gl/StateManagerGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/Data.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/ProgramGL.h"
#include "libANGLE/renderer/gl/VertexArrayGL.h"
namespace rx namespace rx
{ {
...@@ -49,4 +53,15 @@ void StateManagerGL::bindBuffer(GLenum type, GLuint buffer) ...@@ -49,4 +53,15 @@ void StateManagerGL::bindBuffer(GLenum type, GLuint buffer)
} }
} }
void StateManagerGL::setDrawState(const gl::State &state)
{
const gl::VertexArray *vao = state.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
bindVertexArray(vaoGL->getVertexArrayID());
const gl::Program *program = state.getProgram();
const ProgramGL *programGL = GetImplAs<ProgramGL>(program);
useProgram(programGL->getProgramID());
}
} }
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
#include <map> #include <map>
namespace gl
{
class State;
}
namespace rx namespace rx
{ {
...@@ -28,6 +33,8 @@ class StateManagerGL ...@@ -28,6 +33,8 @@ class StateManagerGL
void bindVertexArray(GLuint vao); void bindVertexArray(GLuint vao);
void bindBuffer(GLenum type, GLuint buffer); void bindBuffer(GLenum type, GLuint buffer);
void setDrawState(const gl::State &state);
private: private:
DISALLOW_COPY_AND_ASSIGN(StateManagerGL); DISALLOW_COPY_AND_ASSIGN(StateManagerGL);
......
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