Prepare for future changes

- Implement changing MemObj's GraphicsAllocation
- Create function for resolving change of SharedHandler's GraphicsAllocation

Change-Id: Ibd975070ca11ba8591f5561d9f02bf5d9af1636b
This commit is contained in:
Maciej Dziuban
2018-07-04 10:41:58 +02:00
committed by sys_ocldev
parent a95c6d3c1a
commit 4993a94b5b
6 changed files with 152 additions and 14 deletions

View File

@@ -246,6 +246,16 @@ GraphicsAllocation *MemObj::getGraphicsAllocation() {
return graphicsAllocation;
}
void MemObj::resetGraphicsAllocation(GraphicsAllocation *newGraphicsAllocation) {
TakeOwnershipWrapper<MemObj> lock(*this);
if (graphicsAllocation != nullptr && (peekSharingHandler() == nullptr || graphicsAllocation->peekReuseCount() == 0)) {
memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(graphicsAllocation);
}
graphicsAllocation = newGraphicsAllocation;
}
bool MemObj::readMemObjFlagsInvalid() {
if (this->getFlags() & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS)) {
return true;

View File

@@ -94,6 +94,7 @@ class MemObj : public BaseObject<_cl_mem> {
virtual void transferDataFromHostPtr(MemObjSizeArray &copySize, MemObjOffsetArray &copyOffset) { UNRECOVERABLE_IF(true); };
GraphicsAllocation *getGraphicsAllocation();
void resetGraphicsAllocation(GraphicsAllocation *newGraphicsAllocation);
GraphicsAllocation *getMcsAllocation() { return mcsAllocation; }
void setMcsAllocation(GraphicsAllocation *alloc) { mcsAllocation = alloc; }
@@ -115,7 +116,7 @@ class MemObj : public BaseObject<_cl_mem> {
void setSharingHandler(SharingHandler *sharingHandler) { this->sharingHandler.reset(sharingHandler); }
void setParentSharingHandler(std::shared_ptr<SharingHandler> &handler) { sharingHandler = handler; }
unsigned int acquireCount = 0;
const Context *getContext() const { return context; }
Context *getContext() const { return context; }
void waitForCsrCompletion();
void destroyGraphicsAllocation(GraphicsAllocation *allocation, bool asyncDestroy);