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

Side by Side Diff: gpu/blink/webgraphicscontext3d_impl.cc

Issue 978193003: Fix glGetActiveUniform/Attrib crashes due to state inconsistency (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/blink/webgraphicscontext3d_impl.h" 5 #include "gpu/blink/webgraphicscontext3d_impl.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "gpu/GLES2/gl2extchromium.h" 10 #include "gpu/GLES2/gl2extchromium.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 WebGLId program, WGC3Duint index, ActiveInfo& info) { 354 WebGLId program, WGC3Duint index, ActiveInfo& info) {
355 if (!program) { 355 if (!program) {
356 synthesizeGLError(GL_INVALID_VALUE); 356 synthesizeGLError(GL_INVALID_VALUE);
357 return false; 357 return false;
358 } 358 }
359 GLint max_name_length = -1; 359 GLint max_name_length = -1;
360 gl_->GetProgramiv( 360 gl_->GetProgramiv(
361 program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); 361 program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
362 if (max_name_length < 0) 362 if (max_name_length < 0)
363 return false; 363 return false;
364 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); 364 if (max_name_length == 0) {
365 if (!name) { 365 // No active attributes exist.
366 synthesizeGLError(GL_OUT_OF_MEMORY); 366 synthesizeGLError(GL_INVALID_VALUE);
Zhenyao Mo 2015/03/07 01:00:08 This is unnecessary because we always crash when "
no sievers 2015/03/09 19:10:08 This seems correct if the program is not valid. Bu
no sievers 2015/03/09 19:13:54 nm, we do call getProgramiv() but this is obviousl
Zhenyao Mo 2015/03/09 19:58:28 If the linked program has zero attribs or uniforms
367 return false; 367 return false;
368 } 368 }
369 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
369 GLsizei length = 0; 370 GLsizei length = 0;
370 GLint size = -1; 371 GLint size = -1;
371 GLenum type = 0; 372 GLenum type = 0;
372 gl_->GetActiveAttrib( 373 gl_->GetActiveAttrib(
373 program, index, max_name_length, &length, &size, &type, name.get()); 374 program, index, max_name_length, &length, &size, &type, name.get());
374 if (size < 0) { 375 if (size < 0) {
375 return false; 376 return false;
376 } 377 }
377 info.name = blink::WebString::fromUTF8(name.get(), length); 378 info.name = blink::WebString::fromUTF8(name.get(), length);
378 info.type = type; 379 info.type = type;
379 info.size = size; 380 info.size = size;
380 return true; 381 return true;
381 } 382 }
382 383
383 bool WebGraphicsContext3DImpl::getActiveUniform( 384 bool WebGraphicsContext3DImpl::getActiveUniform(
384 WebGLId program, WGC3Duint index, ActiveInfo& info) { 385 WebGLId program, WGC3Duint index, ActiveInfo& info) {
385 GLint max_name_length = -1; 386 GLint max_name_length = -1;
386 gl_->GetProgramiv( 387 gl_->GetProgramiv(
387 program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length); 388 program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
388 if (max_name_length < 0) 389 if (max_name_length < 0)
389 return false; 390 return false;
390 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); 391 if (max_name_length == 0) {
391 if (!name) { 392 // No active uniforms exist.
392 synthesizeGLError(GL_OUT_OF_MEMORY); 393 synthesizeGLError(GL_INVALID_VALUE);
393 return false; 394 return false;
394 } 395 }
396 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
395 GLsizei length = 0; 397 GLsizei length = 0;
396 GLint size = -1; 398 GLint size = -1;
397 GLenum type = 0; 399 GLenum type = 0;
398 gl_->GetActiveUniform( 400 gl_->GetActiveUniform(
399 program, index, max_name_length, &length, &size, &type, name.get()); 401 program, index, max_name_length, &length, &size, &type, name.get());
400 if (size < 0) { 402 if (size < 0) {
401 return false; 403 return false;
402 } 404 }
403 info.name = blink::WebString::fromUTF8(name.get(), length); 405 info.name = blink::WebString::fromUTF8(name.get(), length);
404 info.type = type; 406 info.type = type;
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 output_attribs->samples = attributes.antialias ? 4 : 0; 1214 output_attribs->samples = attributes.antialias ? 4 : 0;
1213 output_attribs->sample_buffers = attributes.antialias ? 1 : 0; 1215 output_attribs->sample_buffers = attributes.antialias ? 1 : 0;
1214 output_attribs->fail_if_major_perf_caveat = 1216 output_attribs->fail_if_major_perf_caveat =
1215 attributes.failIfMajorPerformanceCaveat; 1217 attributes.failIfMajorPerformanceCaveat;
1216 output_attribs->bind_generates_resource = false; 1218 output_attribs->bind_generates_resource = false;
1217 output_attribs->es3_context_required = 1219 output_attribs->es3_context_required =
1218 (attributes.webGL && attributes.webGLVersion == 2); 1220 (attributes.webGL && attributes.webGLVersion == 2);
1219 } 1221 }
1220 1222
1221 } // namespace gpu_blink 1223 } // namespace gpu_blink
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