Add allowCapture flag to BufferObject
Related-To: NEO-5026 Change-Id: I69a9f270272a13fccdd1d8dd8b13ad03ef93cb79 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
parent
e48c056b9f
commit
0e935b0e10
|
@ -344,3 +344,15 @@ TEST(DrmBufferObject, whenBindExtHandleAddedThenItIsStored) {
|
|||
EXPECT_EQ(1u, bo.getBindExtHandles().size());
|
||||
EXPECT_EQ(4u, bo.getBindExtHandles()[0]);
|
||||
}
|
||||
|
||||
TEST(DrmBufferObject, whenMarkForCapturedCalledThenIsMarkedForCaptureReturnsTrue) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
EXPECT_FALSE(bo.isMarkedForCapture());
|
||||
|
||||
bo.markForCapture();
|
||||
EXPECT_TRUE(bo.isMarkedForCapture());
|
||||
}
|
||||
|
|
|
@ -4014,4 +4014,20 @@ TEST(DrmMemoryManager, givenNullBoWhenRegisteringBindExtHandleThenEarlyReturn) {
|
|||
gfxAllocation.freeRegisteredBOBindExtHandles(mockDrm.get());
|
||||
}
|
||||
|
||||
TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenAllocationIsRegisteredThenBosAreMarkedForCapture) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
|
||||
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
// mock resource registration enabling by storing class handles
|
||||
drm.classHandles.push_back(1);
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA, MemoryPool::System4KBPages);
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
allocation.registerBOBindExtHandle(&drm);
|
||||
|
||||
EXPECT_TRUE(bo.isMarkedForCapture());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -418,7 +418,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(const A
|
|||
this->registerSysMemAlloc(allocation);
|
||||
}
|
||||
FileLoggerInstance().logAllocation(allocation);
|
||||
registerAllocation(allocation);
|
||||
registerAllocationInOs(allocation);
|
||||
return allocation;
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ class MemoryManager {
|
|||
virtual void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) = 0;
|
||||
virtual void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) = 0;
|
||||
virtual void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) { return unlockResourceImpl(graphicsAllocation); };
|
||||
virtual void registerAllocation(GraphicsAllocation *allocation) {}
|
||||
virtual void registerAllocationInOs(GraphicsAllocation *allocation) {}
|
||||
|
||||
bool initialized = false;
|
||||
bool forceNonSvmForExternalHostPtr = false;
|
||||
|
|
|
@ -95,6 +95,7 @@ void DrmAllocation::registerBOBindExtHandle(Drm *drm) {
|
|||
for (auto bo : bos) {
|
||||
if (bo) {
|
||||
bo->addBindExtHandle(handle);
|
||||
bo->markForCapture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,12 @@ class BufferObject {
|
|||
bool peekIsReusableAllocation() const { return this->isReused; }
|
||||
void addBindExtHandle(uint32_t handle);
|
||||
StackVec<uint32_t, 2> &getBindExtHandles() { return bindExtHandles; }
|
||||
void markForCapture() {
|
||||
allowCapture = true;
|
||||
}
|
||||
bool isMarkedForCapture() {
|
||||
return allowCapture;
|
||||
}
|
||||
|
||||
protected:
|
||||
Drm *drm = nullptr;
|
||||
|
@ -83,6 +89,7 @@ class BufferObject {
|
|||
|
||||
//Tiling
|
||||
uint32_t tiling_mode;
|
||||
bool allowCapture = false;
|
||||
|
||||
MOCKABLE_VIRTUAL void fillExecObject(drm_i915_gem_exec_object2 &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId);
|
||||
void fillExecObjectImpl(drm_i915_gem_exec_object2 &execObject, OsContext *osContext, uint32_t vmHandleId);
|
||||
|
|
|
@ -930,7 +930,7 @@ void DrmMemoryManager::unregisterAllocation(GraphicsAllocation *allocation) {
|
|||
localMemAllocs[allocation->getRootDeviceIndex()].end());
|
||||
}
|
||||
|
||||
void DrmMemoryManager::registerAllocation(GraphicsAllocation *allocation) {
|
||||
void DrmMemoryManager::registerAllocationInOs(GraphicsAllocation *allocation) {
|
||||
if (allocation) {
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
|
||||
drmAllocation->registerBOBindExtHandle(&getDrm(drmAllocation->getRootDeviceIndex()));
|
||||
|
|
|
@ -101,7 +101,7 @@ class DrmMemoryManager : public MemoryManager {
|
|||
DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount);
|
||||
void registerAllocation(GraphicsAllocation *allocation) override;
|
||||
void registerAllocationInOs(GraphicsAllocation *allocation) override;
|
||||
|
||||
Drm &getDrm(uint32_t rootDeviceIndex) const;
|
||||
uint32_t getRootDeviceIndex(const Drm *drm);
|
||||
|
|
|
@ -68,7 +68,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
|
|||
using DrmMemoryManager::pinBBs;
|
||||
using DrmMemoryManager::pinThreshold;
|
||||
using DrmMemoryManager::pushSharedBufferObject;
|
||||
using DrmMemoryManager::registerAllocation;
|
||||
using DrmMemoryManager::registerAllocationInOs;
|
||||
using DrmMemoryManager::releaseGpuRange;
|
||||
using DrmMemoryManager::setDomainCpu;
|
||||
using DrmMemoryManager::sharingBufferObjects;
|
||||
|
|
Loading…
Reference in New Issue