OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 const void * data); | 744 const void * data); |
745 | 745 |
746 // Wrapper for TexImageIOSurface2DCHROMIUM. | 746 // Wrapper for TexImageIOSurface2DCHROMIUM. |
747 void DoTexImageIOSurface2DCHROMIUM( | 747 void DoTexImageIOSurface2DCHROMIUM( |
748 GLenum target, | 748 GLenum target, |
749 GLsizei width, | 749 GLsizei width, |
750 GLsizei height, | 750 GLsizei height, |
751 GLuint io_surface_id, | 751 GLuint io_surface_id, |
752 GLuint plane); | 752 GLuint plane); |
753 | 753 |
754 // Wrapper for TexStorage2DEXT. | |
755 error::Error DoTexStorage2DEXT( | |
756 GLenum target, | |
757 GLint levels, | |
758 GLenum internal_format, | |
759 GLsizei width, | |
760 GLsizei height); | |
761 | |
754 // Creates a ProgramInfo for the given program. | 762 // Creates a ProgramInfo for the given program. |
755 ProgramManager::ProgramInfo* CreateProgramInfo( | 763 ProgramManager::ProgramInfo* CreateProgramInfo( |
756 GLuint client_id, GLuint service_id) { | 764 GLuint client_id, GLuint service_id) { |
757 return program_manager()->CreateProgramInfo(client_id, service_id); | 765 return program_manager()->CreateProgramInfo(client_id, service_id); |
758 } | 766 } |
759 | 767 |
760 // Gets the program info for the given program. Returns NULL if none exists. | 768 // Gets the program info for the given program. Returns NULL if none exists. |
761 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { | 769 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { |
762 return program_manager()->GetProgramInfo(client_id); | 770 return program_manager()->GetProgramInfo(client_id); |
763 } | 771 } |
(...skipping 5958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6722 } | 6730 } |
6723 | 6731 |
6724 if (!info->ValidForTexture( | 6732 if (!info->ValidForTexture( |
6725 target, level, xoffset, yoffset, width, height, format, type)) { | 6733 target, level, xoffset, yoffset, width, height, format, type)) { |
6726 SetGLError(GL_INVALID_VALUE, | 6734 SetGLError(GL_INVALID_VALUE, |
6727 "glTexSubImage2D: bad dimensions."); | 6735 "glTexSubImage2D: bad dimensions."); |
6728 return; | 6736 return; |
6729 } | 6737 } |
6730 | 6738 |
6731 // See if we can call glTexImage2D instead since it appears to be faster. | 6739 // See if we can call glTexImage2D instead since it appears to be faster. |
6732 if (teximage2d_faster_than_texsubimage2d_ && xoffset == 0 && yoffset == 0) { | 6740 if (teximage2d_faster_than_texsubimage2d_ && xoffset == 0 && yoffset == 0) { |
greggman
2011/12/02 18:33:24
You'll need to check the texture is not immutable
vangelis
2011/12/03 00:19:53
Done.
| |
6733 GLsizei tex_width = 0; | 6741 GLsizei tex_width = 0; |
6734 GLsizei tex_height = 0; | 6742 GLsizei tex_height = 0; |
6735 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height); | 6743 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height); |
6736 DCHECK(ok); | 6744 DCHECK(ok); |
6737 if (width == tex_width && height == tex_height) { | 6745 if (width == tex_width && height == tex_height) { |
6738 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the | 6746 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the |
6739 // same as internal_foramt. If that changes we'll need to look them up. | 6747 // same as internal_foramt. If that changes we'll need to look them up. |
6740 WrappedTexImage2D( | 6748 WrappedTexImage2D( |
6741 target, level, format, width, height, 0, format, type, data); | 6749 target, level, format, width, height, 0, format, type, data); |
6742 texture_manager()->SetLevelCleared(info, target, level); | 6750 texture_manager()->SetLevelCleared(info, target, level); |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7677 feature_info_, info, | 7685 feature_info_, info, |
7678 target, 0, GL_RGBA, width, height, 1, 0, | 7686 target, 0, GL_RGBA, width, height, 1, 0, |
7679 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); | 7687 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); |
7680 | 7688 |
7681 #else | 7689 #else |
7682 SetGLError(GL_INVALID_OPERATION, | 7690 SetGLError(GL_INVALID_OPERATION, |
7683 "glTexImageIOSurface2DCHROMIUM: not supported."); | 7691 "glTexImageIOSurface2DCHROMIUM: not supported."); |
7684 #endif | 7692 #endif |
7685 } | 7693 } |
7686 | 7694 |
7695 static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) | |
7696 { | |
greggman
2011/12/02 18:33:24
This is not chromium style
should be
type functi
vangelis
2011/12/03 00:19:53
Done.
| |
7697 switch (internalformat) | |
7698 { | |
7699 case GL_RGB565: return GL_RGB; | |
7700 case GL_RGBA4: return GL_RGBA; | |
7701 case GL_RGB5_A1: return GL_RGBA; | |
7702 case GL_RGB8_OES: return GL_RGB; | |
7703 case GL_RGBA8_OES: return GL_RGBA; | |
7704 case GL_LUMINANCE8_ALPHA8_EXT: return GL_LUMINANCE_ALPHA; | |
7705 case GL_LUMINANCE8_EXT: return GL_LUMINANCE; | |
7706 case GL_ALPHA8_EXT: return GL_ALPHA; | |
7707 case GL_RGBA32F_EXT: return GL_RGBA; | |
7708 case GL_RGB32F_EXT: return GL_RGB; | |
7709 case GL_ALPHA32F_EXT: return GL_ALPHA; | |
7710 case GL_LUMINANCE32F_EXT: return GL_LUMINANCE; | |
7711 case GL_LUMINANCE_ALPHA32F_EXT: return GL_LUMINANCE_ALPHA; | |
7712 case GL_RGBA16F_EXT: return GL_RGBA; | |
7713 case GL_RGB16F_EXT: return GL_RGB; | |
7714 case GL_ALPHA16F_EXT: return GL_ALPHA; | |
7715 case GL_LUMINANCE16F_EXT: return GL_LUMINANCE; | |
7716 case GL_LUMINANCE_ALPHA16F_EXT: return GL_LUMINANCE_ALPHA; | |
7717 case GL_BGRA8_EXT: return GL_BGRA_EXT; | |
7718 default: return GL_NONE; // Unsupported | |
7719 } | |
7720 } | |
7721 | |
7722 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
| |
7723 { | |
7724 switch (internalformat) | |
7725 { | |
7726 case GL_RGB565: return GL_UNSIGNED_SHORT_5_6_5; | |
7727 case GL_RGBA4: return GL_UNSIGNED_SHORT_4_4_4_4; | |
7728 case GL_RGB5_A1: return GL_UNSIGNED_SHORT_5_5_5_1; | |
7729 case GL_RGB8_OES: return GL_UNSIGNED_BYTE; | |
7730 case GL_RGBA8_OES: return GL_UNSIGNED_BYTE; | |
7731 case GL_LUMINANCE8_ALPHA8_EXT: return GL_UNSIGNED_BYTE; | |
7732 case GL_LUMINANCE8_EXT: return GL_UNSIGNED_BYTE; | |
7733 case GL_ALPHA8_EXT: return GL_UNSIGNED_BYTE; | |
7734 case GL_RGBA32F_EXT: return GL_FLOAT; | |
7735 case GL_RGB32F_EXT: return GL_FLOAT; | |
7736 case GL_ALPHA32F_EXT: return GL_FLOAT; | |
7737 case GL_LUMINANCE32F_EXT: return GL_FLOAT; | |
7738 case GL_LUMINANCE_ALPHA32F_EXT: return GL_FLOAT; | |
7739 case GL_RGBA16F_EXT: return GL_HALF_FLOAT_OES; | |
7740 case GL_RGB16F_EXT: return GL_HALF_FLOAT_OES; | |
7741 case GL_ALPHA16F_EXT: return GL_HALF_FLOAT_OES; | |
7742 case GL_LUMINANCE16F_EXT: return GL_HALF_FLOAT_OES; | |
7743 case GL_LUMINANCE_ALPHA16F_EXT: return GL_HALF_FLOAT_OES; | |
7744 case GL_BGRA8_EXT: return GL_UNSIGNED_BYTE; | |
7745 default: return GL_NONE; // Unsupported | |
7746 } | |
7747 } | |
7748 | |
7749 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.
| |
7750 GLenum target, | |
7751 GLint levels, | |
7752 GLenum internal_format, | |
7753 GLsizei width, | |
7754 GLsizei height) { | |
7755 if (!texture_manager()->ValidForTarget( | |
7756 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.
| |
7757 texture_manager()->MaxLevelsForTarget(target) < levels) { | |
7758 SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT: dimensions out of range"); | |
7759 return error::kNoError; | |
7760 } | |
7761 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | |
7762 if (!info) { | |
7763 SetGLError(GL_INVALID_OPERATION, | |
7764 "glTexStorage2DEXT: unknown texture for target"); | |
7765 return error::kNoError; | |
7766 } | |
7767 if (info->IsAttachedToFramebuffer()) { | |
7768 state_dirty_ = true; | |
7769 } | |
7770 | |
7771 CopyRealGLErrorsToWrapper(); | |
7772 glTexStorage2DEXT(target, levels, internal_format, width, height); | |
7773 GLenum error = PeekGLError(); | |
7774 if (error == GL_NO_ERROR) { | |
7775 GLenum format = ExtractFormatFromStorageFormat(internal_format); | |
7776 GLenum type = ExtractTypeFromStorageFormat(internal_format); | |
7777 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
| |
7778 feature_info_, info, | |
7779 target, 0, format, width, height, 1, 0, format, type, | |
7780 false); | |
7781 } | |
7782 | |
7783 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.
| |
7784 | |
7785 return error::kNoError; | |
7786 } | |
7687 | 7787 |
7688 // Include the auto-generated part of this file. We split this because it means | 7788 // Include the auto-generated part of this file. We split this because it means |
7689 // we can easily edit the non-auto generated parts right here in this file | 7789 // we can easily edit the non-auto generated parts right here in this file |
7690 // instead of having to edit some template or the code generator. | 7790 // instead of having to edit some template or the code generator. |
7691 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 7791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
7692 | 7792 |
7693 } // namespace gles2 | 7793 } // namespace gles2 |
7694 } // namespace gpu | 7794 } // namespace gpu |
OLD | NEW |