diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 00:13:56 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 00:13:56 +0000 |
commit | 8609397d9932b0f743dd4bbe55246632fb597945 (patch) | |
tree | 76292d97a3534cb53f2e8e55e50af4971efb50fb /gpu/command_buffer | |
parent | b40e2c007431876d67d4c57b92135a2132719c0f (diff) | |
download | chromium_src-8609397d9932b0f743dd4bbe55246632fb597945.zip chromium_src-8609397d9932b0f743dd4bbe55246632fb597945.tar.gz chromium_src-8609397d9932b0f743dd4bbe55246632fb597945.tar.bz2 |
Track the bound framebuffer and renderbuffer and
allow ID = 0 to make it through to the glBindXXX
functions.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/783002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
-rwxr-xr-x | gpu/command_buffer/build_gles2_cmd_buffer.py | 50 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 35 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h | 24 |
3 files changed, 90 insertions, 19 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index af2f9b0..e29ef07 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -27,7 +27,7 @@ _LICENSE = """// Copyright (c) 2009 The Chromium Authors. All rights reserved. # Edits: # # *) Any argument that is a resourceID has been changed to GLid<Type>. -# (not pointer arguments) +# (not pointer arguments) and if it's allowed to be zero it's GLidZero<Type> # # *) All GLenums have been changed to GLenumTypeOfEnum # @@ -35,10 +35,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, GLidBuffer buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget target, GLidFramebuffer framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLidRenderbuffer renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget target, GLidTexture texture); +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 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); @@ -845,8 +845,14 @@ _FUNCTION_INFO = { 'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'expectation': False}, 'BindAttribLocation': {'type': 'GLchar'}, 'BindBuffer': {'decoder_func': 'DoBindBuffer'}, - 'BindFramebuffer': {'decoder_func': 'glBindFramebufferEXT'}, - 'BindRenderbuffer': {'decoder_func': 'glBindRenderbufferEXT'}, + 'BindFramebuffer': { + 'decoder_func': 'DoBindFramebuffer', + 'gl_test_func': 'glBindFramebufferEXT', + }, + 'BindRenderbuffer': { + 'decoder_func': 'DoBindRenderbuffer', + 'gl_test_func': 'glBindRenderbufferEXT', + }, 'BindTexture': {'decoder_func': 'DoBindTexture'}, 'BufferData': {'type': 'Manual', 'immediate': True}, 'BufferSubData': {'type': 'Data', 'decoder_func': 'DoBufferSubData'}, @@ -3579,6 +3585,34 @@ class ResourceIdArgument(Argument): def GetValidGLArg(self, offset, index): return "kService%sId" % self.resource_type + +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.""" + 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}) + + def GetValidArg(self, offset, index): + return "client_%s_id_" % self.resource_type.lower() + + def GetValidGLArg(self, offset, index): + return "kService%sId" % self.resource_type + + class Function(object): """A class that represents a function.""" @@ -3874,6 +3908,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('GLidZero'): + return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) elif arg_parts[0].startswith('GLid'): return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 4b2e520..8c9be47 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -431,6 +431,12 @@ class GLES2DecoderImpl : public GLES2Decoder { // Wrapper for glBindBuffer since we need to track the current targets. void DoBindBuffer(GLenum target, GLuint buffer); + // Wrapper for glBindFramebuffer since we need to track the current targets. + void DoBindFramebuffer(GLenum target, GLuint framebuffer); + + // Wrapper for glBindRenderbuffer since we need to track the current targets. + void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); + // Wrapper for glBindTexture since we need to track the current targets. void DoBindTexture(GLenum target, GLuint texture); @@ -547,6 +553,8 @@ class GLES2DecoderImpl : public GLES2Decoder { uint32 shm_id, uint32 shm_offset, error::Error* error, GLuint* service_id, void** result); + bool ValidateGLenumCompressedTextureInternalFormat(GLenum format); + // Generate a member function prototype for each command in an automated and // typesafe way. #define GLES2_CMD_OP(name) \ @@ -599,6 +607,12 @@ class GLES2DecoderImpl : public GLES2Decoder { // The program in use by glUseProgram ProgramManager::ProgramInfo::Ref current_program_; + // The currently bound framebuffer + GLuint bound_framebuffer_; + + // The currently bound renderbuffer + GLuint bound_renderbuffer_; + #if defined(UNIT_TEST) #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) #elif defined(OS_WIN) @@ -636,6 +650,8 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) active_texture_unit_(0), black_2d_texture_id_(0), black_cube_texture_id_(0), + bound_framebuffer_(0), + bound_renderbuffer_(0), #if defined(UNIT_TEST) #elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) #elif defined(OS_WIN) @@ -1287,6 +1303,11 @@ void GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) { } } +bool GLES2DecoderImpl::ValidateGLenumCompressedTextureInternalFormat(GLenum) { + // TODO(gman): Add support for compressed texture formats. + return false; +} + void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { if (texture_unit > group_->max_texture_units()) { SetGLError(GL_INVALID_ENUM); @@ -1323,6 +1344,16 @@ void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) { glBindBuffer(target, buffer); } +void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint framebuffer) { + bound_framebuffer_ = framebuffer; + glBindFramebufferEXT(target, framebuffer); +} + +void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint renderbuffer) { + bound_renderbuffer_ = renderbuffer; + glBindRenderbufferEXT(target, renderbuffer); +} + void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint texture) { TextureManager::TextureInfo* info = NULL; if (texture) { @@ -2125,9 +2156,9 @@ error::Error GLES2DecoderImpl::DoCompressedTexImage2D( GLint border, GLsizei image_size, const void* data) { - // TODO(gman): Validate internal_format // TODO(gman): Validate image_size is correct for width, height and format. - if (!ValidateGLenumTextureTarget(target)) { + if (!ValidateGLenumTextureTarget(target) || + !ValidateGLenumCompressedTextureInternalFormat(internal_format)) { SetGLError(GL_INVALID_ENUM); 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 eb66e7f..7b123bc 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -72,8 +72,9 @@ error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate( error::Error GLES2DecoderImpl::HandleBindBuffer( uint32 immediate_data_size, const gles2::BindBuffer& c) { GLenum target = static_cast<GLenum>(c.target); - GLuint buffer; - if (!id_manager()->GetServiceId(c.buffer, &buffer)) { + GLuint buffer = c.buffer; + if (buffer != 0u && + !id_manager()->GetServiceId(buffer, &buffer)) { SetGLError(GL_INVALID_VALUE); return error::kNoError; } @@ -88,8 +89,9 @@ error::Error GLES2DecoderImpl::HandleBindBuffer( error::Error GLES2DecoderImpl::HandleBindFramebuffer( uint32 immediate_data_size, const gles2::BindFramebuffer& c) { GLenum target = static_cast<GLenum>(c.target); - GLuint framebuffer; - if (!id_manager()->GetServiceId(c.framebuffer, &framebuffer)) { + GLuint framebuffer = c.framebuffer; + if (framebuffer != 0u && + !id_manager()->GetServiceId(framebuffer, &framebuffer)) { SetGLError(GL_INVALID_VALUE); return error::kNoError; } @@ -97,15 +99,16 @@ error::Error GLES2DecoderImpl::HandleBindFramebuffer( SetGLError(GL_INVALID_ENUM); return error::kNoError; } - glBindFramebufferEXT(target, framebuffer); + DoBindFramebuffer(target, framebuffer); return error::kNoError; } error::Error GLES2DecoderImpl::HandleBindRenderbuffer( uint32 immediate_data_size, const gles2::BindRenderbuffer& c) { GLenum target = static_cast<GLenum>(c.target); - GLuint renderbuffer; - if (!id_manager()->GetServiceId(c.renderbuffer, &renderbuffer)) { + GLuint renderbuffer = c.renderbuffer; + if (renderbuffer != 0u && + !id_manager()->GetServiceId(renderbuffer, &renderbuffer)) { SetGLError(GL_INVALID_VALUE); return error::kNoError; } @@ -113,15 +116,16 @@ error::Error GLES2DecoderImpl::HandleBindRenderbuffer( SetGLError(GL_INVALID_ENUM); return error::kNoError; } - glBindRenderbufferEXT(target, renderbuffer); + DoBindRenderbuffer(target, renderbuffer); return error::kNoError; } error::Error GLES2DecoderImpl::HandleBindTexture( uint32 immediate_data_size, const gles2::BindTexture& c) { GLenum target = static_cast<GLenum>(c.target); - GLuint texture; - if (!id_manager()->GetServiceId(c.texture, &texture)) { + GLuint texture = c.texture; + if (texture != 0u && + !id_manager()->GetServiceId(texture, &texture)) { SetGLError(GL_INVALID_VALUE); return error::kNoError; } |