summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/mailbox_manager_impl.h
diff options
context:
space:
mode:
authorsievers <sievers@chromium.org>2014-10-24 12:11:34 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-24 19:12:15 +0000
commitb727d53654c5b686bd0cc3cd678ea0d78e0b95c8 (patch)
tree1e7627b79a2a0b0bd54527395050ea6a12fb18b5 /gpu/command_buffer/service/mailbox_manager_impl.h
parent2e434b4c460fb4274dbfc9ccd7561e7339d00926 (diff)
downloadchromium_src-b727d53654c5b686bd0cc3cd678ea0d78e0b95c8.zip
chromium_src-b727d53654c5b686bd0cc3cd678ea0d78e0b95c8.tar.gz
chromium_src-b727d53654c5b686bd0cc3cd678ea0d78e0b95c8.tar.bz2
gpu: Rewrite MailboxSynchronizer
The current version that tries to synchronize the tracked textures between separate MailboxManager instances does not get things right, see added tests. Simplify the problem by subclassing MailboxManager. NOTRY=True Review URL: https://codereview.chromium.org/670953004 Cr-Commit-Position: refs/heads/master@{#301165}
Diffstat (limited to 'gpu/command_buffer/service/mailbox_manager_impl.h')
-rw-r--r--gpu/command_buffer/service/mailbox_manager_impl.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/mailbox_manager_impl.h b/gpu/command_buffer/service/mailbox_manager_impl.h
new file mode 100644
index 0000000..9fd40b3
--- /dev/null
+++ b/gpu/command_buffer/service/mailbox_manager_impl.h
@@ -0,0 +1,65 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_IMPL_H_
+#define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_IMPL_H_
+
+#include <map>
+#include <utility>
+
+#include "base/memory/linked_ptr.h"
+#include "base/memory/ref_counted.h"
+#include "gpu/command_buffer/common/constants.h"
+#include "gpu/command_buffer/common/mailbox.h"
+#include "gpu/command_buffer/service/mailbox_manager.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+namespace gles2 {
+
+class Texture;
+class TextureManager;
+
+// Manages resources scoped beyond the context or context group level.
+class GPU_EXPORT MailboxManagerImpl : public MailboxManager {
+ public:
+ MailboxManagerImpl();
+
+ // MailboxManager implementation:
+ Texture* ConsumeTexture(unsigned target, const Mailbox& mailbox) override;
+ void ProduceTexture(unsigned target,
+ const Mailbox& mailbox,
+ Texture* texture) override;
+ bool UsesSync() override;
+ void PushTextureUpdates(uint32 sync_point) override {}
+ void PullTextureUpdates(uint32 sync_point) override {}
+ void TextureDeleted(Texture* texture) override;
+
+ protected:
+ ~MailboxManagerImpl() override;
+
+ private:
+ friend class base::RefCounted<MailboxManager>;
+
+ void InsertTexture(TargetName target_name, Texture* texture);
+
+ // This is a bidirectional map between mailbox and textures. We can have
+ // multiple mailboxes per texture, but one texture per mailbox. We keep an
+ // iterator in the MailboxToTextureMap to be able to manage changes to
+ // the TextureToMailboxMap efficiently.
+ typedef std::multimap<Texture*, TargetName> TextureToMailboxMap;
+ typedef std::map<TargetName, TextureToMailboxMap::iterator>
+ MailboxToTextureMap;
+
+ MailboxToTextureMap mailbox_to_textures_;
+ TextureToMailboxMap textures_to_mailboxes_;
+
+ DISALLOW_COPY_AND_ASSIGN(MailboxManagerImpl);
+};
+
+} // namespage gles2
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_IMPL_H_
+