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

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

Issue 10989011: Defend against NULL pointer dereferences in buggy OpenGL drivers. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 | « no previous file | 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 MsgCallback msg_callback_; 1530 MsgCallback msg_callback_;
1531 1531
1532 StreamTextureManager* stream_texture_manager_; 1532 StreamTextureManager* stream_texture_manager_;
1533 1533
1534 // The format of the back buffer_ 1534 // The format of the back buffer_
1535 GLenum back_buffer_color_format_; 1535 GLenum back_buffer_color_format_;
1536 bool back_buffer_has_depth_; 1536 bool back_buffer_has_depth_;
1537 bool back_buffer_has_stencil_; 1537 bool back_buffer_has_stencil_;
1538 1538
1539 bool teximage2d_faster_than_texsubimage2d_; 1539 bool teximage2d_faster_than_texsubimage2d_;
1540 bool bufferdata_faster_than_buffersubdata_;
1541 1540
1542 // The last error message set. 1541 // The last error message set.
1543 std::string last_error_; 1542 std::string last_error_;
1544 1543
1545 int log_message_count_; 1544 int log_message_count_;
1546 1545
1547 // The current decoder error. 1546 // The current decoder error.
1548 error::Error current_decoder_error_; 1547 error::Error current_decoder_error_;
1549 1548
1550 DebugMarkerManager debug_marker_manager_; 1549 DebugMarkerManager debug_marker_manager_;
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 offscreen_target_depth_format_(0), 1983 offscreen_target_depth_format_(0),
1985 offscreen_target_stencil_format_(0), 1984 offscreen_target_stencil_format_(0),
1986 offscreen_target_samples_(0), 1985 offscreen_target_samples_(0),
1987 offscreen_target_buffer_preserved_(true), 1986 offscreen_target_buffer_preserved_(true),
1988 offscreen_saved_color_format_(0), 1987 offscreen_saved_color_format_(0),
1989 stream_texture_manager_(NULL), 1988 stream_texture_manager_(NULL),
1990 back_buffer_color_format_(0), 1989 back_buffer_color_format_(0),
1991 back_buffer_has_depth_(false), 1990 back_buffer_has_depth_(false),
1992 back_buffer_has_stencil_(false), 1991 back_buffer_has_stencil_(false),
1993 teximage2d_faster_than_texsubimage2d_(true), 1992 teximage2d_faster_than_texsubimage2d_(true),
1994 bufferdata_faster_than_buffersubdata_(true),
1995 log_message_count_(0), 1993 log_message_count_(0),
1996 current_decoder_error_(error::kNoError), 1994 current_decoder_error_(error::kNoError),
1997 use_shader_translator_(true), 1995 use_shader_translator_(true),
1998 validators_(group_->feature_info()->validators()), 1996 validators_(group_->feature_info()->validators()),
1999 feature_info_(group_->feature_info()), 1997 feature_info_(group_->feature_info()),
2000 tex_image_2d_failed_(false), 1998 tex_image_2d_failed_(false),
2001 frame_number_(0), 1999 frame_number_(0),
2002 has_robustness_extension_(false), 2000 has_robustness_extension_(false),
2003 reset_status_(GL_NO_ERROR), 2001 reset_status_(GL_NO_ERROR),
2004 needs_mac_nvidia_driver_workaround_(false), 2002 needs_mac_nvidia_driver_workaround_(false),
(...skipping 27 matching lines...) Expand all
2032 // TODO(apatrick): fix this test. 2030 // TODO(apatrick): fix this test.
2033 if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && 2031 if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
2034 !feature_info_->feature_flags().chromium_webglsl && 2032 !feature_info_->feature_flags().chromium_webglsl &&
2035 !force_webgl_glsl_validation_) || 2033 !force_webgl_glsl_validation_) ||
2036 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL || 2034 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL ||
2037 CommandLine::ForCurrentProcess()->HasSwitch( 2035 CommandLine::ForCurrentProcess()->HasSwitch(
2038 switches::kDisableGLSLTranslator)) { 2036 switches::kDisableGLSLTranslator)) {
2039 use_shader_translator_ = false; 2037 use_shader_translator_ = false;
2040 } 2038 }
2041 2039
2042 // TODO(gman): Consider setting these based on GPU and/or driver. 2040 // TODO(gman): Consider setting this based on GPU and/or driver.
2043 if (IsAngle()) { 2041 if (IsAngle()) {
2044 teximage2d_faster_than_texsubimage2d_ = false; 2042 teximage2d_faster_than_texsubimage2d_ = false;
2045 bufferdata_faster_than_buffersubdata_ = false;
2046 } 2043 }
2047 } 2044 }
2048 2045
2049 GLES2DecoderImpl::~GLES2DecoderImpl() { 2046 GLES2DecoderImpl::~GLES2DecoderImpl() {
2050 } 2047 }
2051 2048
2052 bool GLES2DecoderImpl::Initialize( 2049 bool GLES2DecoderImpl::Initialize(
2053 const scoped_refptr<gfx::GLSurface>& surface, 2050 const scoped_refptr<gfx::GLSurface>& surface,
2054 const scoped_refptr<gfx::GLContext>& context, 2051 const scoped_refptr<gfx::GLContext>& context,
2055 bool offscreen, 2052 bool offscreen,
(...skipping 4797 matching lines...) Expand 10 before | Expand all | Expand 10 after
6853 return; 6850 return;
6854 } 6851 }
6855 // Clear the buffer to 0 if no initial data was passed in. 6852 // Clear the buffer to 0 if no initial data was passed in.
6856 scoped_array<int8> zero; 6853 scoped_array<int8> zero;
6857 if (!data) { 6854 if (!data) {
6858 zero.reset(new int8[size]); 6855 zero.reset(new int8[size]);
6859 memset(zero.get(), 0, size); 6856 memset(zero.get(), 0, size);
6860 data = zero.get(); 6857 data = zero.get();
6861 } 6858 }
6862 6859
6863 if (!bufferdata_faster_than_buffersubdata_ &&
6864 size == info->size() && usage == info->usage()) {
6865 glBufferSubData(target, 0, size, data);
6866 info->SetRange(0, size, data);
6867 return;
6868 }
6869
6870 CopyRealGLErrorsToWrapper(); 6860 CopyRealGLErrorsToWrapper();
6871 glBufferData(target, size, data, usage); 6861 glBufferData(target, size, data, usage);
6872 GLenum error = PeekGLError(); 6862 GLenum error = PeekGLError();
6873 if (error == GL_NO_ERROR) { 6863 if (error == GL_NO_ERROR) {
6874 buffer_manager()->SetInfo(info, size, usage); 6864 buffer_manager()->SetInfo(info, size, usage);
6875 info->SetRange(0, size, data); 6865 info->SetRange(0, size, data);
6866 } else {
6867 buffer_manager()->SetInfo(info, 0, usage);
6876 } 6868 }
6877 } 6869 }
6878 6870
6879 error::Error GLES2DecoderImpl::HandleBufferData( 6871 error::Error GLES2DecoderImpl::HandleBufferData(
6880 uint32 immediate_data_size, const gles2::BufferData& c) { 6872 uint32 immediate_data_size, const gles2::BufferData& c) {
6881 GLenum target = static_cast<GLenum>(c.target); 6873 GLenum target = static_cast<GLenum>(c.target);
6882 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 6874 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
6883 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); 6875 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
6884 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); 6876 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
6885 GLenum usage = static_cast<GLenum>(c.usage); 6877 GLenum usage = static_cast<GLenum>(c.usage);
(...skipping 26 matching lines...) Expand all
6912 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) { 6904 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
6913 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); 6905 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target);
6914 if (!info) { 6906 if (!info) {
6915 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer"); 6907 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer");
6916 return; 6908 return;
6917 } 6909 }
6918 if (!info->SetRange(offset, size, data)) { 6910 if (!info->SetRange(offset, size, data)) {
6919 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range"); 6911 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range");
6920 return; 6912 return;
6921 } 6913 }
6922 if (bufferdata_faster_than_buffersubdata_ &&
6923 offset == 0 && size == info->size()) {
6924 glBufferData(target, size, data, info->usage());
6925 return;
6926 }
6927 glBufferSubData(target, offset, size, data); 6914 glBufferSubData(target, offset, size, data);
6928 } 6915 }
6929 6916
6930 bool GLES2DecoderImpl::ClearLevel( 6917 bool GLES2DecoderImpl::ClearLevel(
6931 unsigned service_id, 6918 unsigned service_id,
6932 unsigned bind_target, 6919 unsigned bind_target,
6933 unsigned target, 6920 unsigned target,
6934 int level, 6921 int level,
6935 unsigned format, 6922 unsigned format,
6936 unsigned type, 6923 unsigned type,
(...skipping 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after
9276 } 9263 }
9277 9264
9278 9265
9279 // Include the auto-generated part of this file. We split this because it means 9266 // Include the auto-generated part of this file. We split this because it means
9280 // we can easily edit the non-auto generated parts right here in this file 9267 // we can easily edit the non-auto generated parts right here in this file
9281 // instead of having to edit some template or the code generator. 9268 // instead of having to edit some template or the code generator.
9282 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9269 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9283 9270
9284 } // namespace gles2 9271 } // namespace gles2
9285 } // namespace gpu 9272 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698