summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-12 02:42:08 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-12 02:42:08 +0000
commit051b137ccd7afc37a0a7ea5e1b91804473abc230 (patch)
tree27b6c2d3050f3d3a27a383ee9b4f7de4f743ff96
parent9b7865836797c002717f2f75fe00fb6809d6db34 (diff)
downloadchromium_src-051b137ccd7afc37a0a7ea5e1b91804473abc230.zip
chromium_src-051b137ccd7afc37a0a7ea5e1b91804473abc230.tar.gz
chromium_src-051b137ccd7afc37a0a7ea5e1b91804473abc230.tar.bz2
Connects tracking renderbuffers and framebuffers
and changes glBindXXX to auto-create gl resources to match the spec. TEST=unit tests BUG=none Review URL: http://codereview.chromium.org/1618010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44231 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py87
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc110
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h20
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h88
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h30
5 files changed, 278 insertions, 57 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 8bd3035..0173ee0 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -946,20 +946,34 @@ _ENUM_LISTS = {
# count: The number of units per element. For PUTn or PUT types.
# unit_test: If False no unit test will be generated.
# expectation: If False the unit test will have no expected calls.
+# gen_func: Name of function that generates GL resource for corresponding
+# bind function.
_FUNCTION_INFO = {
'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'unit_test': False},
'BindAttribLocation': {'type': 'GLchar', 'bucket': True, 'needs_size': True},
- 'BindBuffer': {'decoder_func': 'DoBindBuffer'},
+ 'BindBuffer': {
+ 'type': 'Bind',
+ 'decoder_func': 'DoBindBuffer',
+ 'gen_func': 'GenBuffersARB',
+ },
'BindFramebuffer': {
+ 'type': 'Bind',
'decoder_func': 'DoBindFramebuffer',
'gl_test_func': 'glBindFramebufferEXT',
+ 'gen_func': 'GenFramebuffersEXT',
},
'BindRenderbuffer': {
+ 'type': 'Bind',
'decoder_func': 'DoBindRenderbuffer',
'gl_test_func': 'glBindRenderbufferEXT',
+ 'gen_func': 'GenRenderbuffersEXT',
+ },
+ 'BindTexture': {
+ 'type': 'Bind',
+ 'decoder_func': 'DoBindTexture',
+ 'gen_func': 'GenTextures',
},
- 'BindTexture': {'decoder_func': 'DoBindTexture'},
'BufferData': {'type': 'Manual', 'immediate': True},
'BufferSubData': {'type': 'Data', 'decoder_func': 'DoBufferSubData'},
'CheckFramebufferStatus': {
@@ -2036,6 +2050,58 @@ class DataHandler(TypeHandler):
file.Write("// TODO(gman): %s\n\n" % func.name)
+class BindHandler(TypeHandler):
+ """Handler for glBind___ type functions."""
+
+ def __init__(self):
+ TypeHandler.__init__(self)
+
+ def WriteServiceUnitTest(self, func, file):
+ """Overrriden from TypeHandler."""
+ valid_test = """
+TEST_F(%(test_name)s, %(name)sValidArgs) {
+ EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
+ SpecializedSetup<%(name)s, 0>();
+ %(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(%(first_gl_arg)s, kNewServiceId));
+ EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId));
+ SpecializedSetup<%(name)s, 0>();
+ %(name)s cmd;
+ cmd.Init(%(first_arg)s, kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+ EXPECT_TRUE(Get%(resource_type)sInfo(kNewServiceId) != NULL);
+}
+"""
+ gen_func_names = {
+ }
+ self.WriteValidUnitTest(func, file, valid_test, {
+ 'first_arg': func.GetOriginalArgs()[0].GetValidArg(0, 0),
+ 'first_gl_arg': func.GetOriginalArgs()[0].GetValidGLArg(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) {
+ EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
+ SpecializedSetup<%(name)s, 0>();
+ %(name)s cmd;
+ cmd.Init(%(args)s);
+ EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
+}
+"""
+ self.WriteInvalidUnitTest(func, file, invalid_test)
+
+
class GENnHandler(TypeHandler):
"""Handler for glGen___ type functions."""
@@ -3725,11 +3791,6 @@ class ResourceIdZeroArgument(Argument):
def WriteGetCode(self, file):
"""Overridden from Argument."""
code = """ %(type)s %(name)s = c.%(name)s;
- if (%(name)s != 0u &&
- !id_manager()->GetServiceId(%(name)s, &%(name)s)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
"""
file.Write(code % {'type': self.type, 'name': self.name})
@@ -3739,6 +3800,17 @@ class ResourceIdZeroArgument(Argument):
def GetValidGLArg(self, offset, index):
return "kService%sId" % self.resource_type
+ def GetNumInvalidValues(self, func):
+ """returns the number of invalid values to be tested."""
+ return 1
+
+ def GetInvalidArg(self, offset, index):
+ """returns an invalid value by index."""
+ if self.resource_type == "Texture":
+ return ("client_buffer_id_", "kNoError", "GL_INVALID_OPERATION")
+ return ("client_texture_id_", "kNoError", "GL_INVALID_OPERATION")
+
+
class Function(object):
"""A class that represents a function."""
@@ -4139,6 +4211,7 @@ class GLGenerator(object):
self._empty_function_info = FunctionInfo({}, self._empty_type_handler)
self._type_handlers = {
+ 'Bind': BindHandler(),
'Create': CreateHandler(),
'Custom': CustomHandler(),
'Data': DataHandler(),
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 4f70ecf..8f9ef4e 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -832,10 +832,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
ProgramManager::ProgramInfo::Ref current_program_;
// The currently bound framebuffer
- GLuint bound_framebuffer_;
+ FramebufferManager::FramebufferInfo::Ref bound_framebuffer_;
// The currently bound renderbuffer
- GLuint bound_renderbuffer_;
+ RenderbufferManager::RenderbufferInfo::Ref bound_renderbuffer_;
bool anti_aliased_;
@@ -899,7 +899,10 @@ ScopedRenderBufferBinder::ScopedRenderBufferBinder(GLES2DecoderImpl* decoder,
ScopedRenderBufferBinder::~ScopedRenderBufferBinder() {
ScopedGLErrorSuppressor suppressor(decoder_);
- glBindRenderbufferEXT(GL_RENDERBUFFER, decoder_->bound_renderbuffer_);
+ glBindRenderbufferEXT(
+ GL_RENDERBUFFER,
+ decoder_->bound_renderbuffer_ ?
+ decoder_->bound_renderbuffer_->renderbuffer_id() : 0);
}
ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder,
@@ -911,12 +914,15 @@ ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder,
ScopedFrameBufferBinder::~ScopedFrameBufferBinder() {
ScopedGLErrorSuppressor suppressor(decoder_);
- if (decoder_->bound_framebuffer_ == 0 &&
+ FramebufferManager::FramebufferInfo* info =
+ decoder_->bound_framebuffer_.get();
+ GLuint framebuffer_id = info ? info->framebuffer_id() : 0;
+ if (framebuffer_id == 0 &&
decoder_->offscreen_target_frame_buffer_.get()) {
glBindFramebufferEXT(GL_FRAMEBUFFER,
decoder_->offscreen_target_frame_buffer_->id());
} else {
- glBindFramebufferEXT(GL_FRAMEBUFFER, decoder_->bound_framebuffer_);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_id);
}
}
@@ -1101,8 +1107,6 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
active_texture_unit_(0),
black_2d_texture_id_(0),
black_cube_texture_id_(0),
- bound_framebuffer_(0),
- bound_renderbuffer_(0),
anti_aliased_(false) {
}
@@ -1673,10 +1677,17 @@ void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
glActiveTexture(texture_unit);
}
-void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) {
+void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) {
BufferManager::BufferInfo* info = NULL;
- if (buffer) {
- info = GetBufferInfo(buffer);
+ GLuint service_id = 0;
+ if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) {
+ // It's a new id so make a buffer info for it.
+ glGenBuffersARB(1, &service_id);
+ RegisterObjects(1, &client_id, &service_id);
+ CreateBufferInfo(service_id);
+ }
+ if (service_id) {
+ info = GetBufferInfo(service_id);
// Check the buffer exists
// Check that we are not trying to bind it to a different target.
if (!info || (info->target() != 0 && info->target() != target)) {
@@ -1698,29 +1709,68 @@ void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) {
NOTREACHED(); // Validation should prevent us getting here.
break;
}
- glBindBuffer(target, buffer);
+ glBindBuffer(target, service_id);
}
-void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint framebuffer) {
- bound_framebuffer_ = framebuffer;
+void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
+ FramebufferManager::FramebufferInfo* info = NULL;
+ GLuint service_id = 0;
+ if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) {
+ // It's a new id so make a framebuffer info for it.
+ glGenFramebuffersEXT(1, &service_id);
+ RegisterObjects(1, &client_id, &service_id);
+ CreateFramebufferInfo(service_id);
+ }
+ if (service_id) {
+ info = GetFramebufferInfo(service_id);
+ // Check the framebuffer exists
+ if (!info) {
+ SetGLError(GL_INVALID_OPERATION);
+ return;
+ }
+ }
+ bound_framebuffer_ = info;
// When rendering to an offscreen frame buffer, instead of unbinding from
// the current frame buffer, bind to the offscreen target frame buffer.
- if (framebuffer == 0 && offscreen_target_frame_buffer_.get())
- framebuffer = offscreen_target_frame_buffer_->id();
+ if (info == NULL && offscreen_target_frame_buffer_.get())
+ service_id = offscreen_target_frame_buffer_->id();
- glBindFramebufferEXT(target, framebuffer);
+ glBindFramebufferEXT(target, service_id);
}
-void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint renderbuffer) {
- bound_renderbuffer_ = renderbuffer;
- glBindRenderbufferEXT(target, renderbuffer);
+void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) {
+ RenderbufferManager::RenderbufferInfo* info = NULL;
+ GLuint service_id = 0;
+ if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) {
+ // It's a new id so make a renderbuffer info for it.
+ glGenRenderbuffersEXT(1, &service_id);
+ RegisterObjects(1, &client_id, &service_id);
+ CreateRenderbufferInfo(service_id);
+ }
+ if (service_id) {
+ info = GetRenderbufferInfo(service_id);
+ // Check the renderbuffer exists
+ if (!info) {
+ SetGLError(GL_INVALID_OPERATION);
+ return;
+ }
+ }
+ bound_renderbuffer_ = info;
+ glBindRenderbufferEXT(target, service_id);
}
-void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint texture) {
+void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
TextureManager::TextureInfo* info = NULL;
- if (texture) {
- info = GetTextureInfo(texture);
+ GLuint service_id = 0;
+ if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) {
+ // It's a new id so make a texture info for it.
+ glGenTextures(1, &service_id);
+ RegisterObjects(1, &client_id, &service_id);
+ CreateTextureInfo(service_id);
+ }
+ if (service_id) {
+ info = GetTextureInfo(service_id);
// Check the texture exists
// Check that we are not trying to bind it to a different target.
if (!info || (info->target() != 0 && info->target() != target)) {
@@ -1731,7 +1781,7 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint texture) {
texture_manager()->SetInfoTarget(info, target);
}
}
- glBindTexture(target, texture);
+ glBindTexture(target, service_id);
TextureUnit& unit = texture_units_[active_texture_unit_];
unit.bind_target = target;
switch (target) {
@@ -1873,7 +1923,7 @@ void GLES2DecoderImpl::DoDrawArrays(
void GLES2DecoderImpl::DoFramebufferRenderbuffer(
GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint renderbuffer) {
- if (bound_framebuffer_ == 0) {
+ if (!bound_framebuffer_) {
SetGLError(GL_INVALID_OPERATION);
return;
}
@@ -1882,7 +1932,7 @@ void GLES2DecoderImpl::DoFramebufferRenderbuffer(
}
GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) {
- if (bound_framebuffer_ == 0) {
+ if (!bound_framebuffer_) {
return GL_FRAMEBUFFER_COMPLETE;
}
return glCheckFramebufferStatusEXT(target);
@@ -1891,7 +1941,7 @@ GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) {
void GLES2DecoderImpl::DoFramebufferTexture2D(
GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level) {
- if (bound_framebuffer_ == 0) {
+ if (!bound_framebuffer_) {
SetGLError(GL_INVALID_OPERATION);
return;
}
@@ -1900,7 +1950,7 @@ void GLES2DecoderImpl::DoFramebufferTexture2D(
void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
GLenum target, GLenum attachment, GLenum pname, GLint* params) {
- if (bound_framebuffer_ == 0) {
+ if (!bound_framebuffer_) {
SetGLError(GL_INVALID_OPERATION);
return;
}
@@ -1909,7 +1959,7 @@ void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
void GLES2DecoderImpl::DoGetRenderbufferParameteriv(
GLenum target, GLenum pname, GLint* params) {
- if (bound_renderbuffer_ == 0) {
+ if (!bound_renderbuffer_) {
SetGLError(GL_INVALID_OPERATION);
return;
}
@@ -1918,7 +1968,7 @@ void GLES2DecoderImpl::DoGetRenderbufferParameteriv(
void GLES2DecoderImpl::DoRenderbufferStorage(
GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
- if (bound_renderbuffer_ == 0) {
+ if (!bound_renderbuffer_) {
SetGLError(GL_INVALID_OPERATION);
return;
}
@@ -3162,7 +3212,7 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
// Check a client created frame buffer is not bound. TODO(apatrick):
// this error is overkill. It will require that the client recreate the
// context to continue.
- if (bound_framebuffer_ != 0)
+ if (bound_framebuffer_)
return error::kLostContext;
// If offscreen then don't actually SwapBuffers to the display. Just copy
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index 7507d95..cc862d1 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -35,11 +35,6 @@ error::Error GLES2DecoderImpl::HandleBindBuffer(
uint32 immediate_data_size, const gles2::BindBuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint buffer = c.buffer;
- if (buffer != 0u &&
- !id_manager()->GetServiceId(buffer, &buffer)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
if (!ValidateGLenumBufferTarget(target)) {
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
@@ -52,11 +47,6 @@ error::Error GLES2DecoderImpl::HandleBindFramebuffer(
uint32 immediate_data_size, const gles2::BindFramebuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint framebuffer = c.framebuffer;
- if (framebuffer != 0u &&
- !id_manager()->GetServiceId(framebuffer, &framebuffer)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
if (!ValidateGLenumFrameBufferTarget(target)) {
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
@@ -69,11 +59,6 @@ error::Error GLES2DecoderImpl::HandleBindRenderbuffer(
uint32 immediate_data_size, const gles2::BindRenderbuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint renderbuffer = c.renderbuffer;
- if (renderbuffer != 0u &&
- !id_manager()->GetServiceId(renderbuffer, &renderbuffer)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
if (!ValidateGLenumRenderBufferTarget(target)) {
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
@@ -86,11 +71,6 @@ error::Error GLES2DecoderImpl::HandleBindTexture(
uint32 immediate_data_size, const gles2::BindTexture& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint texture = c.texture;
- if (texture != 0u &&
- !id_manager()->GetServiceId(texture, &texture)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
if (!ValidateGLenumTextureBindTarget(target)) {
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
index 6fb494b..33eeb1f 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
@@ -33,6 +33,19 @@ TEST_F(GLES2DecoderTest1, BindBufferValidArgs) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindBufferValidArgsNewId) {
+ EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kNewServiceId));
+ EXPECT_CALL(*gl_, GenBuffersARB(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId));
+ SpecializedSetup<BindBuffer, 0>();
+ BindBuffer cmd;
+ cmd.Init(GL_ARRAY_BUFFER, kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+ EXPECT_TRUE(GetBufferInfo(kNewServiceId) != NULL);
+}
+
TEST_F(GLES2DecoderTest1, BindBufferInvalidArgs0_0) {
EXPECT_CALL(*gl_, BindBuffer(_, _)).Times(0);
SpecializedSetup<BindBuffer, 0>();
@@ -42,6 +55,15 @@ TEST_F(GLES2DecoderTest1, BindBufferInvalidArgs0_0) {
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindBufferInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, BindBuffer(_, _)).Times(0);
+ SpecializedSetup<BindBuffer, 0>();
+ BindBuffer cmd;
+ cmd.Init(GL_ARRAY_BUFFER, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+}
+
TEST_F(GLES2DecoderTest1, BindFramebufferValidArgs) {
EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, kServiceFramebufferId));
SpecializedSetup<BindFramebuffer, 0>();
@@ -51,6 +73,19 @@ TEST_F(GLES2DecoderTest1, BindFramebufferValidArgs) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindFramebufferValidArgsNewId) {
+ EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, kNewServiceId));
+ EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId));
+ SpecializedSetup<BindFramebuffer, 0>();
+ BindFramebuffer cmd;
+ cmd.Init(GL_FRAMEBUFFER, kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+ EXPECT_TRUE(GetFramebufferInfo(kNewServiceId) != NULL);
+}
+
TEST_F(GLES2DecoderTest1, BindFramebufferInvalidArgs0_0) {
EXPECT_CALL(*gl_, BindFramebufferEXT(_, _)).Times(0);
SpecializedSetup<BindFramebuffer, 0>();
@@ -60,6 +95,15 @@ TEST_F(GLES2DecoderTest1, BindFramebufferInvalidArgs0_0) {
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindFramebufferInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, BindFramebufferEXT(_, _)).Times(0);
+ SpecializedSetup<BindFramebuffer, 0>();
+ BindFramebuffer cmd;
+ cmd.Init(GL_FRAMEBUFFER, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+}
+
TEST_F(GLES2DecoderTest1, BindRenderbufferValidArgs) {
EXPECT_CALL(
*gl_, BindRenderbufferEXT(GL_RENDERBUFFER, kServiceRenderbufferId));
@@ -70,6 +114,19 @@ TEST_F(GLES2DecoderTest1, BindRenderbufferValidArgs) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindRenderbufferValidArgsNewId) {
+ EXPECT_CALL(*gl_, BindRenderbufferEXT(GL_RENDERBUFFER, kNewServiceId));
+ EXPECT_CALL(*gl_, GenRenderbuffersEXT(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId));
+ SpecializedSetup<BindRenderbuffer, 0>();
+ BindRenderbuffer cmd;
+ cmd.Init(GL_RENDERBUFFER, kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+ EXPECT_TRUE(GetRenderbufferInfo(kNewServiceId) != NULL);
+}
+
TEST_F(GLES2DecoderTest1, BindRenderbufferInvalidArgs0_0) {
EXPECT_CALL(*gl_, BindRenderbufferEXT(_, _)).Times(0);
SpecializedSetup<BindRenderbuffer, 0>();
@@ -79,6 +136,15 @@ TEST_F(GLES2DecoderTest1, BindRenderbufferInvalidArgs0_0) {
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindRenderbufferInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, BindRenderbufferEXT(_, _)).Times(0);
+ SpecializedSetup<BindRenderbuffer, 0>();
+ BindRenderbuffer cmd;
+ cmd.Init(GL_RENDERBUFFER, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+}
+
TEST_F(GLES2DecoderTest1, BindTextureValidArgs) {
EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId));
SpecializedSetup<BindTexture, 0>();
@@ -88,6 +154,19 @@ TEST_F(GLES2DecoderTest1, BindTextureValidArgs) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindTextureValidArgsNewId) {
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kNewServiceId));
+ EXPECT_CALL(*gl_, GenTextures(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId));
+ SpecializedSetup<BindTexture, 0>();
+ BindTexture cmd;
+ cmd.Init(GL_TEXTURE_2D, kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+ EXPECT_TRUE(GetTextureInfo(kNewServiceId) != NULL);
+}
+
TEST_F(GLES2DecoderTest1, BindTextureInvalidArgs0_0) {
EXPECT_CALL(*gl_, BindTexture(_, _)).Times(0);
SpecializedSetup<BindTexture, 0>();
@@ -106,6 +185,15 @@ TEST_F(GLES2DecoderTest1, BindTextureInvalidArgs0_1) {
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
+TEST_F(GLES2DecoderTest1, BindTextureInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, BindTexture(_, _)).Times(0);
+ SpecializedSetup<BindTexture, 0>();
+ BindTexture cmd;
+ cmd.Init(GL_TEXTURE_2D, client_buffer_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+}
+
TEST_F(GLES2DecoderTest1, BlendColorValidArgs) {
EXPECT_CALL(*gl_, BlendColor(1, 2, 3, 4));
SpecializedSetup<BlendColor, 0>();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
index 4eb317a..0513d6a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -7,11 +7,16 @@
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/framebuffer_manager.h"
#include "gpu/command_buffer/service/gl_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/program_manager.h"
+#include "gpu/command_buffer/service/renderbuffer_manager.h"
+#include "gpu/command_buffer/service/shader_manager.h"
+#include "gpu/command_buffer/service/texture_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gpu {
@@ -123,6 +128,31 @@ class GLES2DecoderTestBase : public testing::Test {
return decoder_->GetServiceIdForTesting(client_id);
}
+ BufferManager::BufferInfo* GetBufferInfo(GLuint service_id) {
+ return group_.buffer_manager()->GetBufferInfo(service_id);
+ }
+
+ FramebufferManager::FramebufferInfo* GetFramebufferInfo(GLuint service_id) {
+ return group_.framebuffer_manager()->GetFramebufferInfo(service_id);
+ }
+
+ RenderbufferManager::RenderbufferInfo* GetRenderbufferInfo(
+ GLuint service_id) {
+ return group_.renderbuffer_manager()->GetRenderbufferInfo(service_id);
+ }
+
+ TextureManager::TextureInfo* GetTextureInfo(GLuint service_id) {
+ return group_.texture_manager()->GetTextureInfo(service_id);
+ }
+
+ ShaderManager::ShaderInfo* GetShaderInfo(GLuint service_id) {
+ return group_.shader_manager()->GetShaderInfo(service_id);
+ }
+
+ ProgramManager::ProgramInfo* GetProgramInfo(GLuint service_id) {
+ return group_.program_manager()->GetProgramInfo(service_id);
+ }
+
void SetBucketAsCString(uint32 bucket_id, const char* str);
// Note that the error is returned as GLint instead of GLenum.