diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-22 05:17:15 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-22 05:17:15 +0000 |
commit | 1958e0ef0fe59e392cab9bb351401beeb64e8379 (patch) | |
tree | 2dab1d4b2cdbbb50c1c6263b85430988d0ebecdb /gpu/command_buffer | |
parent | 9040ad23a3950685b08523d12305d9afcbbc7551 (diff) | |
download | chromium_src-1958e0ef0fe59e392cab9bb351401beeb64e8379.zip chromium_src-1958e0ef0fe59e392cab9bb351401beeb64e8379.tar.gz chromium_src-1958e0ef0fe59e392cab9bb351401beeb64e8379.tar.bz2 |
A bunch more GLES2 conformance test fixes.
1) All the glIsXXX functions were wrong
2) unlike buffers, renderbuffers, framebuffers, etc texture 0 is valid.
3) UseProgram accepts 0.
4) make glShaderSource fail if passed a NULL pointer (the spec doesn't say this afaict)
TEST=conformance tests
BUG=none
Review URL: http://codereview.chromium.org/1750005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
-rwxr-xr-x | gpu/command_buffer/build_gles2_cmd_buffer.py | 99 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils.cc | 12 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/gl_interface.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/gl_mock.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 121 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h | 46 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h | 46 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager.cc | 12 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager.h | 16 |
11 files changed, 256 insertions, 114 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index b2782cb..67f683a 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -28,6 +28,7 @@ _LICENSE = """// Copyright (c) 2009 The Chromium Authors. All rights reserved. # # *) Any argument that is a resourceID has been changed to GLid<Type>. # (not pointer arguments) and if it's allowed to be zero it's GLidZero<Type> +# If it's allowed to not exist it's GLidBind<Type> # # *) All GLenums have been changed to GLenumTypeOfEnum # @@ -35,10 +36,10 @@ _GL_FUNCTIONS = """ GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); GL_APICALL void GL_APIENTRY glAttachShader (GLidProgram program, GLidShader shader); GL_APICALL void GL_APIENTRY glBindAttribLocation (GLidProgram program, GLuint index, const char* name); -GL_APICALL void GL_APIENTRY glBindBuffer (GLenumBufferTarget target, GLidZeroBuffer buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget target, GLidZeroFramebuffer framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLidZeroRenderbuffer renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget target, GLidZeroTexture texture); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenumBufferTarget target, GLidBindBuffer buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget target, GLidBindFramebuffer framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLidBindRenderbuffer renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget target, GLidBindTexture texture); GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); GL_APICALL void GL_APIENTRY glBlendEquation ( GLenumEquation mode ); GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenumEquation modeRGB, GLenumEquation modeAlpha); @@ -115,11 +116,11 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLe GL_APICALL void GL_APIENTRY glHint (GLenumHintTarget target, GLenumHintMode mode); GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLidBuffer buffer); GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenumCapability cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLidFramebuffer framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLidProgram program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLidRenderbuffer renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader (GLidShader shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLidTexture texture); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); GL_APICALL void GL_APIENTRY glLinkProgram (GLidProgram program); GL_APICALL void GL_APIENTRY glPixelStorei (GLenumPixelStore pname, GLintPixelStoreAlignment param); @@ -162,7 +163,7 @@ GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLbooleanFalse transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLbooleanFalse transpose, const GLfloat* value); GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLbooleanFalse transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram (GLidProgram program); +GL_APICALL void GL_APIENTRY glUseProgram (GLidZeroProgram program); GL_APICALL void GL_APIENTRY glValidateProgram (GLidProgram program); GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); @@ -1206,13 +1207,37 @@ _FUNCTION_INFO = { 'immediate': False, 'result': ['SizedResult<GLuint>'], }, - 'IsBuffer': {'type': 'Is'}, + 'IsBuffer': { + 'type': 'Is', + 'decoder_func': 'DoIsBuffer', + 'expectation': False, + }, 'IsEnabled': {'type': 'Is'}, - 'IsFramebuffer': {'type': 'Is', 'decoder_func': 'glIsFramebufferEXT'}, - 'IsProgram': {'type': 'Is'}, - 'IsRenderbuffer': {'type': 'Is', 'decoder_func': 'glIsRenderbufferEXT'}, - 'IsShader': {'type': 'Is'}, - 'IsTexture': {'type': 'Is'}, + 'IsFramebuffer': { + 'type': 'Is', + 'decoder_func': 'DoIsFramebuffer', + 'expectation': False, + }, + 'IsProgram': { + 'type': 'Is', + 'decoder_func': 'DoIsProgram', + 'expectation': False, + }, + 'IsRenderbuffer': { + 'type': 'Is', + 'decoder_func': 'DoIsRenderbuffer', + 'expectation': False, + }, + 'IsShader': { + 'type': 'Is', + 'decoder_func': 'DoIsShader', + 'expectation': False, + }, + 'IsTexture': { + 'type': 'Is', + 'decoder_func': 'DoIsTexture', + 'expectation': False, + }, 'LinkProgram': {'decoder_func': 'DoLinkProgram'}, 'PixelStorei': {'type': 'Manual'}, 'RenderbufferStorage': { @@ -3874,11 +3899,11 @@ class ResourceIdArgument(Argument): return "kService%sId" % self.resource_type -class ResourceIdZeroArgument(Argument): - """Represents a resource id argument to a function that can be zero.""" +class ResourceIdBindArgument(Argument): + """Represents a resource id argument to a bind function.""" def __init__(self, name, type): - match = re.match("(GLidZero\w+)", type) + match = re.match("(GLidBind\w+)", type) self.resource_type = match.group(1)[8:] type = type.replace(match.group(1), "GLuint") Argument.__init__(self, name, type) @@ -3906,6 +3931,40 @@ class ResourceIdZeroArgument(Argument): return ("client_texture_id_", "kNoError", "GL_INVALID_OPERATION") +class ResourceIdZeroArgument(Argument): + """Represents a resource id argument to a function that can be zero.""" + + def __init__(self, name, type): + match = re.match("(GLidZero\w+)", type) + self.resource_type = match.group(1)[8:] + type = type.replace(match.group(1), "GLuint") + Argument.__init__(self, name, type) + + def WriteGetCode(self, file): + """Overridden from Argument.""" + file.Write(" %s %s = c.%s;\n" % (self.type, self.name, self.name)) + file.Write(" if (%s != 0 && !id_manager()->GetServiceId(%s, &%s)) {\n" % + (self.name, self.name, self.name)) + file.Write(" SetGLError(GL_INVALID_VALUE);\n") + file.Write(" return error::kNoError;\n") + file.Write(" }\n") + + def GetValidArg(self, offset, index): + return "client_%s_id_" % self.resource_type.lower() + + 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.""" @@ -4274,6 +4333,8 @@ def CreateArg(arg_string): arg_parts[-1], " ".join(arg_parts[0:-1])) # Is this a resource argument? Must come after pointer check. + elif arg_parts[0].startswith('GLidBind'): + return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) elif arg_parts[0].startswith('GLidZero'): return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) elif arg_parts[0].startswith('GLid'): diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 39b55d0..583b0d5 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -690,6 +690,11 @@ void GLES2Implementation::ShaderSource( // Compute the total size. uint32 total_size = 1; for (GLsizei ii = 0; ii < count; ++ii) { + // I shouldn't have to check for this. The spec doesn't allow this + if (!source[ii]) { + SetGLError(GL_INVALID_VALUE); + return; + } total_size += (length && length[ii] >= 0) ? length[ii] : strlen(source[ii]); } @@ -699,6 +704,7 @@ void GLES2Implementation::ShaderSource( uint32 offset = 0; for (GLsizei ii = 0; ii <= count; ++ii) { const char* src = ii < count ? source[ii] : ""; + uint32 size = ii < count ? (length ? length[ii] : strlen(src)) : 1; while (size) { uint32 part_size = std::min(size, max_size); diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index 3421fc4..ab60f0b 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -466,6 +466,18 @@ uint32 GLES2Util::GLErrorBitToGLError(uint32 error_bit) { } } +uint32 GLES2Util::IndexToGLFaceTarget(int index) { + static uint32 faces[] = { + GL_TEXTURE_CUBE_MAP_POSITIVE_X, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, + }; + return faces[index]; +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index e9ad91a..8099fe2 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -54,6 +54,8 @@ inline bool SafeAddUint32(uint32 a, uint32 b, uint32* dst) { // Utilties for GLES2 support. class GLES2Util { public: + static const int kNumFaces = 6; + explicit GLES2Util( int num_compressed_texture_formats) : num_compressed_texture_formats_(num_compressed_texture_formats) { @@ -76,6 +78,8 @@ class GLES2Util { static uint32 GLErrorBitToGLError(uint32 error_bit); + static uint32 IndexToGLFaceTarget(int index); + private: int num_compressed_texture_formats_; }; diff --git a/gpu/command_buffer/service/gl_interface.h b/gpu/command_buffer/service/gl_interface.h index fd934bf..29ce544 100644 --- a/gpu/command_buffer/service/gl_interface.h +++ b/gpu/command_buffer/service/gl_interface.h @@ -253,11 +253,11 @@ class GLInterface { virtual GLboolean IsEnabled(GLenum cap) = 0; - virtual GLboolean IsFramebufferEXT(GLuint framebuffer) = 0; + virtual GLboolean IsFramebuffer(GLuint framebuffer) = 0; virtual GLboolean IsProgram(GLuint program) = 0; - virtual GLboolean IsRenderbufferEXT(GLuint renderbuffer) = 0; + virtual GLboolean IsRenderbuffer(GLuint renderbuffer) = 0; virtual GLboolean IsShader(GLuint shader) = 0; diff --git a/gpu/command_buffer/service/gl_mock.h b/gpu/command_buffer/service/gl_mock.h index 41be895..3378112 100644 --- a/gpu/command_buffer/service/gl_mock.h +++ b/gpu/command_buffer/service/gl_mock.h @@ -225,11 +225,11 @@ class MockGLInterface : public GLInterface { MOCK_METHOD1(IsEnabled, GLboolean(GLenum cap)); - MOCK_METHOD1(IsFramebufferEXT, GLboolean(GLuint framebuffer)); + MOCK_METHOD1(IsFramebuffer, GLboolean(GLuint framebuffer)); MOCK_METHOD1(IsProgram, GLboolean(GLuint program)); - MOCK_METHOD1(IsRenderbufferEXT, GLboolean(GLuint renderbuffer)); + MOCK_METHOD1(IsRenderbuffer, GLboolean(GLuint renderbuffer)); MOCK_METHOD1(IsShader, GLboolean(GLuint shader)); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 13654c1..953bd14 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -722,6 +722,14 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, void DoGetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* dst); + // Wrappers for glIsXXX functions. + bool DoIsBuffer(GLuint client_id); + bool DoIsFramebuffer(GLuint client_id); + bool DoIsProgram(GLuint client_id); + bool DoIsRenderbuffer(GLuint client_id); + bool DoIsShader(GLuint client_id); + bool DoIsTexture(GLuint client_id); + // Wrapper for glLinkProgram void DoLinkProgram(GLuint program); @@ -1206,6 +1214,12 @@ bool GLES2DecoderImpl::Initialize(GLContext* context, new VertexAttribInfo[group_->max_vertex_attribs()]); texture_units_.reset( new TextureUnit[group_->max_texture_units()]); + for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { + texture_units_[tt].bound_texture_2d = + texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); + texture_units_[tt].bound_texture_cube_map = + texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); + } GLuint ids[2]; glGenTextures(2, ids); // Make black textures for replacing non-renderable textures. @@ -1217,17 +1231,9 @@ bool GLES2DecoderImpl::Initialize(GLContext* context, GL_UNSIGNED_BYTE, black); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_CUBE_MAP, black_cube_texture_id_); - static GLenum faces[] = { - GL_TEXTURE_CUBE_MAP_POSITIVE_X, - GL_TEXTURE_CUBE_MAP_NEGATIVE_X, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, - }; - for (size_t ii = 0; ii < arraysize(faces); ++ii) { - glTexImage2D(faces[ii], 0, GL_RGBA, 1, 1, 0, GL_RGBA, - GL_UNSIGNED_BYTE, black); + for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { + glTexImage2D(GLES2Util::IndexToGLFaceTarget(ii), 0, GL_RGBA, 1, 1, 0, + GL_RGBA, GL_UNSIGNED_BYTE, black); } glBindTexture(GL_TEXTURE_CUBE_MAP, 0); CHECK_GL_ERROR(); @@ -1514,7 +1520,7 @@ bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { #if !defined(UNIT_TEST) // Clear the saved offscreen color texture. Use default GL context // to ensure clear is not affected by client set state. - { + { // NOLINT ScopedDefaultGLContext scoped_context(this); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, offscreen_target_frame_buffer_->id()); @@ -1551,7 +1557,7 @@ bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { #if !defined(UNIT_TEST) // Clear offscreen frame buffer to its initial state. Use default GL context // to ensure clear is not affected by client set state. - { + { // NOLINT ScopedDefaultGLContext scoped_context(this); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, offscreen_target_frame_buffer_->id()); @@ -1840,7 +1846,6 @@ void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { } void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { - TextureManager::TextureInfo* 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 texture info for it. @@ -1848,17 +1853,17 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_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)) { - SetGLError(GL_INVALID_OPERATION); - return; - } - if (info->target() == 0) { - texture_manager()->SetInfoTarget(info, target); - } + TextureManager::TextureInfo* info = + service_id ? GetTextureInfo(service_id) : + texture_manager()->GetDefaultTextureInfo(target); + // 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)) { + SetGLError(GL_INVALID_OPERATION); + return; + } + if (info->target() == 0) { + texture_manager()->SetInfoTarget(info, target); } glBindTexture(target, service_id); TextureUnit& unit = texture_units_[active_texture_unit_]; @@ -2558,6 +2563,54 @@ void GLES2DecoderImpl::DoGetShaderSource( dst[size] = '\0'; } +bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { + GLuint service_id = 0; + if (!id_manager()->GetServiceId(client_id, &service_id)) { + return false; + } + return GetBufferInfo(service_id) != NULL; +} + +bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) { + GLuint service_id = 0; + if (!id_manager()->GetServiceId(client_id, &service_id)) { + return false; + } + return GetFramebufferInfo(service_id) != NULL; +} + +bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) { + GLuint service_id = 0; + if (!id_manager()->GetServiceId(client_id, &service_id)) { + return false; + } + return GetProgramInfo(service_id) != NULL; +} + +bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) { + GLuint service_id = 0; + if (!id_manager()->GetServiceId(client_id, &service_id)) { + return false; + } + return GetRenderbufferInfo(service_id) != NULL; +} + +bool GLES2DecoderImpl::DoIsShader(GLuint client_id) { + GLuint service_id = 0; + if (!id_manager()->GetServiceId(client_id, &service_id)) { + return false; + } + return GetShaderInfo(service_id) != NULL; +} + +bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { + GLuint service_id = 0; + if (!id_manager()->GetServiceId(client_id, &service_id)) { + return false; + } + return GetTextureInfo(service_id) != NULL; +} + error::Error GLES2DecoderImpl::HandleVertexAttribPointer( uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { if (bound_array_buffer_ && !bound_array_buffer_->IsDeleted()) { @@ -2872,8 +2925,24 @@ error::Error GLES2DecoderImpl::HandleGetString( SetGLError(GL_INVALID_ENUM); return error::kNoError; } + const char* gl_str = reinterpret_cast<const char*>(glGetString(name)); + const char* str = NULL; + switch (name) { + case GL_VERSION: + str = "OpenGL ES 2.0 Chromium"; + break; + case GL_SHADING_LANGUAGE_VERSION: + str = "OpenGL ES GLSL ES 1.0 Chromium"; + break; + case GL_EXTENSIONS: + str = ""; + break; + default: + str = gl_str; + break; + } Bucket* bucket = CreateBucket(c.bucket_id); - bucket->SetFromString(reinterpret_cast<const char*>(glGetString(name))); + bucket->SetFromString(str); return error::kNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index fd0c9f8..0412a1d 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1492,7 +1492,7 @@ error::Error GLES2DecoderImpl::HandleIsBuffer( if (!result_dst) { return error::kOutOfBounds; } - *result_dst = glIsBuffer(buffer); + *result_dst = DoIsBuffer(buffer); return error::kNoError; } @@ -1515,86 +1515,66 @@ error::Error GLES2DecoderImpl::HandleIsEnabled( error::Error GLES2DecoderImpl::HandleIsFramebuffer( uint32 immediate_data_size, const gles2::IsFramebuffer& c) { - GLuint framebuffer; - if (!id_manager()->GetServiceId(c.framebuffer, &framebuffer)) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } + GLuint framebuffer = static_cast<GLuint>(c.framebuffer); typedef IsFramebuffer::Result Result; Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); if (!result_dst) { return error::kOutOfBounds; } - *result_dst = glIsFramebufferEXT(framebuffer); + *result_dst = DoIsFramebuffer(framebuffer); return error::kNoError; } error::Error GLES2DecoderImpl::HandleIsProgram( uint32 immediate_data_size, const gles2::IsProgram& c) { - GLuint program; - if (!id_manager()->GetServiceId(c.program, &program)) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } + GLuint program = static_cast<GLuint>(c.program); typedef IsProgram::Result Result; Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); if (!result_dst) { return error::kOutOfBounds; } - *result_dst = glIsProgram(program); + *result_dst = DoIsProgram(program); return error::kNoError; } error::Error GLES2DecoderImpl::HandleIsRenderbuffer( uint32 immediate_data_size, const gles2::IsRenderbuffer& c) { - GLuint renderbuffer; - if (!id_manager()->GetServiceId(c.renderbuffer, &renderbuffer)) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } + GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer); typedef IsRenderbuffer::Result Result; Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); if (!result_dst) { return error::kOutOfBounds; } - *result_dst = glIsRenderbufferEXT(renderbuffer); + *result_dst = DoIsRenderbuffer(renderbuffer); return error::kNoError; } error::Error GLES2DecoderImpl::HandleIsShader( uint32 immediate_data_size, const gles2::IsShader& c) { - GLuint shader; - if (!id_manager()->GetServiceId(c.shader, &shader)) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } + GLuint shader = static_cast<GLuint>(c.shader); typedef IsShader::Result Result; Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); if (!result_dst) { return error::kOutOfBounds; } - *result_dst = glIsShader(shader); + *result_dst = DoIsShader(shader); return error::kNoError; } error::Error GLES2DecoderImpl::HandleIsTexture( uint32 immediate_data_size, const gles2::IsTexture& c) { - GLuint texture; - if (!id_manager()->GetServiceId(c.texture, &texture)) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } + GLuint texture = static_cast<GLuint>(c.texture); typedef IsTexture::Result Result; Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); if (!result_dst) { return error::kOutOfBounds; } - *result_dst = glIsTexture(texture); + *result_dst = DoIsTexture(texture); return error::kNoError; } @@ -2612,8 +2592,8 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate( error::Error GLES2DecoderImpl::HandleUseProgram( uint32 immediate_data_size, const gles2::UseProgram& c) { - GLuint program; - if (!id_manager()->GetServiceId(c.program, &program)) { + GLuint program = c.program; + if (program != 0 && !id_manager()->GetServiceId(program, &program)) { SetGLError(GL_INVALID_VALUE); return error::kNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h index 64f1424..56a56ac 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h @@ -136,7 +136,6 @@ TEST_F(GLES2DecoderTest2, HintInvalidArgs0_0) { } TEST_F(GLES2DecoderTest2, IsBufferValidArgs) { - EXPECT_CALL(*gl_, IsBuffer(kServiceBufferId)); SpecializedSetup<IsBuffer, 0>(); IsBuffer cmd; cmd.Init(client_buffer_id_, shared_memory_id_, shared_memory_offset_); @@ -145,7 +144,6 @@ TEST_F(GLES2DecoderTest2, IsBufferValidArgs) { } TEST_F(GLES2DecoderTest2, IsBufferInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsBuffer(kServiceBufferId)).Times(0); SpecializedSetup<IsBuffer, 0>(); IsBuffer cmd; cmd.Init(client_buffer_id_, kInvalidSharedMemoryId, shared_memory_offset_); @@ -192,101 +190,87 @@ TEST_F(GLES2DecoderTest2, IsEnabledInvalidArgsBadSharedMemoryId) { } TEST_F(GLES2DecoderTest2, IsFramebufferValidArgs) { - EXPECT_CALL(*gl_, IsFramebufferEXT(kServiceFramebufferId)); SpecializedSetup<IsFramebuffer, 0>(); IsFramebuffer cmd; - cmd.Init(client_framebuffer_id_, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, IsFramebufferInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsFramebufferEXT(kServiceFramebufferId)).Times(0); SpecializedSetup<IsFramebuffer, 0>(); IsFramebuffer cmd; - cmd.Init( - client_framebuffer_id_, kInvalidSharedMemoryId, shared_memory_offset_); + cmd.Init(1, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init( - client_framebuffer_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } TEST_F(GLES2DecoderTest2, IsProgramValidArgs) { - EXPECT_CALL(*gl_, IsProgram(kServiceProgramId)); SpecializedSetup<IsProgram, 0>(); IsProgram cmd; - cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, IsProgramInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsProgram(kServiceProgramId)).Times(0); SpecializedSetup<IsProgram, 0>(); IsProgram cmd; - cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_); + cmd.Init(1, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init(client_program_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } TEST_F(GLES2DecoderTest2, IsRenderbufferValidArgs) { - EXPECT_CALL(*gl_, IsRenderbufferEXT(kServiceRenderbufferId)); SpecializedSetup<IsRenderbuffer, 0>(); IsRenderbuffer cmd; - cmd.Init(client_renderbuffer_id_, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, IsRenderbufferInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsRenderbufferEXT(kServiceRenderbufferId)).Times(0); SpecializedSetup<IsRenderbuffer, 0>(); IsRenderbuffer cmd; - cmd.Init( - client_renderbuffer_id_, kInvalidSharedMemoryId, shared_memory_offset_); + cmd.Init(1, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init( - client_renderbuffer_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } TEST_F(GLES2DecoderTest2, IsShaderValidArgs) { - EXPECT_CALL(*gl_, IsShader(kServiceShaderId)); SpecializedSetup<IsShader, 0>(); IsShader cmd; - cmd.Init(client_shader_id_, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, IsShaderInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsShader(kServiceShaderId)).Times(0); SpecializedSetup<IsShader, 0>(); IsShader cmd; - cmd.Init(client_shader_id_, kInvalidSharedMemoryId, shared_memory_offset_); + cmd.Init(1, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init(client_shader_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } TEST_F(GLES2DecoderTest2, IsTextureValidArgs) { - EXPECT_CALL(*gl_, IsTexture(kServiceTextureId)); SpecializedSetup<IsTexture, 0>(); IsTexture cmd; - cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, IsTextureInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsTexture(kServiceTextureId)).Times(0); SpecializedSetup<IsTexture, 0>(); IsTexture cmd; - cmd.Init(client_texture_id_, kInvalidSharedMemoryId, shared_memory_offset_); + cmd.Init(1, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init(client_texture_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index 4369199..a895e27 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc @@ -4,6 +4,7 @@ #include "gpu/command_buffer/service/texture_manager.h" #include "base/bits.h" +#include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" @@ -263,6 +264,17 @@ TextureManager::TextureManager( max_cube_map_levels_(ComputeMipMapCount(max_cube_map_texture_size, max_cube_map_texture_size, max_cube_map_texture_size)) { + default_texture_2d_ = TextureInfo::Ref(new TextureInfo(0)); + SetInfoTarget(default_texture_2d_, GL_TEXTURE_2D); + default_texture_2d_->SetLevelInfo( + GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); + default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(0)); + SetInfoTarget(default_texture_cube_map_, GL_TEXTURE_CUBE_MAP); + for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { + default_texture_cube_map_->SetLevelInfo( + GLES2Util::IndexToGLFaceTarget(ii), + 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); + } } TextureManager::TextureInfo* TextureManager::CreateTextureInfo( diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h index 2dba85d..a2db386 100644 --- a/gpu/command_buffer/service/texture_manager.h +++ b/gpu/command_buffer/service/texture_manager.h @@ -29,6 +29,7 @@ class TextureManager { explicit TextureInfo(GLuint texture_id) : texture_id_(texture_id), + deleted_(false), target_(0), min_filter_(GL_NEAREST_MIPMAP_LINEAR), mag_filter_(GL_LINEAR), @@ -102,7 +103,7 @@ class TextureManager { void SetParameter(GLenum pname, GLint param); bool IsDeleted() const { - return texture_id_ == 0; + return deleted_; } private: @@ -135,6 +136,7 @@ class TextureManager { void MarkAsDeleted() { texture_id_ = 0; + deleted_ = true; } bool NeedsMips() const { @@ -164,6 +166,9 @@ class TextureManager { // The id of the texure GLuint texture_id_; + // Whether this texture has been deleted. + bool deleted_; + // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. GLenum target_; @@ -237,6 +242,11 @@ class TextureManager { // Removes a texture info. void RemoveTextureInfo(GLuint texture_id); + TextureInfo* GetDefaultTextureInfo(GLenum target) { + return target == GL_TEXTURE_2D ? default_texture_2d_ : + default_texture_cube_map_; + } + private: // Info for each texture in the system. // TODO(gman): Choose a faster container. @@ -248,6 +258,10 @@ class TextureManager { GLint max_levels_; GLint max_cube_map_levels_; + // The default textures for each target (texture name = 0) + TextureInfo::Ref default_texture_2d_; + TextureInfo::Ref default_texture_cube_map_; + DISALLOW_COPY_AND_ASSIGN(TextureManager); }; |