OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ |
7 | 7 |
8 #include "gpu/command_buffer/common/mailbox.h" | 8 #include "gpu/command_buffer/common/mailbox.h" |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <queue> |
11 #include <set> | 12 #include <set> |
12 | 13 |
13 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
14 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
15 #include "gpu/command_buffer/service/texture_definition.h" | 16 #include "gpu/command_buffer/service/texture_definition.h" |
16 #include "gpu/gpu_export.h" | 17 #include "gpu/gpu_export.h" |
17 | 18 |
| 19 namespace gfx { |
| 20 class GLFence; |
| 21 } |
| 22 |
18 namespace gpu { | 23 namespace gpu { |
19 namespace gles2 { | 24 namespace gles2 { |
20 | 25 |
21 class MailboxManager; | 26 class MailboxManager; |
22 class Texture; | 27 class Texture; |
23 | 28 |
24 // A thread-safe proxy that can be used to emulate texture sharing across | 29 // A thread-safe proxy that can be used to emulate texture sharing across |
25 // share-groups. | 30 // share-groups. |
26 class MailboxSynchronizer { | 31 class MailboxSynchronizer { |
27 public: | 32 public: |
28 ~MailboxSynchronizer(); | 33 ~MailboxSynchronizer(); |
29 | 34 |
30 GPU_EXPORT static bool Initialize(); | 35 GPU_EXPORT static bool Initialize(); |
31 GPU_EXPORT static void Terminate(); | 36 GPU_EXPORT static void Terminate(); |
32 static MailboxSynchronizer* GetInstance(); | 37 static MailboxSynchronizer* GetInstance(); |
33 | 38 |
34 // Create a texture from a globally visible mailbox. | 39 // Create a texture from a globally visible mailbox. |
35 Texture* CreateTextureFromMailbox(unsigned target, const Mailbox& mailbox); | 40 Texture* CreateTextureFromMailbox(unsigned target, const Mailbox& mailbox); |
36 | 41 |
37 void PushTextureUpdates(MailboxManager* manager); | 42 void PushTextureUpdates(MailboxManager* manager, uint32 sync_point); |
38 void PullTextureUpdates(MailboxManager* manager); | 43 void PullTextureUpdates(MailboxManager* manager, uint32 sync_point); |
39 | 44 |
40 void TextureDeleted(Texture* texture); | 45 void TextureDeleted(Texture* texture); |
41 | 46 |
42 private: | 47 private: |
43 MailboxSynchronizer(); | 48 MailboxSynchronizer(); |
44 | 49 |
45 struct TargetName { | 50 struct TargetName { |
46 TargetName(unsigned target, const Mailbox& mailbox); | 51 TargetName(unsigned target, const Mailbox& mailbox); |
47 bool operator<(const TargetName& rhs) const { | 52 bool operator<(const TargetName& rhs) const { |
48 return memcmp(this, &rhs, sizeof(rhs)) < 0; | 53 return memcmp(this, &rhs, sizeof(rhs)) < 0; |
(...skipping 29 matching lines...) Expand all Loading... |
78 }; | 83 }; |
79 typedef std::map<Texture*, TextureVersion> TextureMap; | 84 typedef std::map<Texture*, TextureVersion> TextureMap; |
80 TextureMap textures_; | 85 TextureMap textures_; |
81 | 86 |
82 linked_ptr<TextureGroup> GetGroupForMailboxLocked( | 87 linked_ptr<TextureGroup> GetGroupForMailboxLocked( |
83 const TargetName& target_name); | 88 const TargetName& target_name); |
84 void ReassociateMailboxLocked( | 89 void ReassociateMailboxLocked( |
85 const TargetName& target_name, | 90 const TargetName& target_name, |
86 TextureGroup* group); | 91 TextureGroup* group); |
87 void UpdateTextureLocked(Texture* texture, TextureVersion& texture_version); | 92 void UpdateTextureLocked(Texture* texture, TextureVersion& texture_version); |
| 93 void CreateFenceLocked(uint32 sync_point); |
| 94 void AcquireFenceLocked(uint32 sync_point); |
| 95 |
| 96 typedef std::map<uint32, linked_ptr<gfx::GLFence> > SyncPointToFenceMap; |
| 97 SyncPointToFenceMap sync_point_to_fence_; |
| 98 std::queue<SyncPointToFenceMap::iterator> sync_points_; |
88 | 99 |
89 DISALLOW_COPY_AND_ASSIGN(MailboxSynchronizer); | 100 DISALLOW_COPY_AND_ASSIGN(MailboxSynchronizer); |
90 }; | 101 }; |
91 | 102 |
92 } // namespage gles2 | 103 } // namespage gles2 |
93 } // namespace gpu | 104 } // namespace gpu |
94 | 105 |
95 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ | 106 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ |
96 | 107 |
OLD | NEW |