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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 2727573003: gpu: Add sync token dependencies to flush metadata. (Closed)
Patch Set: use verified sync token Created 3 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
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) { 372 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) {
373 if (!lost_context_callback_run_) 373 if (!lost_context_callback_run_)
374 callback.Run(); 374 callback.Run();
375 } 375 }
376 376
377 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token, 377 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token,
378 const base::Closure& callback) { 378 const base::Closure& callback) {
379 if (sync_token.HasData() && 379 if (sync_token.HasData() &&
380 (sync_token.verified_flush() || 380 (sync_token.verified_flush() ||
381 gpu_control_->CanWaitUnverifiedSyncToken(&sync_token))) { 381 gpu_control_->CanWaitUnverifiedSyncToken(sync_token))) {
382 382 // We can only send verified sync tokens across IPC.
383 gpu::SyncToken intermediate_sync_token = sync_token; 383 gpu::SyncToken verified_sync_token = sync_token;
384 384 verified_sync_token.SetVerifyFlush();
385 // Mark the intermediate sync token as verified if we can wait on
386 // unverified sync tokens.
387 intermediate_sync_token.SetVerifyFlush();
388 385
389 gpu_control_->SignalSyncToken( 386 gpu_control_->SignalSyncToken(
390 intermediate_sync_token, 387 verified_sync_token,
391 base::Bind(&GLES2Implementation::RunIfContextNotLost, 388 base::Bind(&GLES2Implementation::RunIfContextNotLost,
392 weak_ptr_factory_.GetWeakPtr(), 389 weak_ptr_factory_.GetWeakPtr(), callback));
393 callback));
394 } else { 390 } else {
395 // Invalid sync token, just call the callback immediately. 391 // Invalid sync token, just call the callback immediately.
396 callback.Run(); 392 callback.Run();
397 } 393 }
398 } 394 }
399 395
400 // This may be called from any thread. It's safe to access gpu_control_ without 396 // This may be called from any thread. It's safe to access gpu_control_ without
401 // the lock because it is const. 397 // the lock because it is const.
402 bool GLES2Implementation::IsSyncTokenSignalled( 398 bool GLES2Implementation::IsSyncTokenSignaled(
403 const gpu::SyncToken& sync_token) { 399 const gpu::SyncToken& sync_token) {
404 // Check that the sync token belongs to this context. 400 // Check that the sync token belongs to this context.
405 DCHECK_EQ(gpu_control_->GetNamespaceID(), sync_token.namespace_id()); 401 DCHECK_EQ(gpu_control_->GetNamespaceID(), sync_token.namespace_id());
406 DCHECK_EQ(gpu_control_->GetCommandBufferID(), sync_token.command_buffer_id()); 402 DCHECK_EQ(gpu_control_->GetCommandBufferID(), sync_token.command_buffer_id());
407 return gpu_control_->IsFenceSyncReleased(sync_token.release_count()); 403 return gpu_control_->IsFenceSyncReleased(sync_token.release_count());
408 } 404 }
409 405
410 void GLES2Implementation::SignalQuery(uint32_t query, 406 void GLES2Implementation::SignalQuery(uint32_t query,
411 const base::Closure& callback) { 407 const base::Closure& callback) {
412 // Flush previously entered commands to ensure ordering with any 408 // Flush previously entered commands to ensure ordering with any
(...skipping 5695 matching lines...) Expand 10 before | Expand all | Expand 10 after
6108 6104
6109 void GLES2Implementation::VerifySyncTokensCHROMIUM(GLbyte **sync_tokens, 6105 void GLES2Implementation::VerifySyncTokensCHROMIUM(GLbyte **sync_tokens,
6110 GLsizei count) { 6106 GLsizei count) {
6111 bool requires_synchronization = false; 6107 bool requires_synchronization = false;
6112 for (GLsizei i = 0; i < count; ++i) { 6108 for (GLsizei i = 0; i < count; ++i) {
6113 if (sync_tokens[i]) { 6109 if (sync_tokens[i]) {
6114 SyncToken sync_token; 6110 SyncToken sync_token;
6115 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); 6111 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token));
6116 6112
6117 if (sync_token.HasData() && !sync_token.verified_flush()) { 6113 if (sync_token.HasData() && !sync_token.verified_flush()) {
6118 if (!gpu_control_->CanWaitUnverifiedSyncToken(&sync_token)) { 6114 if (!gpu_control_->CanWaitUnverifiedSyncToken(sync_token)) {
6119 SetGLError(GL_INVALID_VALUE, "glVerifySyncTokensCHROMIUM", 6115 SetGLError(GL_INVALID_VALUE, "glVerifySyncTokensCHROMIUM",
6120 "Cannot verify sync token using this context."); 6116 "Cannot verify sync token using this context.");
6121 return; 6117 return;
6122 } 6118 }
6123 requires_synchronization = true; 6119 requires_synchronization = true;
6124 } 6120 }
6125 } 6121 }
6126 } 6122 }
6127 6123
6128 // This step must be done after all unverified tokens have finished processing 6124 // This step must be done after all unverified tokens have finished processing
(...skipping 13 matching lines...) Expand all
6142 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); 6138 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token));
6143 if (sync_token.HasData() && !sync_token.verified_flush()) { 6139 if (sync_token.HasData() && !sync_token.verified_flush()) {
6144 sync_token.SetVerifyFlush(); 6140 sync_token.SetVerifyFlush();
6145 memcpy(sync_tokens[i], &sync_token, sizeof(sync_token)); 6141 memcpy(sync_tokens[i], &sync_token, sizeof(sync_token));
6146 } 6142 }
6147 } 6143 }
6148 } 6144 }
6149 } 6145 }
6150 } 6146 }
6151 6147
6152 void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) { 6148 void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token_data) {
6153 if (sync_token) { 6149 if (!sync_token_data)
6154 // Copy the data over before data access to ensure alignment. 6150 return;
6155 SyncToken sync_token_data;
6156 memcpy(&sync_token_data, sync_token, sizeof(SyncToken));
6157 if (sync_token_data.HasData()) {
6158 if (!sync_token_data.verified_flush() &&
6159 !gpu_control_->CanWaitUnverifiedSyncToken(&sync_token_data)) {
6160 SetGLError(GL_INVALID_VALUE, "glWaitSyncTokenCHROMIUM",
6161 "Cannot wait on sync_token which has not been verified");
6162 return;
6163 }
6164 6151
6165 helper_->WaitSyncTokenCHROMIUM( 6152 // Copy the data over before data access to ensure alignment.
6166 static_cast<GLint>(sync_token_data.namespace_id()), 6153 SyncToken sync_token;
6167 sync_token_data.command_buffer_id().GetUnsafeValue(), 6154 memcpy(&sync_token, sync_token_data, sizeof(SyncToken));
6168 sync_token_data.release_count()); 6155
6169 } 6156 if (!sync_token.HasData())
6157 return;
6158
6159 if (!sync_token.verified_flush() &&
6160 !gpu_control_->CanWaitUnverifiedSyncToken(sync_token)) {
6161 SetGLError(GL_INVALID_VALUE, "glWaitSyncTokenCHROMIUM",
6162 "Cannot wait on sync_token which has not been verified");
6163 return;
6170 } 6164 }
6165
6166 gpu_control_->WaitSyncToken(sync_token);
jbauman 2017/03/09 02:00:09 I think this should actually go after the call to
sunnyps 2017/03/10 03:26:20 Nice catch!
6167
6168 helper_->WaitSyncTokenCHROMIUM(
6169 static_cast<GLint>(sync_token.namespace_id()),
6170 sync_token.command_buffer_id().GetUnsafeValue(),
6171 sync_token.release_count());
6171 } 6172 }
6172 6173
6173 namespace { 6174 namespace {
6174 6175
6175 bool CreateImageValidInternalFormat(GLenum internalformat, 6176 bool CreateImageValidInternalFormat(GLenum internalformat,
6176 const Capabilities& capabilities) { 6177 const Capabilities& capabilities) {
6177 switch (internalformat) { 6178 switch (internalformat) {
6178 case GL_ATC_RGB_AMD: 6179 case GL_ATC_RGB_AMD:
6179 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: 6180 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
6180 return capabilities.texture_format_atc; 6181 return capabilities.texture_format_atc;
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
7023 CheckGLError(); 7024 CheckGLError();
7024 } 7025 }
7025 7026
7026 // Include the auto-generated part of this file. We split this because it means 7027 // Include the auto-generated part of this file. We split this because it means
7027 // we can easily edit the non-auto generated parts right here in this file 7028 // we can easily edit the non-auto generated parts right here in this file
7028 // instead of having to edit some template or the code generator. 7029 // instead of having to edit some template or the code generator.
7029 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 7030 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
7030 7031
7031 } // namespace gles2 7032 } // namespace gles2
7032 } // namespace gpu 7033 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698