Call SimplePool methods directly
This removes redundant helper functions in GpuBufferMultiPool. PiperOrigin-RevId: 488782516
This commit is contained in:
parent
0c4522cb9f
commit
f13903b7c5
|
@ -21,12 +21,6 @@
|
||||||
#include "mediapipe/framework/port/logging.h"
|
#include "mediapipe/framework/port/logging.h"
|
||||||
#include "mediapipe/gpu/gpu_shared_data_internal.h"
|
#include "mediapipe/gpu/gpu_shared_data_internal.h"
|
||||||
|
|
||||||
#if MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER
|
|
||||||
#include "CoreFoundation/CFBase.h"
|
|
||||||
#include "mediapipe/objc/CFHolder.h"
|
|
||||||
#include "mediapipe/objc/util.h"
|
|
||||||
#endif // MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER
|
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
// Keep this many buffers allocated for a given frame size.
|
// Keep this many buffers allocated for a given frame size.
|
||||||
|
@ -87,20 +81,11 @@ GpuBuffer GpuBufferMultiPool::GetBuffer(int width, int height,
|
||||||
std::shared_ptr<SimplePool> pool = RequestPool(key);
|
std::shared_ptr<SimplePool> pool = RequestPool(key);
|
||||||
if (pool) {
|
if (pool) {
|
||||||
// Note: we release our multipool lock before accessing the simple pool.
|
// Note: we release our multipool lock before accessing the simple pool.
|
||||||
return GetBufferFromSimplePool(key, *pool);
|
return GpuBuffer(pool->GetBuffer());
|
||||||
} else {
|
} else {
|
||||||
return GetBufferWithoutPool(key);
|
return GpuBuffer(
|
||||||
|
SimplePool::CreateBufferWithoutPool(width, height, format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuBuffer GpuBufferMultiPool::GetBufferFromSimplePool(
|
|
||||||
BufferSpec spec, GpuBufferMultiPool::SimplePool& pool) {
|
|
||||||
return GpuBuffer(pool.GetBuffer());
|
|
||||||
}
|
|
||||||
|
|
||||||
GpuBuffer GpuBufferMultiPool::GetBufferWithoutPool(const BufferSpec& spec) {
|
|
||||||
return GpuBuffer(SimplePool::CreateBufferWithoutPool(spec.width, spec.height,
|
|
||||||
spec.format));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mediapipe
|
} // namespace mediapipe
|
||||||
|
|
|
@ -82,11 +82,8 @@ class GpuBufferMultiPool {
|
||||||
std::shared_ptr<SimplePool> MakeSimplePool(const BufferSpec& spec);
|
std::shared_ptr<SimplePool> MakeSimplePool(const BufferSpec& spec);
|
||||||
// Requests a simple buffer pool for the given spec. This may return nullptr
|
// Requests a simple buffer pool for the given spec. This may return nullptr
|
||||||
// if we have not yet reached a sufficient number of requests to allocate a
|
// if we have not yet reached a sufficient number of requests to allocate a
|
||||||
// pool, in which case the caller should invoke GetBufferWithoutPool instead
|
// pool, in which case the caller should invoke CreateBufferWithoutPool.
|
||||||
// of GetBufferFromSimplePool.
|
|
||||||
std::shared_ptr<SimplePool> RequestPool(const BufferSpec& spec);
|
std::shared_ptr<SimplePool> RequestPool(const BufferSpec& spec);
|
||||||
GpuBuffer GetBufferFromSimplePool(BufferSpec spec, SimplePool& pool);
|
|
||||||
GpuBuffer GetBufferWithoutPool(const BufferSpec& spec);
|
|
||||||
|
|
||||||
absl::Mutex mutex_;
|
absl::Mutex mutex_;
|
||||||
mediapipe::ResourceCache<BufferSpec, std::shared_ptr<SimplePool>> cache_
|
mediapipe::ResourceCache<BufferSpec, std::shared_ptr<SimplePool>> cache_
|
||||||
|
|
Loading…
Reference in New Issue
Block a user