Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| =================================================================== |
| --- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 112643) |
| +++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy) |
| @@ -751,6 +751,14 @@ |
| GLuint io_surface_id, |
| GLuint plane); |
| + // Wrapper for TexStorage2DEXT. |
| + error::Error DoTexStorage2DEXT( |
| + GLenum target, |
| + GLint levels, |
| + GLenum internal_format, |
| + GLsizei width, |
| + GLsizei height); |
| + |
| // Creates a ProgramInfo for the given program. |
| ProgramManager::ProgramInfo* CreateProgramInfo( |
| GLuint client_id, GLuint service_id) { |
| @@ -7684,7 +7692,99 @@ |
| #endif |
| } |
| +static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) |
| +{ |
|
greggman
2011/12/02 18:33:24
This is not chromium style
should be
type functi
vangelis
2011/12/03 00:19:53
Done.
|
| + switch (internalformat) |
| + { |
| + case GL_RGB565: return GL_RGB; |
| + case GL_RGBA4: return GL_RGBA; |
| + case GL_RGB5_A1: return GL_RGBA; |
| + case GL_RGB8_OES: return GL_RGB; |
| + case GL_RGBA8_OES: return GL_RGBA; |
| + case GL_LUMINANCE8_ALPHA8_EXT: return GL_LUMINANCE_ALPHA; |
| + case GL_LUMINANCE8_EXT: return GL_LUMINANCE; |
| + case GL_ALPHA8_EXT: return GL_ALPHA; |
| + case GL_RGBA32F_EXT: return GL_RGBA; |
| + case GL_RGB32F_EXT: return GL_RGB; |
| + case GL_ALPHA32F_EXT: return GL_ALPHA; |
| + case GL_LUMINANCE32F_EXT: return GL_LUMINANCE; |
| + case GL_LUMINANCE_ALPHA32F_EXT: return GL_LUMINANCE_ALPHA; |
| + case GL_RGBA16F_EXT: return GL_RGBA; |
| + case GL_RGB16F_EXT: return GL_RGB; |
| + case GL_ALPHA16F_EXT: return GL_ALPHA; |
| + case GL_LUMINANCE16F_EXT: return GL_LUMINANCE; |
| + case GL_LUMINANCE_ALPHA16F_EXT: return GL_LUMINANCE_ALPHA; |
| + case GL_BGRA8_EXT: return GL_BGRA_EXT; |
| + default: return GL_NONE; // Unsupported |
| + } |
| +} |
| +GLenum ExtractTypeFromStorageFormat(GLenum internalformat) |
|
greggman
2011/12/02 18:33:24
style issues same as above. Should be static?
vangelis
2011/12/03 00:19:53
Done and Done
|
| +{ |
| + switch (internalformat) |
| + { |
| + case GL_RGB565: return GL_UNSIGNED_SHORT_5_6_5; |
| + case GL_RGBA4: return GL_UNSIGNED_SHORT_4_4_4_4; |
| + case GL_RGB5_A1: return GL_UNSIGNED_SHORT_5_5_5_1; |
| + case GL_RGB8_OES: return GL_UNSIGNED_BYTE; |
| + case GL_RGBA8_OES: return GL_UNSIGNED_BYTE; |
| + case GL_LUMINANCE8_ALPHA8_EXT: return GL_UNSIGNED_BYTE; |
| + case GL_LUMINANCE8_EXT: return GL_UNSIGNED_BYTE; |
| + case GL_ALPHA8_EXT: return GL_UNSIGNED_BYTE; |
| + case GL_RGBA32F_EXT: return GL_FLOAT; |
| + case GL_RGB32F_EXT: return GL_FLOAT; |
| + case GL_ALPHA32F_EXT: return GL_FLOAT; |
| + case GL_LUMINANCE32F_EXT: return GL_FLOAT; |
| + case GL_LUMINANCE_ALPHA32F_EXT: return GL_FLOAT; |
| + case GL_RGBA16F_EXT: return GL_HALF_FLOAT_OES; |
| + case GL_RGB16F_EXT: return GL_HALF_FLOAT_OES; |
| + case GL_ALPHA16F_EXT: return GL_HALF_FLOAT_OES; |
| + case GL_LUMINANCE16F_EXT: return GL_HALF_FLOAT_OES; |
| + case GL_LUMINANCE_ALPHA16F_EXT: return GL_HALF_FLOAT_OES; |
| + case GL_BGRA8_EXT: return GL_UNSIGNED_BYTE; |
| + default: return GL_NONE; // Unsupported |
| + } |
| +} |
| + |
| +error::Error GLES2DecoderImpl::DoTexStorage2DEXT( |
|
greggman
2011/12/02 18:33:24
There's no reason for this to return an error. sho
vangelis
2011/12/03 00:19:53
Done.
|
| + GLenum target, |
| + GLint levels, |
| + GLenum internal_format, |
| + GLsizei width, |
| + GLsizei height) { |
| + if (!texture_manager()->ValidForTarget( |
| + feature_info_, target, 1, width, height, 1) || |
|
greggman
2011/12/02 18:33:24
the 1 after target should be 0
Also, you probably
vangelis
2011/12/03 00:19:53
Done.
|
| + texture_manager()->MaxLevelsForTarget(target) < levels) { |
| + SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT: dimensions out of range"); |
| + return error::kNoError; |
| + } |
| + TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| + if (!info) { |
| + SetGLError(GL_INVALID_OPERATION, |
| + "glTexStorage2DEXT: unknown texture for target"); |
| + return error::kNoError; |
| + } |
| + if (info->IsAttachedToFramebuffer()) { |
| + state_dirty_ = true; |
| + } |
| + |
| + CopyRealGLErrorsToWrapper(); |
| + glTexStorage2DEXT(target, levels, internal_format, width, height); |
| + GLenum error = PeekGLError(); |
| + if (error == GL_NO_ERROR) { |
| + GLenum format = ExtractFormatFromStorageFormat(internal_format); |
| + GLenum type = ExtractTypeFromStorageFormat(internal_format); |
| + texture_manager()->SetLevelInfo( |
|
greggman
2011/12/02 18:33:24
I think you're going to need to add a field 'immut
vangelis
2011/12/03 00:19:53
Good point. Done. I also added checks in the han
|
| + feature_info_, info, |
| + target, 0, format, width, height, 1, 0, format, type, |
| + false); |
| + } |
| + |
| + texture_manager()->MarkMipmapsGenerated(feature_info_, info); |
|
greggman
2011/12/02 18:33:24
This should be inside the if.
You should also co
vangelis
2011/12/03 00:19:53
Done.
|
| + |
| + return error::kNoError; |
| +} |
| + |
| // Include the auto-generated part of this file. We split this because it means |
| // we can easily edit the non-auto generated parts right here in this file |
| // instead of having to edit some template or the code generator. |