mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 23:56:39 +08:00
fix: change global Var/Const Buffer type to SharedPoolAllocation
This is prep work for the future implementation of pooling these allocations. Related-To: NEO-12287 Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6539b3e01a
commit
a2f60af5c6
@@ -7,15 +7,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace NEO {
|
||||
class GraphicsAllocation;
|
||||
|
||||
class SharedPoolAllocation {
|
||||
public:
|
||||
SharedPoolAllocation(GraphicsAllocation *graphicsAllocation, size_t offset, size_t size, std::mutex *mtx)
|
||||
: graphicsAllocation(graphicsAllocation), offset(offset), size(size), mtx(*mtx){};
|
||||
: graphicsAllocation(graphicsAllocation), offset(offset), size(size), mtx(mtx){};
|
||||
|
||||
explicit SharedPoolAllocation(GraphicsAllocation *graphicsAllocation)
|
||||
: graphicsAllocation(graphicsAllocation), offset(0u), size(graphicsAllocation ? graphicsAllocation->getUnderlyingBufferSize() : 0u), mtx(nullptr){};
|
||||
|
||||
GraphicsAllocation *getGraphicsAllocation() const {
|
||||
return graphicsAllocation;
|
||||
@@ -29,15 +33,35 @@ class SharedPoolAllocation {
|
||||
return size;
|
||||
}
|
||||
|
||||
uint64_t getGpuAddress() const {
|
||||
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
|
||||
return graphicsAllocation->getGpuAddress() + offset;
|
||||
}
|
||||
|
||||
uint64_t getGpuAddressToPatch() const {
|
||||
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
|
||||
return graphicsAllocation->getGpuAddressToPatch() + offset;
|
||||
}
|
||||
|
||||
void *getUnderlyingBuffer() const {
|
||||
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
|
||||
return ptrOffset(graphicsAllocation->getUnderlyingBuffer(), offset);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> obtainSharedAllocationLock() {
|
||||
return std::unique_lock<std::mutex>(mtx);
|
||||
if (mtx) {
|
||||
return std::unique_lock<std::mutex>(*mtx);
|
||||
} else {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return std::unique_lock<std::mutex>();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GraphicsAllocation *graphicsAllocation;
|
||||
const size_t offset;
|
||||
const size_t size;
|
||||
std::mutex &mtx; // This mutex is shared across all users of this GA
|
||||
std::mutex *mtx; // This mutex is shared across all users of this GA
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user