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

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

Issue 2328463002: Fix formats mismatch in validate_multisample_buffer_allocation (Closed)
Patch Set: Fix the format mismatch for BlitFramebuffer Created 4 years, 3 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
« no previous file with comments | « content/test/gpu/gpu_tests/webgl2_conformance_expectations.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 bool gpu_debug_commands_; 2343 bool gpu_debug_commands_;
2344 2344
2345 std::queue<FenceCallback> pending_readpixel_fences_; 2345 std::queue<FenceCallback> pending_readpixel_fences_;
2346 2346
2347 // After a second fence is inserted, both the GpuChannelMessageQueue and 2347 // After a second fence is inserted, both the GpuChannelMessageQueue and
2348 // CommandExecutor are descheduled. Once the first fence has completed, both 2348 // CommandExecutor are descheduled. Once the first fence has completed, both
2349 // get rescheduled. 2349 // get rescheduled.
2350 std::vector<std::unique_ptr<gl::GLFence>> deschedule_until_finished_fences_; 2350 std::vector<std::unique_ptr<gl::GLFence>> deschedule_until_finished_fences_;
2351 2351
2352 // Used to validate multisample renderbuffers if needed 2352 // Used to validate multisample renderbuffers if needed
2353 GLuint validation_texture_; 2353 typedef base::hash_map<GLenum, GLuint> TextureMap;
2354 TextureMap validation_textures_;
2354 GLuint validation_fbo_multisample_; 2355 GLuint validation_fbo_multisample_;
2355 GLuint validation_fbo_; 2356 GLuint validation_fbo_;
2356 2357
2357 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( 2358 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)(
2358 uint32_t immediate_data_size, 2359 uint32_t immediate_data_size,
2359 const volatile void* data); 2360 const volatile void* data);
2360 2361
2361 // A struct to hold info about each command. 2362 // A struct to hold info about each command.
2362 struct CommandInfo { 2363 struct CommandInfo {
2363 CmdHandler cmd_handler; 2364 CmdHandler cmd_handler;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 service_logging_( 2991 service_logging_(
2991 group_->gpu_preferences().enable_gpu_service_logging_gpu), 2992 group_->gpu_preferences().enable_gpu_service_logging_gpu),
2992 viewport_max_width_(0), 2993 viewport_max_width_(0),
2993 viewport_max_height_(0), 2994 viewport_max_height_(0),
2994 texture_state_(group_->feature_info()->workarounds()), 2995 texture_state_(group_->feature_info()->workarounds()),
2995 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( 2996 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
2996 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))), 2997 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))),
2997 gpu_trace_level_(2), 2998 gpu_trace_level_(2),
2998 gpu_trace_commands_(false), 2999 gpu_trace_commands_(false),
2999 gpu_debug_commands_(false), 3000 gpu_debug_commands_(false),
3000 validation_texture_(0),
3001 validation_fbo_multisample_(0), 3001 validation_fbo_multisample_(0),
3002 validation_fbo_(0), 3002 validation_fbo_(0),
3003 texture_manager_service_id_generation_(0), 3003 texture_manager_service_id_generation_(0),
3004 force_shader_name_hashing_for_test(false) { 3004 force_shader_name_hashing_for_test(false) {
3005 DCHECK(group); 3005 DCHECK(group);
3006 } 3006 }
3007 3007
3008 GLES2DecoderImpl::~GLES2DecoderImpl() { 3008 GLES2DecoderImpl::~GLES2DecoderImpl() {
3009 } 3009 }
3010 3010
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
4610 state_.current_program.get()); 4610 state_.current_program.get());
4611 } 4611 }
4612 4612
4613 if (attrib_0_buffer_id_) { 4613 if (attrib_0_buffer_id_) {
4614 glDeleteBuffersARB(1, &attrib_0_buffer_id_); 4614 glDeleteBuffersARB(1, &attrib_0_buffer_id_);
4615 } 4615 }
4616 if (fixed_attrib_buffer_id_) { 4616 if (fixed_attrib_buffer_id_) {
4617 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); 4617 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_);
4618 } 4618 }
4619 4619
4620 if (validation_texture_) { 4620 if (validation_fbo_) {
4621 glDeleteTextures(1, &validation_texture_);
4622 glDeleteFramebuffersEXT(1, &validation_fbo_multisample_); 4621 glDeleteFramebuffersEXT(1, &validation_fbo_multisample_);
4623 glDeleteFramebuffersEXT(1, &validation_fbo_); 4622 glDeleteFramebuffersEXT(1, &validation_fbo_);
4624 } 4623 }
4624 while (!validation_textures_.empty()) {
4625 GLuint tex;
4626 tex = validation_textures_.begin()->second;
4627 glDeleteTextures(1, &tex);
4628 validation_textures_.erase(validation_textures_.begin());
4629 }
4625 4630
4626 if (offscreen_target_frame_buffer_.get()) 4631 if (offscreen_target_frame_buffer_.get())
4627 offscreen_target_frame_buffer_->Destroy(); 4632 offscreen_target_frame_buffer_->Destroy();
4628 if (offscreen_target_color_texture_.get()) 4633 if (offscreen_target_color_texture_.get())
4629 offscreen_target_color_texture_->Destroy(); 4634 offscreen_target_color_texture_->Destroy();
4630 if (offscreen_target_color_render_buffer_.get()) 4635 if (offscreen_target_color_render_buffer_.get())
4631 offscreen_target_color_render_buffer_->Destroy(); 4636 offscreen_target_color_render_buffer_->Destroy();
4632 if (offscreen_target_depth_render_buffer_.get()) 4637 if (offscreen_target_depth_render_buffer_.get())
4633 offscreen_target_depth_render_buffer_->Destroy(); 4638 offscreen_target_depth_render_buffer_->Destroy();
4634 if (offscreen_target_stencil_render_buffer_.get()) 4639 if (offscreen_target_stencil_render_buffer_.get())
(...skipping 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after
7850 // by clearing it to a key color, blitting the contents to a texture, and 7855 // by clearing it to a key color, blitting the contents to a texture, and
7851 // reading back the color to ensure it matches the key. 7856 // reading back the color to ensure it matches the key.
7852 bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity( 7857 bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity(
7853 GLuint renderbuffer, GLenum format) { 7858 GLuint renderbuffer, GLenum format) {
7854 7859
7855 // Only validate color buffers. 7860 // Only validate color buffers.
7856 // These formats have been selected because they are very common or are known 7861 // These formats have been selected because they are very common or are known
7857 // to be used by the WebGL backbuffer. If problems are observed with other 7862 // to be used by the WebGL backbuffer. If problems are observed with other
7858 // color formats they can be added here. 7863 // color formats they can be added here.
7859 switch (format) { 7864 switch (format) {
7860 case GL_RGB: 7865 case GL_RGB:
Zhenyao Mo 2016/09/09 18:53:51 This is incorrect. Can you fix it? RGB and RGBA ar
7861 case GL_RGB8: 7866 case GL_RGB8:
7862 case GL_RGBA: 7867 case GL_RGBA:
7863 case GL_RGBA8: 7868 case GL_RGBA8:
7864 break; 7869 break;
7865 default: 7870 default:
7866 return true; 7871 return true;
7867 } 7872 }
7868 7873
7869 GLint draw_framebuffer, read_framebuffer; 7874 GLint draw_framebuffer, read_framebuffer;
7870 7875
7871 // Cache framebuffer and texture bindings. 7876 // Cache framebuffer and texture bindings.
7872 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer); 7877 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);
7873 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_framebuffer); 7878 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_framebuffer);
7874 7879
7875 if (!validation_texture_) { 7880 if (!validation_fbo_) {
7876 GLint bound_texture;
7877 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
7878
7879 // Create additional resources needed for the verification.
7880 glGenTextures(1, &validation_texture_);
7881 glGenFramebuffersEXT(1, &validation_fbo_multisample_); 7881 glGenFramebuffersEXT(1, &validation_fbo_multisample_);
7882 glGenFramebuffersEXT(1, &validation_fbo_); 7882 glGenFramebuffersEXT(1, &validation_fbo_);
7883 }
7884
7885 GLint bound_texture;
7886 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
7887 GLuint validation_texture;
7888 TextureMap::iterator iter = validation_textures_.find(format);
7889 if (iter == validation_textures_.end()) {
7890 // Create additional resources needed for the verification.
7891 glGenTextures(1, &validation_texture);
7892 validation_textures_.insert(std::make_pair(format, validation_texture));
7883 7893
7884 // Texture only needs to be 1x1. 7894 // Texture only needs to be 1x1.
7885 glBindTexture(GL_TEXTURE_2D, validation_texture_); 7895 glBindTexture(GL_TEXTURE_2D, validation_texture);
7886 // TODO(erikchen): When Chrome on Mac is linked against an OSX 10.9+ SDK, a 7896 glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, 1, 1);
7887 // multisample will fail if the color format of the source and destination 7897 } else {
7888 // do not match. Here, we assume that the source is GL_RGBA, and make the 7898 validation_texture = iter->second;
7889 // destination GL_RGBA. http://crbug.com/484203
7890 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
7891 GL_UNSIGNED_BYTE, NULL);
7892
7893 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_);
7894 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
7895 GL_TEXTURE_2D, validation_texture_, 0);
7896
7897 glBindTexture(GL_TEXTURE_2D, bound_texture);
7898 } 7899 }
7900 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_);
7901 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
7902 GL_TEXTURE_2D, validation_texture, 0);
7903 glBindTexture(GL_TEXTURE_2D, bound_texture);
7899 7904
7900 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); 7905 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_);
7901 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 7906 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
7902 GL_RENDERBUFFER, renderbuffer); 7907 GL_RENDERBUFFER, renderbuffer);
7903 7908
7904 // Cache current state and reset it to the values we require. 7909 // Cache current state and reset it to the values we require.
7905 GLboolean scissor_enabled = false; 7910 GLboolean scissor_enabled = false;
7906 glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled); 7911 glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled);
7907 if (scissor_enabled) 7912 if (scissor_enabled)
7908 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 7913 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
(...skipping 10025 matching lines...) Expand 10 before | Expand all | Expand 10 after
17934 } 17939 }
17935 17940
17936 // Include the auto-generated part of this file. We split this because it means 17941 // Include the auto-generated part of this file. We split this because it means
17937 // we can easily edit the non-auto generated parts right here in this file 17942 // we can easily edit the non-auto generated parts right here in this file
17938 // instead of having to edit some template or the code generator. 17943 // instead of having to edit some template or the code generator.
17939 #include "base/macros.h" 17944 #include "base/macros.h"
17940 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17945 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17941 17946
17942 } // namespace gles2 17947 } // namespace gles2
17943 } // namespace gpu 17948 } // namespace gpu
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/webgl2_conformance_expectations.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698