[SIPool] Update SharedImagePool to use new PoolId.
Update SharedImagePool to use new PoolId which is unguessable. This is required since pool id will later be stored in a shared image backing generated from a pool. It will be used to identify the pool to which the backing belongs. Since the pool id will be sent across multiple process including renderers, browser and gpu process, it needs to be unguessable. Bug: 383466770 Change-Id: Iff0da80e5ecbb5461124ca16f7cee9eec46556d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6088286 Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Auto-Submit: vikas soni <vikassoni@chromium.org> Commit-Queue: vikas soni <vikassoni@chromium.org> Cr-Commit-Position: refs/heads/main@{#1395620}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e53581b711
commit
eb5e095127
gpu/command_buffer
@ -4,7 +4,6 @@
|
||||
|
||||
#include "gpu/command_buffer/client/shared_image_pool.h"
|
||||
|
||||
#include "base/atomic_sequence_num.h"
|
||||
#include "gpu/command_buffer/client/shared_image_interface.h"
|
||||
|
||||
namespace {
|
||||
@ -17,8 +16,6 @@ gpu::ImageInfo GetImageInfo(scoped_refptr<gpu::ClientImage> image) {
|
||||
shared_image->alpha_type(), shared_image->buffer_usage());
|
||||
}
|
||||
|
||||
base::AtomicSequenceNumber g_pool_id;
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace gpu {
|
||||
@ -47,16 +44,17 @@ void ClientImage::SetReleaseSyncToken(SyncToken release_sync_token) {
|
||||
sync_token_ = std::move(release_sync_token);
|
||||
}
|
||||
|
||||
int ClientImage::GetPoolIdForTesting() const {
|
||||
const PoolId& ClientImage::GetPoolIdForTesting() const {
|
||||
return pool_id_;
|
||||
}
|
||||
|
||||
SharedImagePoolBase::SharedImagePoolBase(
|
||||
const PoolId& pool_id,
|
||||
const ImageInfo& image_info,
|
||||
const scoped_refptr<SharedImageInterface> sii,
|
||||
std::optional<uint8_t> max_pool_size,
|
||||
std::optional<base::TimeDelta> unused_resource_expiration_time)
|
||||
: pool_id_(g_pool_id.GetNext()),
|
||||
: pool_id_(pool_id),
|
||||
image_info_(image_info),
|
||||
sii_(std::move(sii)),
|
||||
max_pool_size_(std::move(max_pool_size)),
|
||||
@ -113,7 +111,7 @@ void SharedImagePoolBase::ReleaseImageInternal(
|
||||
}
|
||||
|
||||
// Ensure that the |image| belongs to |this| pool.
|
||||
CHECK_EQ(image->pool_id_, pool_id_);
|
||||
CHECK_EQ(image->pool_id_.ToString(), pool_id_.ToString());
|
||||
|
||||
// Ensure that there is only one reference which the current |image| and
|
||||
// clients are not accidentally keeping more references alive while releasing
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "components/viz/common/resources/shared_image_format.h"
|
||||
#include "gpu/command_buffer/client/client_shared_image.h"
|
||||
#include "gpu/command_buffer/client/shared_image_interface.h"
|
||||
#include "gpu/command_buffer/common/shared_image_pool_id.h"
|
||||
#include "gpu/command_buffer/common/shared_image_usage.h"
|
||||
#include "gpu/command_buffer/common/sync_token.h"
|
||||
#include "gpu/gpu_export.h"
|
||||
@ -90,7 +91,7 @@ class GPU_EXPORT ClientImage : public base::RefCounted<ClientImage> {
|
||||
void SetReleaseSyncToken(SyncToken release_sync_token);
|
||||
|
||||
// Only used for testing purposes.
|
||||
int GetPoolIdForTesting() const;
|
||||
const PoolId& GetPoolIdForTesting() const;
|
||||
|
||||
protected:
|
||||
friend class base::RefCounted<ClientImage>;
|
||||
@ -114,8 +115,8 @@ class GPU_EXPORT ClientImage : public base::RefCounted<ClientImage> {
|
||||
// the client.
|
||||
base::TimeTicks last_used_time_ = base::TimeTicks::Now();
|
||||
|
||||
// Unique identifier to identify the pool this image belongs to.
|
||||
int pool_id_;
|
||||
// Unique unguessable identifier to identify the pool this image belongs to.
|
||||
PoolId pool_id_;
|
||||
};
|
||||
|
||||
// This class is designed to handle bulk of functionality of the image pool.
|
||||
@ -133,6 +134,7 @@ class GPU_EXPORT SharedImagePoolBase {
|
||||
|
||||
protected:
|
||||
SharedImagePoolBase(
|
||||
const PoolId& pool_id,
|
||||
const ImageInfo& image_info,
|
||||
const scoped_refptr<SharedImageInterface> sii,
|
||||
std::optional<uint8_t> max_pool_size,
|
||||
@ -145,7 +147,7 @@ class GPU_EXPORT SharedImagePoolBase {
|
||||
void ReconfigureInternal(const ImageInfo& image_info);
|
||||
|
||||
// Unique identifier to identify this pool and all images generated from it.
|
||||
const int pool_id_;
|
||||
const PoolId pool_id_;
|
||||
|
||||
// Information used to create new ClientSharedImage.
|
||||
ImageInfo image_info_;
|
||||
@ -249,7 +251,8 @@ class GPU_EXPORT SharedImagePool : public SharedImagePoolBase {
|
||||
scoped_refptr<SharedImageInterface> sii,
|
||||
std::optional<uint8_t> max_pool_size,
|
||||
std::optional<base::TimeDelta> unused_resource_expiration_time)
|
||||
: SharedImagePoolBase(image_info,
|
||||
: SharedImagePoolBase(PoolId::Create(),
|
||||
image_info,
|
||||
std::move(sii),
|
||||
std::move(max_pool_size),
|
||||
std::move(unused_resource_expiration_time)) {}
|
||||
|
@ -14,7 +14,7 @@ PoolId PoolId::Create() {
|
||||
return PoolId(base::UnguessableToken::Create());
|
||||
}
|
||||
|
||||
std::string PoolId::ToDebugString() const {
|
||||
std::string PoolId::ToString() const {
|
||||
return token_.ToString();
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@ class GPU_EXPORT PoolId {
|
||||
// Creates a new PoolId with a cryptographically random value.
|
||||
static PoolId Create();
|
||||
|
||||
// Generates a debug string representation of the PoolId.
|
||||
std::string ToDebugString() const;
|
||||
// Generates a string representation of the PoolId.
|
||||
std::string ToString() const;
|
||||
|
||||
bool operator==(const PoolId& other) const { return token_ == other.token_; }
|
||||
|
||||
|
Reference in New Issue
Block a user