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

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

Issue 157033009: Explicitly disable all attribs before drawing in CopyTextureCHROMIUM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Feedback Created 6 years, 10 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 | Annotate | Revision Log
« 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_copy_texture_chromium.h" 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "gpu/command_buffer/common/types.h" 9 #include "gpu/command_buffer/common/types.h"
10 #include "gpu/command_buffer/service/gl_utils.h" 10 #include "gpu/command_buffer/service/gl_utils.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // NVidia drivers require texture settings to be a certain way 381 // NVidia drivers require texture settings to be a certain way
382 // or they won't report FRAMEBUFFER_COMPLETE. 382 // or they won't report FRAMEBUFFER_COMPLETE.
383 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 383 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
384 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 384 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
385 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 385 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
387 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_); 387 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_);
388 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, 388 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target,
389 dest_id, level); 389 dest_id, level);
390 390
391 GLint max_attribs = 0;
392 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs);
393
391 #ifndef NDEBUG 394 #ifndef NDEBUG
392 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 395 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
393 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { 396 if (GL_FRAMEBUFFER_COMPLETE != fb_status) {
394 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; 397 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer.";
395 } else 398 } else
396 #endif 399 #endif
397 { 400 {
398 glEnableVertexAttribArray(kVertexPositionAttrib); 401 glEnableVertexAttribArray(kVertexPositionAttrib);
402 for (int i = 0; i < max_attribs; ++i) {
403 if (i != kVertexPositionAttrib)
404 glDisableVertexAttribArray(i);
405 }
Ken Russell (switch to Gerrit) 2014/02/11 23:15:24 The vertex attribute divisor also needs to be set
399 406
400 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); 407 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_);
401 glVertexAttribPointer(kVertexPositionAttrib, 4, GL_FLOAT, GL_FALSE, 408 glVertexAttribPointer(kVertexPositionAttrib, 4, GL_FLOAT, GL_FALSE,
402 4 * sizeof(GLfloat), 0); 409 4 * sizeof(GLfloat), 0);
403 410
404 glUniform1i(sampler_locations_[program], 0); 411 glUniform1i(sampler_locations_[program], 0);
405 412
406 glBindTexture(source_target, source_id); 413 glBindTexture(source_target, source_id);
407 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 414 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
408 glTexParameterf(source_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 415 glTexParameterf(source_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
409 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 416 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
410 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 417 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
411 418
412 glDisable(GL_DEPTH_TEST); 419 glDisable(GL_DEPTH_TEST);
413 glDisable(GL_SCISSOR_TEST); 420 glDisable(GL_SCISSOR_TEST);
414 glDisable(GL_STENCIL_TEST); 421 glDisable(GL_STENCIL_TEST);
415 glDisable(GL_CULL_FACE); 422 glDisable(GL_CULL_FACE);
416 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 423 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
417 glDepthMask(GL_FALSE); 424 glDepthMask(GL_FALSE);
418 glDisable(GL_BLEND); 425 glDisable(GL_BLEND);
419 426
420 glViewport(0, 0, width, height); 427 glViewport(0, 0, width, height);
421 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 428 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
422 } 429 }
423 430
424 decoder->RestoreAttribute(kVertexPositionAttrib); 431 for (int i = 0; i < max_attribs; ++i)
432 decoder->RestoreAttribute(i);
425 decoder->RestoreTextureState(source_id); 433 decoder->RestoreTextureState(source_id);
426 decoder->RestoreTextureState(dest_id); 434 decoder->RestoreTextureState(dest_id);
427 decoder->RestoreTextureUnitBindings(0); 435 decoder->RestoreTextureUnitBindings(0);
428 decoder->RestoreActiveTexture(); 436 decoder->RestoreActiveTexture();
429 decoder->RestoreProgramBindings(); 437 decoder->RestoreProgramBindings();
430 decoder->RestoreBufferBindings(); 438 decoder->RestoreBufferBindings();
431 decoder->RestoreFramebufferBindings(); 439 decoder->RestoreFramebufferBindings();
432 decoder->RestoreGlobalState(); 440 decoder->RestoreGlobalState();
433 } 441 }
434 442
435 } // namespace 443 } // namespace
436 444
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