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 "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 (msg ? msg : "")); | 626 (msg ? msg : "")); |
627 error_message_callback_->OnErrorMessage(temp.c_str(), 0); | 627 error_message_callback_->OnErrorMessage(temp.c_str(), 0); |
628 } | 628 } |
629 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); | 629 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); |
630 } | 630 } |
631 | 631 |
632 bool GLES2Implementation::GetBucketContents(uint32 bucket_id, | 632 bool GLES2Implementation::GetBucketContents(uint32 bucket_id, |
633 std::vector<int8>* data) { | 633 std::vector<int8>* data) { |
634 TRACE_EVENT0("gpu", "GLES2::GetBucketContents"); | 634 TRACE_EVENT0("gpu", "GLES2::GetBucketContents"); |
635 GPU_DCHECK(data); | 635 GPU_DCHECK(data); |
636 typedef cmd::GetBucketSize::Result Result; | 636 const uint32 kStartSize = 32 * 1024; |
| 637 ScopedTransferBufferPtr buffer(kStartSize, helper_, transfer_buffer_); |
| 638 if (!buffer.valid()) { |
| 639 return false; |
| 640 } |
| 641 typedef cmd::GetBucketStart::Result Result; |
637 Result* result = GetResultAs<Result*>(); | 642 Result* result = GetResultAs<Result*>(); |
638 if (!result) { | 643 if (!result) { |
639 return false; | 644 return false; |
640 } | 645 } |
641 *result = 0; | 646 *result = 0; |
642 helper_->GetBucketSize(bucket_id, GetResultShmId(), GetResultShmOffset()); | 647 helper_->GetBucketStart( |
| 648 bucket_id, GetResultShmId(), GetResultShmOffset(), |
| 649 buffer.size(), buffer.shm_id(), buffer.offset()); |
643 WaitForCmd(); | 650 WaitForCmd(); |
644 uint32 size = *result; | 651 uint32 size = *result; |
645 data->resize(size); | 652 data->resize(size); |
646 if (size > 0u) { | 653 if (size > 0u) { |
647 uint32 offset = 0; | 654 uint32 offset = 0; |
648 while (size) { | 655 while (size) { |
649 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); | |
650 if (!buffer.valid()) { | 656 if (!buffer.valid()) { |
651 return false; | 657 buffer.Reset(size); |
| 658 if (!buffer.valid()) { |
| 659 return false; |
| 660 } |
| 661 helper_->GetBucketData( |
| 662 bucket_id, offset, buffer.size(), buffer.shm_id(), buffer.offset()); |
| 663 WaitForCmd(); |
652 } | 664 } |
653 helper_->GetBucketData( | 665 uint32 size_to_copy = std::min(size, buffer.size()); |
654 bucket_id, offset, buffer.size(), buffer.shm_id(), buffer.offset()); | 666 memcpy(&(*data)[offset], buffer.address(), size_to_copy); |
655 WaitForCmd(); | 667 offset += size_to_copy; |
656 memcpy(&(*data)[offset], buffer.address(), buffer.size()); | 668 size -= size_to_copy; |
657 offset += buffer.size(); | 669 buffer.Release(); |
658 size -= buffer.size(); | 670 }; |
659 } | |
660 // Free the bucket. This is not required but it does free up the memory. | 671 // Free the bucket. This is not required but it does free up the memory. |
661 // and we don't have to wait for the result so from the client's perspective | 672 // and we don't have to wait for the result so from the client's perspective |
662 // it's cheap. | 673 // it's cheap. |
663 helper_->SetBucketSize(bucket_id, 0); | 674 helper_->SetBucketSize(bucket_id, 0); |
664 } | 675 } |
665 return true; | 676 return true; |
666 } | 677 } |
667 | 678 |
668 void GLES2Implementation::SetBucketContents( | 679 void GLES2Implementation::SetBucketContents( |
669 uint32 bucket_id, const void* data, size_t size) { | 680 uint32 bucket_id, const void* data, size_t size) { |
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3100 helper_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 3111 helper_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
3101 } | 3112 } |
3102 #else | 3113 #else |
3103 helper_->DrawElementsInstancedANGLE( | 3114 helper_->DrawElementsInstancedANGLE( |
3104 mode, count, type, ToGLuint(indices), primcount); | 3115 mode, count, type, ToGLuint(indices), primcount); |
3105 #endif | 3116 #endif |
3106 } | 3117 } |
3107 | 3118 |
3108 } // namespace gles2 | 3119 } // namespace gles2 |
3109 } // namespace gpu | 3120 } // namespace gpu |
OLD | NEW |