| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 // BGRX format is preferred for Ozone as it matches the format | 2842 // BGRX format is preferred for Ozone as it matches the format |
| 2843 // used by the buffer queue and is as a result guaranteed to work | 2843 // used by the buffer queue and is as a result guaranteed to work |
| 2844 // on all devices. | 2844 // on all devices. |
| 2845 // TODO(reveman): Define this format in one place instead of | 2845 // TODO(reveman): Define this format in one place instead of |
| 2846 // having to duplicate BGRX_8888. | 2846 // having to duplicate BGRX_8888. |
| 2847 gfx::BufferFormat::BGRX_8888 | 2847 gfx::BufferFormat::BGRX_8888 |
| 2848 #else | 2848 #else |
| 2849 gfx::BufferFormat::RGBX_8888 | 2849 gfx::BufferFormat::RGBX_8888 |
| 2850 #endif | 2850 #endif |
| 2851 : gfx::BufferFormat::RGBA_8888, | 2851 : gfx::BufferFormat::RGBA_8888, |
| 2852 format); | 2852 gfx::BufferUsage::SCANOUT, format); |
| 2853 if (!image || !image->BindTexImage(Target())) | 2853 if (!image || !image->BindTexImage(Target())) |
| 2854 return false; | 2854 return false; |
| 2855 | 2855 |
| 2856 image_ = image; | 2856 image_ = image; |
| 2857 decoder_->texture_manager()->SetLevelInfo( | 2857 decoder_->texture_manager()->SetLevelInfo( |
| 2858 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), | 2858 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), |
| 2859 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), | 2859 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), |
| 2860 GL_UNSIGNED_BYTE, gfx::Rect(size)); | 2860 GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 2861 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, | 2861 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, |
| 2862 image_.get(), Texture::BOUND); | 2862 image_.get(), Texture::BOUND); |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 caps.disable_webgl_rgb_multisampling_usage = | 3880 caps.disable_webgl_rgb_multisampling_usage = |
| 3881 workarounds().disable_webgl_rgb_multisampling_usage; | 3881 workarounds().disable_webgl_rgb_multisampling_usage; |
| 3882 caps.software_to_accelerated_canvas_upgrade = | 3882 caps.software_to_accelerated_canvas_upgrade = |
| 3883 !workarounds().disable_software_to_accelerated_canvas_upgrade; | 3883 !workarounds().disable_software_to_accelerated_canvas_upgrade; |
| 3884 caps.emulate_rgb_buffer_with_rgba = | 3884 caps.emulate_rgb_buffer_with_rgba = |
| 3885 workarounds().disable_gl_rgb_format; | 3885 workarounds().disable_gl_rgb_format; |
| 3886 if (workarounds().disable_non_empty_post_sub_buffers_for_onscreen_surfaces && | 3886 if (workarounds().disable_non_empty_post_sub_buffers_for_onscreen_surfaces && |
| 3887 !surface_->IsOffscreen()) { | 3887 !surface_->IsOffscreen()) { |
| 3888 caps.disable_non_empty_post_sub_buffers = true; | 3888 caps.disable_non_empty_post_sub_buffers = true; |
| 3889 } | 3889 } |
| 3890 caps.texture_buffer_chromium = |
| 3891 feature_info_->feature_flags().chromium_texture_buffer; |
| 3890 | 3892 |
| 3891 return caps; | 3893 return caps; |
| 3892 } | 3894 } |
| 3893 | 3895 |
| 3894 void GLES2DecoderImpl::UpdateCapabilities() { | 3896 void GLES2DecoderImpl::UpdateCapabilities() { |
| 3895 util_.set_num_compressed_texture_formats( | 3897 util_.set_num_compressed_texture_formats( |
| 3896 validators_->compressed_texture_format.GetValues().size()); | 3898 validators_->compressed_texture_format.GetValues().size()); |
| 3897 util_.set_num_shader_binary_formats( | 3899 util_.set_num_shader_binary_formats( |
| 3898 validators_->shader_binary_format.GetValues().size()); | 3900 validators_->shader_binary_format.GetValues().size()); |
| 3899 } | 3901 } |
| (...skipping 7083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10983 iparams[0] = texture->swizzle_b(); | 10985 iparams[0] = texture->swizzle_b(); |
| 10984 } | 10986 } |
| 10985 return; | 10987 return; |
| 10986 case GL_TEXTURE_SWIZZLE_A: | 10988 case GL_TEXTURE_SWIZZLE_A: |
| 10987 if (fparams) { | 10989 if (fparams) { |
| 10988 fparams[0] = static_cast<GLfloat>(texture->swizzle_a()); | 10990 fparams[0] = static_cast<GLfloat>(texture->swizzle_a()); |
| 10989 } else { | 10991 } else { |
| 10990 iparams[0] = texture->swizzle_a(); | 10992 iparams[0] = texture->swizzle_a(); |
| 10991 } | 10993 } |
| 10992 return; | 10994 return; |
| 10995 case GL_TEXTURE_BUFFER_USAGE_CHROMIUM: |
| 10996 if (fparams) { |
| 10997 fparams[0] = static_cast<GLfloat>(texture->buffer_usage()); |
| 10998 } else { |
| 10999 iparams[0] = texture->buffer_usage(); |
| 11000 } |
| 11001 return; |
| 10993 default: | 11002 default: |
| 10994 break; | 11003 break; |
| 10995 } | 11004 } |
| 10996 if (fparams) { | 11005 if (fparams) { |
| 10997 glGetTexParameterfv(target, pname, fparams); | 11006 glGetTexParameterfv(target, pname, fparams); |
| 10998 } else { | 11007 } else { |
| 10999 glGetTexParameteriv(target, pname, iparams); | 11008 glGetTexParameteriv(target, pname, iparams); |
| 11000 } | 11009 } |
| 11001 } | 11010 } |
| 11002 | 11011 |
| (...skipping 6559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17562 Texture* texture = texture_ref->texture(); | 17571 Texture* texture = texture_ref->texture(); |
| 17563 if (texture->IsAttachedToFramebuffer()) { | 17572 if (texture->IsAttachedToFramebuffer()) { |
| 17564 framebuffer_state_.clear_state_dirty = true; | 17573 framebuffer_state_.clear_state_dirty = true; |
| 17565 } | 17574 } |
| 17566 if (texture->IsImmutable()) { | 17575 if (texture->IsImmutable()) { |
| 17567 LOCAL_SET_GL_ERROR( | 17576 LOCAL_SET_GL_ERROR( |
| 17568 GL_INVALID_OPERATION, function_name, "texture is immutable"); | 17577 GL_INVALID_OPERATION, function_name, "texture is immutable"); |
| 17569 return; | 17578 return; |
| 17570 } | 17579 } |
| 17571 | 17580 |
| 17581 if (texture->buffer_usage() != GL_NONE) { |
| 17582 ScopedGLErrorSuppressor suppressor("GLES2CmdDecoder::TexStorageImpl", |
| 17583 state_.GetErrorState()); |
| 17584 gfx::Size size(width, height); |
| 17585 gfx::BufferFormat buffer_format; |
| 17586 GLint real_internal_format; |
| 17587 switch (internal_format) { |
| 17588 case GL_RGBA8_OES: |
| 17589 buffer_format = gfx::BufferFormat::RGBA_8888; |
| 17590 real_internal_format = GL_RGBA; |
| 17591 break; |
| 17592 case GL_BGRA8_EXT: |
| 17593 buffer_format = gfx::BufferFormat::BGRA_8888; |
| 17594 real_internal_format = GL_BGRA_EXT; |
| 17595 break; |
| 17596 case GL_RGBA16F_EXT: |
| 17597 buffer_format = gfx::BufferFormat::RGBA_F16; |
| 17598 real_internal_format = GL_RGBA; |
| 17599 break; |
| 17600 default: |
| 17601 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, function_name, |
| 17602 "Invalid buffer format"); |
| 17603 return; |
| 17604 } |
| 17605 |
| 17606 if (levels != 1) { |
| 17607 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 17608 "Levels != 1 for buffer"); |
| 17609 return; |
| 17610 } |
| 17611 if (depth > 1) { |
| 17612 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 17613 "depth > 1 for buffer"); |
| 17614 return; |
| 17615 } |
| 17616 DCHECK_EQ(GL_TEXTURE_BUFFER_SCANOUT_CHROMIUM, texture->buffer_usage()); |
| 17617 |
| 17618 gfx::BufferUsage buffer_usage = gfx::BufferUsage::SCANOUT; |
| 17619 scoped_refptr<gl::GLImage> image = |
| 17620 GetContextGroup()->image_factory()->CreateAnonymousImage( |
| 17621 gfx::Size(width, height), buffer_format, buffer_usage, |
| 17622 real_internal_format); |
| 17623 if (!image || !image->BindTexImage(target)) { |
| 17624 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 17625 "Cannot create GL Image"); |
| 17626 return; |
| 17627 } |
| 17628 |
| 17629 texture_manager()->SetLevelInfo( |
| 17630 texture_ref, target, 0, image->GetInternalFormat(), width, height, 1, 0, |
| 17631 image->GetInternalFormat(), GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 17632 texture_manager()->SetLevelImage(texture_ref, target, 0, image.get(), |
| 17633 Texture::BOUND); |
| 17634 return; |
| 17635 } |
| 17636 |
| 17572 GLenum format = TextureManager::ExtractFormatFromStorageFormat( | 17637 GLenum format = TextureManager::ExtractFormatFromStorageFormat( |
| 17573 internal_format); | 17638 internal_format); |
| 17574 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); | 17639 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); |
| 17575 | 17640 |
| 17576 std::vector<int32_t> level_size(levels); | 17641 std::vector<int32_t> level_size(levels); |
| 17577 { | 17642 { |
| 17578 GLsizei level_width = width; | 17643 GLsizei level_width = width; |
| 17579 GLsizei level_height = height; | 17644 GLsizei level_height = height; |
| 17580 GLsizei level_depth = depth; | 17645 GLsizei level_depth = depth; |
| 17581 base::CheckedNumeric<uint32_t> estimated_size(0); | 17646 base::CheckedNumeric<uint32_t> estimated_size(0); |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19881 } | 19946 } |
| 19882 | 19947 |
| 19883 // Include the auto-generated part of this file. We split this because it means | 19948 // Include the auto-generated part of this file. We split this because it means |
| 19884 // we can easily edit the non-auto generated parts right here in this file | 19949 // we can easily edit the non-auto generated parts right here in this file |
| 19885 // instead of having to edit some template or the code generator. | 19950 // instead of having to edit some template or the code generator. |
| 19886 #include "base/macros.h" | 19951 #include "base/macros.h" |
| 19887 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19952 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19888 | 19953 |
| 19889 } // namespace gles2 | 19954 } // namespace gles2 |
| 19890 } // namespace gpu | 19955 } // namespace gpu |
| OLD | NEW |