Commit 1a23a18f authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

oop: Convert trasfer cache client api to be bulk unlock.

This patch fixes a TODO, and introduces a bulk API for unlocking
transfer cache entries.

R=ericrk@chromium.org, piman@chromium.org

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic13611fa2763fc7bb20000519f2f4e893264708a
Reviewed-on: https://chromium-review.googlesource.com/828062Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524297}
parent 792e646b
...@@ -35,7 +35,8 @@ void TransferCacheSerializeHelper::CreateEntry( ...@@ -35,7 +35,8 @@ void TransferCacheSerializeHelper::CreateEntry(
} }
void TransferCacheSerializeHelper::FlushEntries() { void TransferCacheSerializeHelper::FlushEntries() {
FlushEntriesInternal(added_entries_); FlushEntriesInternal(
std::vector<EntryKey>(added_entries_.begin(), added_entries_.end()));
added_entries_.clear(); added_entries_.clear();
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CC_PAINT_TRANSFER_CACHE_SERIALIZE_HELPER_H_ #define CC_PAINT_TRANSFER_CACHE_SERIALIZE_HELPER_H_
#include <set> #include <set>
#include <vector>
#include "cc/paint/paint_export.h" #include "cc/paint/paint_export.h"
#include "cc/paint/transfer_cache_entry.h" #include "cc/paint/transfer_cache_entry.h"
...@@ -27,7 +28,7 @@ class CC_PAINT_EXPORT TransferCacheSerializeHelper { ...@@ -27,7 +28,7 @@ class CC_PAINT_EXPORT TransferCacheSerializeHelper {
using EntryKey = std::pair<TransferCacheEntryType, uint32_t>; using EntryKey = std::pair<TransferCacheEntryType, uint32_t>;
virtual bool LockEntryInternal(TransferCacheEntryType type, uint32_t id) = 0; virtual bool LockEntryInternal(TransferCacheEntryType type, uint32_t id) = 0;
virtual void CreateEntryInternal(const ClientTransferCacheEntry& entry) = 0; virtual void CreateEntryInternal(const ClientTransferCacheEntry& entry) = 0;
virtual void FlushEntriesInternal(const std::set<EntryKey>& entries) = 0; virtual void FlushEntriesInternal(const std::vector<EntryKey>& entries) = 0;
std::set<EntryKey> added_entries_; std::set<EntryKey> added_entries_;
}; };
......
...@@ -103,7 +103,7 @@ TEST_F(TransferCacheTest, Basic) { ...@@ -103,7 +103,7 @@ TEST_F(TransferCacheTest, Basic) {
EXPECT_NE(nullptr, service_cache->GetEntry(entry.Type(), entry.Id())); EXPECT_NE(nullptr, service_cache->GetEntry(entry.Type(), entry.Id()));
// Unlock on client side and flush to service. // Unlock on client side and flush to service.
context_support->UnlockTransferCacheEntry(entry.Type(), entry.Id()); context_support->UnlockTransferCacheEntries({{entry.Type(), entry.Id()}});
gl->Finish(); gl->Finish();
// Re-lock on client side and validate state. No need to flush as lock is // Re-lock on client side and validate state. No need to flush as lock is
...@@ -131,7 +131,7 @@ TEST_F(TransferCacheTest, Eviction) { ...@@ -131,7 +131,7 @@ TEST_F(TransferCacheTest, Eviction) {
EXPECT_NE(nullptr, service_cache->GetEntry(entry.Type(), entry.Id())); EXPECT_NE(nullptr, service_cache->GetEntry(entry.Type(), entry.Id()));
// Unlock on client side and flush to service. // Unlock on client side and flush to service.
context_support->UnlockTransferCacheEntry(entry.Type(), entry.Id()); context_support->UnlockTransferCacheEntries({{entry.Type(), entry.Id()}});
gl->Finish(); gl->Finish();
// Evict on the service side. // Evict on the service side.
......
...@@ -123,9 +123,8 @@ bool TestContextSupport::ThreadsafeLockTransferCacheEntry( ...@@ -123,9 +123,8 @@ bool TestContextSupport::ThreadsafeLockTransferCacheEntry(
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return false; return false;
} }
void TestContextSupport::UnlockTransferCacheEntry( void TestContextSupport::UnlockTransferCacheEntries(
TransferCacheEntryType entry_type, const std::vector<std::pair<TransferCacheEntryType, uint32_t>>& entries) {
uint32_t entry_id) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void TestContextSupport::DeleteTransferCacheEntry( void TestContextSupport::DeleteTransferCacheEntry(
......
...@@ -58,8 +58,9 @@ class TestContextSupport : public gpu::ContextSupport { ...@@ -58,8 +58,9 @@ class TestContextSupport : public gpu::ContextSupport {
void CreateTransferCacheEntry(const ClientTransferCacheEntry& entry) override; void CreateTransferCacheEntry(const ClientTransferCacheEntry& entry) override;
bool ThreadsafeLockTransferCacheEntry(TransferCacheEntryType entry_type, bool ThreadsafeLockTransferCacheEntry(TransferCacheEntryType entry_type,
uint32_t entry_id) override; uint32_t entry_id) override;
void UnlockTransferCacheEntry(TransferCacheEntryType entry_type, void UnlockTransferCacheEntries(
uint32_t entry_id) override; const std::vector<std::pair<TransferCacheEntryType, uint32_t>>& entries)
override;
void DeleteTransferCacheEntry(TransferCacheEntryType entry_type, void DeleteTransferCacheEntry(TransferCacheEntryType entry_type,
uint32_t entry_id) override; uint32_t entry_id) override;
......
...@@ -57,7 +57,7 @@ void TransferCacheTestHelper::CreateEntryInternal( ...@@ -57,7 +57,7 @@ void TransferCacheTestHelper::CreateEntryInternal(
} }
void TransferCacheTestHelper::FlushEntriesInternal( void TransferCacheTestHelper::FlushEntriesInternal(
const std::set<EntryKey>& entries) { const std::vector<EntryKey>& entries) {
for (auto& entry : entries) for (auto& entry : entries)
locked_entries_.erase(entry); locked_entries_.erase(entry);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CC_TEST_TRANSFER_CACHE_TEST_HELPER_H_ #define CC_TEST_TRANSFER_CACHE_TEST_HELPER_H_
#include <map> #include <map>
#include <set> #include <vector>
#include "cc/paint/transfer_cache_deserialize_helper.h" #include "cc/paint/transfer_cache_deserialize_helper.h"
#include "cc/paint/transfer_cache_serialize_helper.h" #include "cc/paint/transfer_cache_serialize_helper.h"
...@@ -31,7 +31,7 @@ class TransferCacheTestHelper : public TransferCacheDeserializeHelper, ...@@ -31,7 +31,7 @@ class TransferCacheTestHelper : public TransferCacheDeserializeHelper,
// Serialization helpers. // Serialization helpers.
bool LockEntryInternal(TransferCacheEntryType type, uint32_t id) override; bool LockEntryInternal(TransferCacheEntryType type, uint32_t id) override;
void CreateEntryInternal(const ClientTransferCacheEntry& entry) override; void CreateEntryInternal(const ClientTransferCacheEntry& entry) override;
void FlushEntriesInternal(const std::set<EntryKey>& entries) override; void FlushEntriesInternal(const std::vector<EntryKey>& entries) override;
std::map<EntryKey, std::unique_ptr<ServiceTransferCacheEntry>> entries_; std::map<EntryKey, std::unique_ptr<ServiceTransferCacheEntry>> entries_;
std::set<EntryKey> locked_entries_; std::set<EntryKey> locked_entries_;
......
...@@ -53,13 +53,17 @@ bool ClientTransferCache::LockTransferCacheEntry( ...@@ -53,13 +53,17 @@ bool ClientTransferCache::LockTransferCacheEntry(
return false; return false;
} }
void ClientTransferCache::UnlockTransferCacheEntry( void ClientTransferCache::UnlockTransferCacheEntries(
gles2::GLES2CmdHelper* helper, gles2::GLES2CmdHelper* helper,
cc::TransferCacheEntryType type, const std::vector<std::pair<cc::TransferCacheEntryType, uint32_t>>&
uint32_t id) { entries) {
base::AutoLock hold(lock_); base::AutoLock hold(lock_);
for (const auto& entry : entries) {
auto type = entry.first;
auto id = entry.second;
DCHECK(!FindDiscardableHandleId(type, id).is_null()); DCHECK(!FindDiscardableHandleId(type, id).is_null());
helper->UnlockTransferCacheEntryINTERNAL(static_cast<uint32_t>(type), id); helper->UnlockTransferCacheEntryINTERNAL(static_cast<uint32_t>(type), id);
}
} }
void ClientTransferCache::DeleteTransferCacheEntry( void ClientTransferCache::DeleteTransferCacheEntry(
......
...@@ -24,7 +24,7 @@ class MappedMemoryManager; ...@@ -24,7 +24,7 @@ class MappedMemoryManager;
// them available for consumption in the GPU process. Typical usage is: // them available for consumption in the GPU process. Typical usage is:
// 1) Insert a new entry via CreateCacheEntry. It starts locked. // 1) Insert a new entry via CreateCacheEntry. It starts locked.
// 2) Use the new entry's ID in one or more commands. // 2) Use the new entry's ID in one or more commands.
// 3) Unlock the entry via UnlockTransferCacheEntry after dependent commands // 3) Unlock the entry via UnlockTransferCacheEntries after dependent commands
// have been issued. // have been issued.
// //
// If an entry is needed again: // If an entry is needed again:
...@@ -48,9 +48,10 @@ class GLES2_IMPL_EXPORT ClientTransferCache { ...@@ -48,9 +48,10 @@ class GLES2_IMPL_EXPORT ClientTransferCache {
MappedMemoryManager* mapped_memory, MappedMemoryManager* mapped_memory,
const cc::ClientTransferCacheEntry& entry); const cc::ClientTransferCacheEntry& entry);
bool LockTransferCacheEntry(cc::TransferCacheEntryType type, uint32_t id); bool LockTransferCacheEntry(cc::TransferCacheEntryType type, uint32_t id);
void UnlockTransferCacheEntry(gles2::GLES2CmdHelper* helper, void UnlockTransferCacheEntries(
cc::TransferCacheEntryType type, gles2::GLES2CmdHelper* helper,
uint32_t id); const std::vector<std::pair<cc::TransferCacheEntryType, uint32_t>>&
entries);
void DeleteTransferCacheEntry(gles2::GLES2CmdHelper* helper, void DeleteTransferCacheEntry(gles2::GLES2CmdHelper* helper,
cc::TransferCacheEntryType type, cc::TransferCacheEntryType type,
uint32_t id); uint32_t id);
......
...@@ -102,8 +102,9 @@ class ContextSupport { ...@@ -102,8 +102,9 @@ class ContextSupport {
const cc::ClientTransferCacheEntry& entry) = 0; const cc::ClientTransferCacheEntry& entry) = 0;
virtual bool ThreadsafeLockTransferCacheEntry(cc::TransferCacheEntryType type, virtual bool ThreadsafeLockTransferCacheEntry(cc::TransferCacheEntryType type,
uint32_t id) = 0; uint32_t id) = 0;
virtual void UnlockTransferCacheEntry(cc::TransferCacheEntryType type, virtual void UnlockTransferCacheEntries(
uint32_t id) = 0; const std::vector<std::pair<cc::TransferCacheEntryType, uint32_t>>&
entries) = 0;
virtual void DeleteTransferCacheEntry(cc::TransferCacheEntryType type, virtual void DeleteTransferCacheEntry(cc::TransferCacheEntryType type,
uint32_t id) = 0; uint32_t id) = 0;
......
...@@ -119,11 +119,9 @@ class TransferCacheSerializeHelperImpl ...@@ -119,11 +119,9 @@ class TransferCacheSerializeHelperImpl
} }
void FlushEntriesInternal( void FlushEntriesInternal(
const std::set<std::pair<cc::TransferCacheEntryType, uint32_t>>& entries) const std::vector<std::pair<cc::TransferCacheEntryType, uint32_t>>&
final { entries) final {
// TODO(vmpstr): Add a bulk unlock API instead. gl_->UnlockTransferCacheEntries(entries);
for (auto& entry : entries)
gl_->UnlockTransferCacheEntry(entry.first, entry.second);
} }
GLES2Implementation* gl_; GLES2Implementation* gl_;
...@@ -6195,10 +6193,10 @@ bool GLES2Implementation::ThreadsafeLockTransferCacheEntry( ...@@ -6195,10 +6193,10 @@ bool GLES2Implementation::ThreadsafeLockTransferCacheEntry(
return share_group()->transfer_cache()->LockTransferCacheEntry(type, id); return share_group()->transfer_cache()->LockTransferCacheEntry(type, id);
} }
void GLES2Implementation::UnlockTransferCacheEntry( void GLES2Implementation::UnlockTransferCacheEntries(
cc::TransferCacheEntryType type, const std::vector<std::pair<cc::TransferCacheEntryType, uint32_t>>&
uint32_t id) { entries) {
share_group()->transfer_cache()->UnlockTransferCacheEntry(helper_, type, id); share_group()->transfer_cache()->UnlockTransferCacheEntries(helper_, entries);
} }
void GLES2Implementation::DeleteTransferCacheEntry( void GLES2Implementation::DeleteTransferCacheEntry(
......
...@@ -221,8 +221,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation ...@@ -221,8 +221,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation
const cc::ClientTransferCacheEntry& entry) override; const cc::ClientTransferCacheEntry& entry) override;
bool ThreadsafeLockTransferCacheEntry(cc::TransferCacheEntryType type, bool ThreadsafeLockTransferCacheEntry(cc::TransferCacheEntryType type,
uint32_t id) override; uint32_t id) override;
void UnlockTransferCacheEntry(cc::TransferCacheEntryType type, void UnlockTransferCacheEntries(
uint32_t id) override; const std::vector<std::pair<cc::TransferCacheEntryType, uint32_t>>&
entries) override;
void DeleteTransferCacheEntry(cc::TransferCacheEntryType type, void DeleteTransferCacheEntry(cc::TransferCacheEntryType type,
uint32_t id) override; uint32_t id) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment