Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2999923002: Revert of Allow creating GLImage-backed textures with glTexStorage2D. (Closed)
Patch Set: rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 // BGRX format is preferred for Ozone as it matches the format 2841 // BGRX format is preferred for Ozone as it matches the format
2842 // used by the buffer queue and is as a result guaranteed to work 2842 // used by the buffer queue and is as a result guaranteed to work
2843 // on all devices. 2843 // on all devices.
2844 // TODO(reveman): Define this format in one place instead of 2844 // TODO(reveman): Define this format in one place instead of
2845 // having to duplicate BGRX_8888. 2845 // having to duplicate BGRX_8888.
2846 gfx::BufferFormat::BGRX_8888 2846 gfx::BufferFormat::BGRX_8888
2847 #else 2847 #else
2848 gfx::BufferFormat::RGBX_8888 2848 gfx::BufferFormat::RGBX_8888
2849 #endif 2849 #endif
2850 : gfx::BufferFormat::RGBA_8888, 2850 : gfx::BufferFormat::RGBA_8888,
2851 gfx::BufferUsage::SCANOUT, format); 2851 format);
2852 if (!image || !image->BindTexImage(Target())) 2852 if (!image || !image->BindTexImage(Target()))
2853 return false; 2853 return false;
2854 2854
2855 image_ = image; 2855 image_ = image;
2856 decoder_->texture_manager()->SetLevelInfo( 2856 decoder_->texture_manager()->SetLevelInfo(
2857 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), 2857 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(),
2858 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), 2858 size.width(), size.height(), 1, 0, image_->GetInternalFormat(),
2859 GL_UNSIGNED_BYTE, gfx::Rect(size)); 2859 GL_UNSIGNED_BYTE, gfx::Rect(size));
2860 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, 2860 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0,
2861 image_.get(), Texture::BOUND); 2861 image_.get(), Texture::BOUND);
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
3872 caps.disable_webgl_rgb_multisampling_usage = 3872 caps.disable_webgl_rgb_multisampling_usage =
3873 workarounds().disable_webgl_rgb_multisampling_usage; 3873 workarounds().disable_webgl_rgb_multisampling_usage;
3874 caps.software_to_accelerated_canvas_upgrade = 3874 caps.software_to_accelerated_canvas_upgrade =
3875 !workarounds().disable_software_to_accelerated_canvas_upgrade; 3875 !workarounds().disable_software_to_accelerated_canvas_upgrade;
3876 caps.emulate_rgb_buffer_with_rgba = 3876 caps.emulate_rgb_buffer_with_rgba =
3877 workarounds().disable_gl_rgb_format; 3877 workarounds().disable_gl_rgb_format;
3878 if (workarounds().disable_non_empty_post_sub_buffers_for_onscreen_surfaces && 3878 if (workarounds().disable_non_empty_post_sub_buffers_for_onscreen_surfaces &&
3879 !surface_->IsOffscreen()) { 3879 !surface_->IsOffscreen()) {
3880 caps.disable_non_empty_post_sub_buffers = true; 3880 caps.disable_non_empty_post_sub_buffers = true;
3881 } 3881 }
3882 caps.texture_buffer_chromium =
3883 feature_info_->feature_flags().chromium_texture_buffer;
3884 3882
3885 return caps; 3883 return caps;
3886 } 3884 }
3887 3885
3888 void GLES2DecoderImpl::UpdateCapabilities() { 3886 void GLES2DecoderImpl::UpdateCapabilities() {
3889 util_.set_num_compressed_texture_formats( 3887 util_.set_num_compressed_texture_formats(
3890 validators_->compressed_texture_format.GetValues().size()); 3888 validators_->compressed_texture_format.GetValues().size());
3891 util_.set_num_shader_binary_formats( 3889 util_.set_num_shader_binary_formats(
3892 validators_->shader_binary_format.GetValues().size()); 3890 validators_->shader_binary_format.GetValues().size());
3893 } 3891 }
(...skipping 7083 matching lines...) Expand 10 before | Expand all | Expand 10 after
10977 iparams[0] = texture->swizzle_b(); 10975 iparams[0] = texture->swizzle_b();
10978 } 10976 }
10979 return; 10977 return;
10980 case GL_TEXTURE_SWIZZLE_A: 10978 case GL_TEXTURE_SWIZZLE_A:
10981 if (fparams) { 10979 if (fparams) {
10982 fparams[0] = static_cast<GLfloat>(texture->swizzle_a()); 10980 fparams[0] = static_cast<GLfloat>(texture->swizzle_a());
10983 } else { 10981 } else {
10984 iparams[0] = texture->swizzle_a(); 10982 iparams[0] = texture->swizzle_a();
10985 } 10983 }
10986 return; 10984 return;
10987 case GL_TEXTURE_BUFFER_USAGE_CHROMIUM:
10988 if (fparams) {
10989 fparams[0] = static_cast<GLfloat>(texture->buffer_usage());
10990 } else {
10991 iparams[0] = texture->buffer_usage();
10992 }
10993 return;
10994 default: 10985 default:
10995 break; 10986 break;
10996 } 10987 }
10997 if (fparams) { 10988 if (fparams) {
10998 glGetTexParameterfv(target, pname, fparams); 10989 glGetTexParameterfv(target, pname, fparams);
10999 } else { 10990 } else {
11000 glGetTexParameteriv(target, pname, iparams); 10991 glGetTexParameteriv(target, pname, iparams);
11001 } 10992 }
11002 } 10993 }
11003 10994
(...skipping 6559 matching lines...) Expand 10 before | Expand all | Expand 10 after
17563 Texture* texture = texture_ref->texture(); 17554 Texture* texture = texture_ref->texture();
17564 if (texture->IsAttachedToFramebuffer()) { 17555 if (texture->IsAttachedToFramebuffer()) {
17565 framebuffer_state_.clear_state_dirty = true; 17556 framebuffer_state_.clear_state_dirty = true;
17566 } 17557 }
17567 if (texture->IsImmutable()) { 17558 if (texture->IsImmutable()) {
17568 LOCAL_SET_GL_ERROR( 17559 LOCAL_SET_GL_ERROR(
17569 GL_INVALID_OPERATION, function_name, "texture is immutable"); 17560 GL_INVALID_OPERATION, function_name, "texture is immutable");
17570 return; 17561 return;
17571 } 17562 }
17572 17563
17573 if (texture->buffer_usage() != GL_NONE) {
17574 ScopedGLErrorSuppressor suppressor("GLES2CmdDecoder::TexStorageImpl",
17575 state_.GetErrorState());
17576 gfx::Size size(width, height);
17577 gfx::BufferFormat buffer_format;
17578 GLint real_internal_format;
17579 switch (internal_format) {
17580 case GL_RGBA8_OES:
17581 buffer_format = gfx::BufferFormat::RGBA_8888;
17582 real_internal_format = GL_RGBA;
17583 break;
17584 case GL_BGRA8_EXT:
17585 buffer_format = gfx::BufferFormat::BGRA_8888;
17586 real_internal_format = GL_BGRA_EXT;
17587 break;
17588 case GL_RGBA16F_EXT:
17589 buffer_format = gfx::BufferFormat::RGBA_F16;
17590 real_internal_format = GL_RGBA;
17591 break;
17592 default:
17593 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, function_name,
17594 "Invalid buffer format");
17595 return;
17596 }
17597
17598 if (levels != 1) {
17599 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
17600 "Levels != 1 for buffer");
17601 return;
17602 }
17603 if (depth > 1) {
17604 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
17605 "depth > 1 for buffer");
17606 return;
17607 }
17608 DCHECK_EQ(GL_TEXTURE_BUFFER_SCANOUT_CHROMIUM, texture->buffer_usage());
17609
17610 gfx::BufferUsage buffer_usage = gfx::BufferUsage::SCANOUT;
17611 scoped_refptr<gl::GLImage> image =
17612 GetContextGroup()->image_factory()->CreateAnonymousImage(
17613 gfx::Size(width, height), buffer_format, buffer_usage,
17614 real_internal_format);
17615 if (!image || !image->BindTexImage(target)) {
17616 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
17617 "Cannot create GL Image");
17618 return;
17619 }
17620
17621 texture_manager()->SetLevelInfo(
17622 texture_ref, target, 0, image->GetInternalFormat(), width, height, 1, 0,
17623 image->GetInternalFormat(), GL_UNSIGNED_BYTE, gfx::Rect(size));
17624 texture_manager()->SetLevelImage(texture_ref, target, 0, image.get(),
17625 Texture::BOUND);
17626 return;
17627 }
17628
17629 GLenum format = TextureManager::ExtractFormatFromStorageFormat( 17564 GLenum format = TextureManager::ExtractFormatFromStorageFormat(
17630 internal_format); 17565 internal_format);
17631 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); 17566 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format);
17632 17567
17633 std::vector<int32_t> level_size(levels); 17568 std::vector<int32_t> level_size(levels);
17634 { 17569 {
17635 GLsizei level_width = width; 17570 GLsizei level_width = width;
17636 GLsizei level_height = height; 17571 GLsizei level_height = height;
17637 GLsizei level_depth = depth; 17572 GLsizei level_depth = depth;
17638 base::CheckedNumeric<uint32_t> estimated_size(0); 17573 base::CheckedNumeric<uint32_t> estimated_size(0);
(...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after
19938 } 19873 }
19939 19874
19940 // Include the auto-generated part of this file. We split this because it means 19875 // Include the auto-generated part of this file. We split this because it means
19941 // we can easily edit the non-auto generated parts right here in this file 19876 // we can easily edit the non-auto generated parts right here in this file
19942 // instead of having to edit some template or the code generator. 19877 // instead of having to edit some template or the code generator.
19943 #include "base/macros.h" 19878 #include "base/macros.h"
19944 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19879 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19945 19880
19946 } // namespace gles2 19881 } // namespace gles2
19947 } // namespace gpu 19882 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.cc ('k') | gpu/command_buffer/service/gles2_cmd_validation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698