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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2329523002: Save/restore PBO bindings in DrawingBuffer (Closed)
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // owns the SharedBitmap. 317 // owns the SharedBitmap.
318 auto func = WTF::bind(&DrawingBuffer::softwareMailboxReleased, 318 auto func = WTF::bind(&DrawingBuffer::softwareMailboxReleased,
319 RefPtr<DrawingBuffer>(this), 319 RefPtr<DrawingBuffer>(this),
320 WTF::passed(std::move(bitmap)), 320 WTF::passed(std::move(bitmap)),
321 m_size); 321 m_size);
322 *outReleaseCallback = cc::SingleReleaseCallback::Create( 322 *outReleaseCallback = cc::SingleReleaseCallback::Create(
323 convertToBaseCallback(std::move(func))); 323 convertToBaseCallback(std::move(func)));
324 return true; 324 return true;
325 } 325 }
326 326
327 m_gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
Ken Russell (switch to Gerrit) 2016/09/09 20:10:33 Here also, this needs to only be executed if the c
Kai Ninomiya 2016/09/09 20:30:44 Done.
328
327 // We must restore the texture binding since creating new textures, 329 // We must restore the texture binding since creating new textures,
328 // consuming and producing mailboxes changes it. 330 // consuming and producing mailboxes changes it.
329 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text ure2DBinding); 331 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text ure2DBinding);
330 332
331 // First try to recycle an old buffer. 333 // First try to recycle an old buffer.
332 RefPtr<MailboxInfo> mailboxInfo = takeRecycledMailbox(); 334 RefPtr<MailboxInfo> mailboxInfo = takeRecycledMailbox();
333 335
334 // No buffer available to recycle, create a new one. 336 // No buffer available to recycle, create a new one.
335 if (!mailboxInfo) 337 if (!mailboxInfo)
336 mailboxInfo = createNewMailbox(createTextureAndAllocateMemory(m_size)); 338 mailboxInfo = createNewMailbox(createTextureAndAllocateMemory(m_size));
337 339
338 if (m_preserveDrawingBuffer == Discard) { 340 if (m_preserveDrawingBuffer == Discard) {
339 std::swap(mailboxInfo->textureInfo, m_colorBuffer); 341 std::swap(mailboxInfo->textureInfo, m_colorBuffer);
340 attachColorBufferToReadFramebuffer(); 342 attachColorBufferToReadFramebuffer();
341 343
342 if (m_discardFramebufferSupported) { 344 if (m_discardFramebufferSupported) {
343 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch. 345 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch.
344 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC HMENT, GL_STENCIL_ATTACHMENT }; 346 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC HMENT, GL_STENCIL_ATTACHMENT };
345 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 347 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
346 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); 348 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments);
347 } 349 }
348 } else { 350 } else {
349 m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, mailboxInfo->textu reInfo.textureId, 351 m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, mailboxInfo->textu reInfo.textureId,
350 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_ FALSE); 352 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_ FALSE);
351 } 353 }
352 354
353 restoreFramebufferBindings(); 355 restoreFramebufferBindings();
356 restorePixelUnpackBufferBindings();
354 m_contentsChanged = false; 357 m_contentsChanged = false;
355 358
356 m_gl->ProduceTextureDirectCHROMIUM(mailboxInfo->textureInfo.textureId, mailb oxInfo->textureInfo.parameters.target, mailboxInfo->mailbox.name); 359 m_gl->ProduceTextureDirectCHROMIUM(mailboxInfo->textureInfo.textureId, mailb oxInfo->textureInfo.parameters.target, mailboxInfo->mailbox.name);
357 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); 360 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM();
358 #if OS(MACOSX) 361 #if OS(MACOSX)
359 m_gl->DescheduleUntilFinishedCHROMIUM(); 362 m_gl->DescheduleUntilFinishedCHROMIUM();
360 #endif 363 #endif
361 m_gl->Flush(); 364 m_gl->Flush();
362 gpu::SyncToken syncToken; 365 gpu::SyncToken syncToken;
363 m_gl->GenSyncTokenCHROMIUM(fenceSync, syncToken.GetData()); 366 m_gl->GenSyncTokenCHROMIUM(fenceSync, syncToken.GetData());
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 m_gl->Enable(GL_SCISSOR_TEST); 950 m_gl->Enable(GL_SCISSOR_TEST);
948 } 951 }
949 952
950 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 953 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
951 if (m_antiAliasingMode == ScreenSpaceAntialiasing) { 954 if (m_antiAliasingMode == ScreenSpaceAntialiasing) {
952 m_gl->ApplyScreenSpaceAntialiasingCHROMIUM(); 955 m_gl->ApplyScreenSpaceAntialiasingCHROMIUM();
953 } 956 }
954 m_contentsChangeCommitted = true; 957 m_contentsChangeCommitted = true;
955 } 958 }
956 959
960 void DrawingBuffer::restorePixelUnpackBufferBindings()
961 {
962 m_gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, m_pixelUnpackBufferBinding);
Ken Russell (switch to Gerrit) 2016/09/09 20:10:33 This must only be done for WebGL 2.0 / ES 3.0 cont
963 }
964
957 void DrawingBuffer::restoreFramebufferBindings() 965 void DrawingBuffer::restoreFramebufferBindings()
958 { 966 {
959 if (m_drawFramebufferBinding && m_readFramebufferBinding) { 967 if (m_drawFramebufferBinding && m_readFramebufferBinding) {
960 if (m_drawFramebufferBinding == m_readFramebufferBinding) { 968 if (m_drawFramebufferBinding == m_readFramebufferBinding) {
961 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding); 969 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding);
962 } else { 970 } else {
963 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding) ; 971 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding) ;
964 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding) ; 972 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding) ;
965 } 973 }
966 return; 974 return;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1236
1229 void DrawingBuffer::restoreTextureBindings() 1237 void DrawingBuffer::restoreTextureBindings()
1230 { 1238 {
1231 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1239 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1232 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1240 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1233 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1241 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1234 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1242 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1235 } 1243 }
1236 1244
1237 } // namespace blink 1245 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698