OLD | NEW |
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 5571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5582 | 5582 |
5583 // Copy the data over after setting the data to ensure alignment. | 5583 // Copy the data over after setting the data to ensure alignment. |
5584 SyncToken sync_token_data(gpu_control_->GetNamespaceID(), | 5584 SyncToken sync_token_data(gpu_control_->GetNamespaceID(), |
5585 gpu_control_->GetExtraCommandBufferData(), | 5585 gpu_control_->GetExtraCommandBufferData(), |
5586 gpu_control_->GetCommandBufferID(), fence_sync); | 5586 gpu_control_->GetCommandBufferID(), fence_sync); |
5587 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); | 5587 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); |
5588 } | 5588 } |
5589 | 5589 |
5590 void GLES2Implementation::VerifySyncTokensCHROMIUM(GLbyte **sync_tokens, | 5590 void GLES2Implementation::VerifySyncTokensCHROMIUM(GLbyte **sync_tokens, |
5591 GLsizei count) { | 5591 GLsizei count) { |
5592 bool sync_tokens_verified = false; | 5592 bool requires_synchronization = false; |
5593 for (GLsizei i = 0; i < count; ++i) { | 5593 for (GLsizei i = 0; i < count; ++i) { |
5594 if (sync_tokens[i]) { | 5594 if (sync_tokens[i]) { |
5595 SyncToken sync_token; | 5595 SyncToken sync_token; |
5596 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); | 5596 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); |
5597 | 5597 |
5598 if (!sync_token.verified_flush()) { | 5598 if (!sync_token.verified_flush()) { |
5599 if (!gpu_control_->CanWaitUnverifiedSyncToken(&sync_token)) { | 5599 if (!gpu_control_->CanWaitUnverifiedSyncToken(&sync_token)) { |
5600 SetGLError(GL_INVALID_VALUE, "glVerifySyncTokensCHROMIUM", | 5600 SetGLError(GL_INVALID_VALUE, "glVerifySyncTokensCHROMIUM", |
5601 "Cannot verify sync token using this context."); | 5601 "Cannot verify sync token using this context."); |
5602 return; | 5602 return; |
5603 } | 5603 } |
5604 if (!sync_tokens_verified) { | 5604 requires_synchronization = true; |
5605 // Insert a fence sync here and ensure it is received immediately. | 5605 } |
5606 // This will require a flush but simplifies things a bit because | 5606 } |
5607 // unverified sync tokens only need an ordering barrier. | 5607 } |
5608 const uint64_t release = gpu_control_->GenerateFenceSyncRelease(); | |
5609 FlushHelper(); | |
5610 const bool verified = gpu_control_->IsFenceSyncFlushReceived(release); | |
5611 DCHECK(verified); | |
5612 | 5608 |
5613 sync_tokens_verified = true; | 5609 // This step must be done after all unverified tokens have finished processing |
5614 } | 5610 // CanWaitUnverifiedSyncToken(), command buffers use that to do any necessary |
| 5611 // flushes. |
| 5612 if (requires_synchronization) { |
| 5613 // Make sure we have no pending ordering barriers by flushing now. |
| 5614 FlushHelper(); |
5615 | 5615 |
| 5616 // Ensure all the fence syncs are visible on GPU service. |
| 5617 gpu_control_->EnsureWorkVisible(); |
| 5618 |
| 5619 // We can automatically mark everything as verified now. |
| 5620 for (GLsizei i = 0; i < count; ++i) { |
| 5621 SyncToken sync_token; |
| 5622 memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); |
| 5623 if (!sync_token.verified_flush()) { |
5616 sync_token.SetVerifyFlush(); | 5624 sync_token.SetVerifyFlush(); |
5617 memcpy(sync_tokens[i], &sync_token, sizeof(sync_token)); | 5625 memcpy(sync_tokens[i], &sync_token, sizeof(sync_token)); |
5618 } | 5626 } |
5619 } | 5627 } |
5620 } | 5628 } |
5621 } | 5629 } |
5622 | 5630 |
5623 void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) { | 5631 void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) { |
5624 if (sync_token) { | 5632 if (sync_token) { |
5625 // Copy the data over before data access to ensure alignment. | 5633 // Copy the data over before data access to ensure alignment. |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6541 CheckGLError(); | 6549 CheckGLError(); |
6542 } | 6550 } |
6543 | 6551 |
6544 // Include the auto-generated part of this file. We split this because it means | 6552 // Include the auto-generated part of this file. We split this because it means |
6545 // we can easily edit the non-auto generated parts right here in this file | 6553 // we can easily edit the non-auto generated parts right here in this file |
6546 // instead of having to edit some template or the code generator. | 6554 // instead of having to edit some template or the code generator. |
6547 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6555 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
6548 | 6556 |
6549 } // namespace gles2 | 6557 } // namespace gles2 |
6550 } // namespace gpu | 6558 } // namespace gpu |
OLD | NEW |