Skip to content

Commit

Permalink
Added support for OES_vertex_array_object to the command buffer
Browse files Browse the repository at this point in the history
BUG=72612


Review URL: https://chromiumcodereview.appspot.com/10915244

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158967 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bajones@google.com committed Sep 27, 2012
1 parent 01719f7 commit 944b62f
Show file tree
Hide file tree
Showing 39 changed files with 1,652 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,20 @@ void WebGraphicsContext3DCommandBufferImpl::pushGroupMarkerEXT(

DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT);

WebGLId WebGraphicsContext3DCommandBufferImpl::createVertexArrayOES() {
GLuint array;
gl_->GenVertexArraysOES(1, &array);
return array;
}

void WebGraphicsContext3DCommandBufferImpl::deleteVertexArrayOES(
WebGLId array) {
gl_->DeleteVertexArraysOES(1, &array);
}

DELEGATE_TO_GL_1R(isVertexArrayOES, IsVertexArrayOES, WebGLId, WGC3Dboolean)
DELEGATE_TO_GL_1(bindVertexArrayOES, BindVertexArrayOES, WebGLId)

GrGLInterface* WebGraphicsContext3DCommandBufferImpl::onCreateGrGLInterface() {
return webkit_glue::CreateCommandBufferSkiaGLBinding();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ class WebGraphicsContext3DCommandBufferImpl
virtual void pushGroupMarkerEXT(const WGC3Dchar* marker);
virtual void popGroupMarkerEXT();

// GL_OES_vertex_array_object
virtual WebGLId createVertexArrayOES();
virtual void deleteVertexArrayOES(WebGLId array);
virtual WGC3Dboolean isVertexArrayOES(WebGLId array);
virtual void bindVertexArrayOES(WebGLId array);

protected:
virtual GrGLInterface* onCreateGrGLInterface();

Expand Down
101 changes: 87 additions & 14 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,35 @@
'expectation': False,
'impl_func': False,
},

'GenVertexArraysOES': {
'type': 'GENn',
'gl_test_func': 'glGenVertexArraysOES',
'resource_type': 'VertexArray',
'resource_types': 'VertexArrays',
'unit_test': False,
},
'BindVertexArrayOES': {
'type': 'Bind',
'gl_test_func': 'glBindVertexArrayOES',
'decoder_func': 'DoBindVertexArrayOES',
'gen_func': 'GenVertexArraysOES',
'unit_test': False,
},
'DeleteVertexArraysOES': {
'type': 'DELn',
'gl_test_func': 'glDeleteVertexArraysOES',
'resource_type': 'VertexArray',
'resource_types': 'VertexArrays',
'unit_test': False,
},
'IsVertexArrayOES': {
'type': 'Is',
'gl_test_func': 'glIsVertexArrayOES',
'decoder_func': 'DoIsVertexArrayOES',
'expectation': False,
'unit_test': False,
},
}


Expand Down Expand Up @@ -2720,7 +2749,38 @@ def __init__(self):

def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """

if len(func.GetOriginalArgs()) == 1:
valid_test = """
TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
SpecializedSetup<%(name)s, 0>(true);
%(name)s cmd;
cmd.Init(%(args)s);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(%(test_name)s, %(name)sValidArgsNewId) {
EXPECT_CALL(*gl_, %(gl_func_name)s(kNewServiceId));
EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _))
.WillOnce(SetArgumentPointee<1>(kNewServiceId));
SpecializedSetup<%(name)s, 0>(true);
%(name)s cmd;
cmd.Init(kNewClientId);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
EXPECT_TRUE(Get%(resource_type)sInfo(kNewClientId) != NULL);
}
"""
gen_func_names = {
}
self.WriteValidUnitTest(func, file, valid_test, {
'resource_type': func.GetOriginalArgs()[0].resource_type,
'gl_gen_func_name': func.GetInfo("gen_func"),
})
else:
valid_test = """
TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
SpecializedSetup<%(name)s, 0>(true);
Expand All @@ -2742,14 +2802,14 @@ def WriteServiceUnitTest(self, func, file):
EXPECT_TRUE(Get%(resource_type)sInfo(kNewClientId) != NULL);
}
"""
gen_func_names = {
}
self.WriteValidUnitTest(func, file, valid_test, {
'first_arg': func.GetOriginalArgs()[0].GetValidArg(func, 0, 0),
'first_gl_arg': func.GetOriginalArgs()[0].GetValidGLArg(func, 0, 0),
'resource_type': func.GetOriginalArgs()[1].resource_type,
'gl_gen_func_name': func.GetInfo("gen_func"),
})
gen_func_names = {
}
self.WriteValidUnitTest(func, file, valid_test, {
'first_arg': func.GetOriginalArgs()[0].GetValidArg(func, 0, 0),
'first_gl_arg': func.GetOriginalArgs()[0].GetValidGLArg(func, 0, 0),
'resource_type': func.GetOriginalArgs()[1].resource_type,
'gl_gen_func_name': func.GetInfo("gen_func"),
})

invalid_test = """
TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
Expand All @@ -2764,11 +2824,14 @@ def WriteServiceUnitTest(self, func, file):

def WriteGLES2ImplementationHeader(self, func, file):
"""Writes the GLES2 Implemention."""

impl_func = func.GetInfo('impl_func')
impl_decl = func.GetInfo('impl_decl')

if (func.can_auto_generate and
(impl_func == None or impl_func == True) and
(impl_decl == None or impl_decl == True)):
(impl_func == None or impl_func == True) and
(impl_decl == None or impl_decl == True)):

file.Write("%s %s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
Expand All @@ -2777,6 +2840,7 @@ def WriteGLES2ImplementationHeader(self, func, file):
self.WriteClientGLCallLog(func, file)
for arg in func.GetOriginalArgs():
arg.WriteClientSideValidationCode(file, func)

code = """ if (Is%(type)sReservedId(%(id)s)) {
SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id");
return;
Expand All @@ -2786,13 +2850,22 @@ def WriteGLES2ImplementationHeader(self, func, file):
}
"""
name_arg = None
if len(func.GetOriginalArgs()) == 1:
# Bind functions that have no target (like BindVertexArrayOES)
name_arg = func.GetOriginalArgs()[0]
else:
# Bind functions that have both a target and a name (like BindTexture)
name_arg = func.GetOriginalArgs()[1]

file.Write(code % {
'name': func.name,
'arg_string': func.MakeOriginalArgString(""),
'id': func.GetOriginalArgs()[1].name,
'type': func.GetOriginalArgs()[1].resource_type,
'lc_type': func.GetOriginalArgs()[1].resource_type.lower(),
'id': name_arg.name,
'type': name_arg.resource_type,
'lc_type': name_arg.resource_type.lower(),
})

else:
self.WriteGLES2ImplementationDeclaration(func, file)

Expand Down
12 changes: 12 additions & 0 deletions gpu/command_buffer/client/gles2_c_lib_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,18 @@ void GLES2PushGroupMarkerEXT(GLsizei length, const GLchar* marker) {
void GLES2PopGroupMarkerEXT() {
gles2::GetGLContext()->PopGroupMarkerEXT();
}
void GLES2GenVertexArraysOES(GLsizei n, GLuint* arrays) {
gles2::GetGLContext()->GenVertexArraysOES(n, arrays);
}
void GLES2DeleteVertexArraysOES(GLsizei n, const GLuint* arrays) {
gles2::GetGLContext()->DeleteVertexArraysOES(n, arrays);
}
GLboolean GLES2IsVertexArrayOES(GLuint array) {
return gles2::GetGLContext()->IsVertexArrayOES(array);
}
void GLES2BindVertexArrayOES(GLuint array) {
gles2::GetGLContext()->BindVertexArrayOES(array);
}
void GLES2SwapBuffers() {
gles2::GetGLContext()->SwapBuffers();
}
Expand Down
52 changes: 52 additions & 0 deletions gpu/command_buffer/client/gles2_cmd_helper_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,58 @@
}
}

void GenVertexArraysOES(
GLsizei n, uint32 arrays_shm_id, uint32 arrays_shm_offset) {
gles2::GenVertexArraysOES* c = GetCmdSpace<gles2::GenVertexArraysOES>();
if (c) {
c->Init(n, arrays_shm_id, arrays_shm_offset);
}
}

void GenVertexArraysOESImmediate(GLsizei n, GLuint* arrays) {
const uint32 size = gles2::GenVertexArraysOESImmediate::ComputeSize(n);
gles2::GenVertexArraysOESImmediate* c =
GetImmediateCmdSpaceTotalSize<gles2::GenVertexArraysOESImmediate>(
size);
if (c) {
c->Init(n, arrays);
}
}

void DeleteVertexArraysOES(
GLsizei n, uint32 arrays_shm_id, uint32 arrays_shm_offset) {
gles2::DeleteVertexArraysOES* c =
GetCmdSpace<gles2::DeleteVertexArraysOES>();
if (c) {
c->Init(n, arrays_shm_id, arrays_shm_offset);
}
}

void DeleteVertexArraysOESImmediate(GLsizei n, const GLuint* arrays) {
const uint32 size = gles2::DeleteVertexArraysOESImmediate::ComputeSize(n);
gles2::DeleteVertexArraysOESImmediate* c =
GetImmediateCmdSpaceTotalSize<gles2::DeleteVertexArraysOESImmediate>(
size);
if (c) {
c->Init(n, arrays);
}
}

void IsVertexArrayOES(
GLuint array, uint32 result_shm_id, uint32 result_shm_offset) {
gles2::IsVertexArrayOES* c = GetCmdSpace<gles2::IsVertexArrayOES>();
if (c) {
c->Init(array, result_shm_id, result_shm_offset);
}
}

void BindVertexArrayOES(GLuint array) {
gles2::BindVertexArrayOES* c = GetCmdSpace<gles2::BindVertexArrayOES>();
if (c) {
c->Init(array);
}
}

void SwapBuffers() {
gles2::SwapBuffers* c = GetCmdSpace<gles2::SwapBuffers>();
if (c) {
Expand Down
28 changes: 28 additions & 0 deletions gpu/command_buffer/client/gles2_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,13 @@ void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) {
GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture);
}

void GLES2Implementation::BindVertexArrayHelper(GLuint array) {
// TODO(gman): See note #1 above.
bound_vertex_array_id_ = array;

GetIdHandler(id_namespaces::kVertexArrays)->MarkAsUsedForBind(array);
}

#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
bool GLES2Implementation::IsBufferReservedId(GLuint id) {
for (size_t ii = 0; ii < arraysize(reserved_ids_); ++ii) {
Expand Down Expand Up @@ -2548,6 +2555,27 @@ void GLES2Implementation::DeleteTexturesHelper(
}
}

void GLES2Implementation::DeleteVertexArraysOESHelper(
GLsizei n, const GLuint* arrays) {
if (!GetIdHandler(id_namespaces::kVertexArrays)->FreeIds(
this, n, arrays, &GLES2Implementation::DeleteVertexArraysOESStub)) {
SetGLError(
GL_INVALID_VALUE,
"glDeleteVertexArraysOES", "id not created by this context.");
return;
}
for (GLsizei ii = 0; ii < n; ++ii) {
if (arrays[ii] == bound_vertex_array_id_) {
bound_vertex_array_id_ = 0;
}
}
}

void GLES2Implementation::DeleteVertexArraysOESStub(
GLsizei n, const GLuint* arrays) {
helper_->DeleteVertexArraysOESImmediate(n, arrays);
}

void GLES2Implementation::DeleteTexturesStub(
GLsizei n, const GLuint* textures) {
helper_->DeleteTexturesImmediate(n, textures);
Expand Down
7 changes: 7 additions & 0 deletions gpu/command_buffer/client/gles2_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,13 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
bool IsFramebufferReservedId(GLuint id) { return false; }
bool IsRenderbufferReservedId(GLuint id) { return false; }
bool IsTextureReservedId(GLuint id) { return false; }
bool IsVertexArrayReservedId(GLuint id) { return false; }

void BindBufferHelper(GLenum target, GLuint texture);
void BindFramebufferHelper(GLenum target, GLuint texture);
void BindRenderbufferHelper(GLenum target, GLuint texture);
void BindTextureHelper(GLenum target, GLuint texture);
void BindVertexArrayHelper(GLuint array);

void DeleteBuffersHelper(GLsizei n, const GLuint* buffers);
void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers);
Expand All @@ -413,6 +415,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
bool DeleteProgramHelper(GLuint program);
bool DeleteShaderHelper(GLuint shader);
void DeleteQueriesEXTHelper(GLsizei n, const GLuint* textures);
void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays);

void DeleteBuffersStub(GLsizei n, const GLuint* buffers);
void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers);
Expand All @@ -422,6 +425,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
void DeleteShaderStub(GLsizei n, const GLuint* shaders);
// TODO(gman): Remove this as queries are not shared.
void DeleteQueriesStub(GLsizei n, const GLuint* queries);
void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays);

void BufferDataHelper(
GLenum target, GLsizeiptr size, const void* data, GLenum usage);
Expand Down Expand Up @@ -534,6 +538,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
// buffers.
scoped_ptr<ClientSideBufferHelper> client_side_buffer_helper_;

// The currently bound vertex array object (VAO)
GLuint bound_vertex_array_id_;

GLuint reserved_ids_[2];

// Current GL error bits.
Expand Down
Loading

0 comments on commit 944b62f

Please sign in to comment.