mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
Decouple Buffer Object and Exec Objects Storage.
Change-Id: Id47c071372959d43ccf3034917f2a5c39b707b38 Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
f24b428cf7
commit
06a7d8c32e
@@ -32,7 +32,6 @@ namespace OCLRT {
|
||||
BufferObject::BufferObject(Drm *drm, int handle, bool isAllocated) : drm(drm), refCount(1), handle(handle), isReused(false), isAllocated(isAllocated) {
|
||||
this->tiling_mode = I915_TILING_NONE;
|
||||
this->stride = 0;
|
||||
execObjectsStorage = nullptr;
|
||||
this->size = 0;
|
||||
this->lockedAddress = nullptr;
|
||||
}
|
||||
@@ -108,18 +107,18 @@ void BufferObject::fillExecObject(drm_i915_gem_exec_object2 &execObject, uint32_
|
||||
execObject.rsvd2 = 0;
|
||||
}
|
||||
|
||||
void BufferObject::processRelocs(int &idx, uint32_t drmContextId, ResidencyVector &residency) {
|
||||
void BufferObject::processRelocs(int &idx, uint32_t drmContextId, ResidencyVector &residency, drm_i915_gem_exec_object2 *execObjectsStorage) {
|
||||
for (size_t i = 0; i < residency.size(); i++) {
|
||||
residency[i]->fillExecObject(execObjectsStorage[idx], drmContextId);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, ResidencyVector &residency) {
|
||||
int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, ResidencyVector &residency, drm_i915_gem_exec_object2 *execObjectsStorage) {
|
||||
drm_i915_gem_execbuffer2 execbuf = {};
|
||||
|
||||
int idx = 0;
|
||||
processRelocs(idx, drmContextId, residency);
|
||||
processRelocs(idx, drmContextId, residency, execObjectsStorage);
|
||||
this->fillExecObject(execObjectsStorage[idx], drmContextId);
|
||||
idx++;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class BufferObject {
|
||||
|
||||
MOCKABLE_VIRTUAL int pin(BufferObject *const boToPin[], size_t numberOfBos, uint32_t drmContextId);
|
||||
|
||||
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, ResidencyVector &residency);
|
||||
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, ResidencyVector &residency, drm_i915_gem_exec_object2 *execObjectsStorage);
|
||||
|
||||
int wait(int64_t timeoutNs);
|
||||
bool close();
|
||||
@@ -61,9 +61,6 @@ class BufferObject {
|
||||
void setLockedAddress(void *cpuAddress) { this->lockedAddress = cpuAddress; }
|
||||
void setUnmapSize(uint64_t unmapSize) { this->unmapSize = unmapSize; }
|
||||
uint64_t peekUnmapSize() const { return unmapSize; }
|
||||
void setExecObjectsStorage(drm_i915_gem_exec_object2 *storage) {
|
||||
execObjectsStorage = storage;
|
||||
}
|
||||
StorageAllocatorType peekAllocationType() const { return storageAllocatorType; }
|
||||
void setAllocationType(StorageAllocatorType allocatorType) { this->storageAllocatorType = allocatorType; }
|
||||
bool peekIsReusableAllocation() { return this->isReused; }
|
||||
@@ -75,8 +72,6 @@ class BufferObject {
|
||||
|
||||
std::atomic<uint32_t> refCount;
|
||||
|
||||
drm_i915_gem_exec_object2 *execObjectsStorage;
|
||||
|
||||
int handle; // i915 gem object handle
|
||||
bool isReused;
|
||||
|
||||
@@ -85,7 +80,7 @@ class BufferObject {
|
||||
uint32_t stride;
|
||||
|
||||
MOCKABLE_VIRTUAL void fillExecObject(drm_i915_gem_exec_object2 &execObject, uint32_t drmContextId);
|
||||
void processRelocs(int &idx, uint32_t drmContextId, ResidencyVector &residency);
|
||||
void processRelocs(int &idx, uint32_t drmContextId, ResidencyVector &residency, drm_i915_gem_exec_object2 *execObjectsStorage);
|
||||
|
||||
uint64_t gpuAddress = 0llu;
|
||||
|
||||
|
||||
@@ -63,13 +63,12 @@ FlushStamp DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer,
|
||||
this->execObjectsStorage.resize(requiredSize);
|
||||
}
|
||||
|
||||
bb->setExecObjectsStorage(this->execObjectsStorage.data());
|
||||
|
||||
bb->exec(static_cast<uint32_t>(alignUp(batchBuffer.usedSize - batchBuffer.startOffset, 8)),
|
||||
alignedStart, engineFlag | I915_EXEC_NO_RELOC,
|
||||
batchBuffer.requiresCoherency,
|
||||
static_cast<OsContextLinux *>(osContext)->getDrmContextId(),
|
||||
this->residency);
|
||||
this->residency,
|
||||
this->execObjectsStorage.data());
|
||||
|
||||
this->residency.clear();
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ class DrmBufferObjectFixture {
|
||||
ASSERT_NE(nullptr, this->mock);
|
||||
bo = new TestedBufferObject(this->mock);
|
||||
ASSERT_NE(nullptr, bo);
|
||||
bo->setExecObjectsStorage(execObjectsStorage);
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
@@ -69,7 +68,8 @@ TEST_F(DrmBufferObjectTest, exec) {
|
||||
mock->ioctl_res = 0;
|
||||
|
||||
BufferObject::ResidencyVector residency;
|
||||
auto ret = bo->exec(0, 0, 0, false, 1, residency);
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
auto ret = bo->exec(0, 0, 0, false, 1, residency, &execObjectsStorage);
|
||||
EXPECT_EQ(mock->ioctl_res, ret);
|
||||
EXPECT_EQ(0u, mock->execBuffer.flags);
|
||||
}
|
||||
@@ -78,7 +78,8 @@ TEST_F(DrmBufferObjectTest, exec_ioctlFailed) {
|
||||
mock->ioctl_expected.total = 1;
|
||||
mock->ioctl_res = -1;
|
||||
BufferObject::ResidencyVector residency;
|
||||
EXPECT_THROW(bo->exec(0, 0, 0, false, 1, residency), std::exception);
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
EXPECT_THROW(bo->exec(0, 0, 0, false, 1, residency, &execObjectsStorage), std::exception);
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, setTiling_success) {
|
||||
@@ -145,8 +146,6 @@ TEST(DrmBufferObjectSimpleTest, givenInvalidBoWhenPinIsCalledThenErrorIsReturned
|
||||
ASSERT_NE(nullptr, mock.get());
|
||||
std::unique_ptr<TestedBufferObject> bo(new TestedBufferObject(mock.get()));
|
||||
ASSERT_NE(nullptr, bo.get());
|
||||
drm_i915_gem_exec_object2 execObjectsStorage[3];
|
||||
bo->setExecObjectsStorage(execObjectsStorage);
|
||||
|
||||
// fail DRM_IOCTL_I915_GEM_EXECBUFFER2 in pin
|
||||
mock->ioctl_res = -1;
|
||||
@@ -168,8 +167,6 @@ TEST(DrmBufferObjectSimpleTest, givenArrayOfBosWhenPinnedThenAllBosArePinned) {
|
||||
ASSERT_NE(nullptr, mock.get());
|
||||
std::unique_ptr<TestedBufferObject> bo(new TestedBufferObject(mock.get()));
|
||||
ASSERT_NE(nullptr, bo.get());
|
||||
drm_i915_gem_exec_object2 execObjectsStorage[4];
|
||||
bo->setExecObjectsStorage(execObjectsStorage);
|
||||
mock->ioctl_res = 0;
|
||||
|
||||
std::unique_ptr<TestedBufferObject> boToPin(new TestedBufferObject(mock.get()));
|
||||
|
||||
Reference in New Issue
Block a user