mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Refactor duplicate Linux code.
Related-To: NEO-3008 Change-Id: Ia920fc9e4b948fb73fe6c6abc7d2c35f1814dc85 Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
This commit is contained in:
@@ -107,67 +107,35 @@ void BufferObject::fillExecObject(drm_i915_gem_exec_object2 &execObject, uint32_
|
||||
execObject.rsvd2 = 0;
|
||||
}
|
||||
|
||||
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, BufferObject *const residency[], size_t residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage) {
|
||||
for (size_t i = 0; i < residencyCount; i++) {
|
||||
residency[i]->fillExecObject(execObjectsStorage[i], drmContextId);
|
||||
}
|
||||
}
|
||||
|
||||
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, execObjectsStorage);
|
||||
this->fillExecObject(execObjectsStorage[idx], drmContextId);
|
||||
idx++;
|
||||
this->fillExecObject(execObjectsStorage[residencyCount], drmContextId);
|
||||
|
||||
drm_i915_gem_execbuffer2 execbuf{};
|
||||
execbuf.buffers_ptr = reinterpret_cast<uintptr_t>(execObjectsStorage);
|
||||
execbuf.buffer_count = idx;
|
||||
execbuf.buffer_count = static_cast<uint32_t>(residencyCount + 1u);
|
||||
execbuf.batch_start_offset = static_cast<uint32_t>(startOffset);
|
||||
execbuf.batch_len = alignUp(used, 8);
|
||||
execbuf.flags = flags;
|
||||
execbuf.rsvd1 = drmContextId;
|
||||
|
||||
int ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
if (ret != 0) {
|
||||
int err = errno;
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int BufferObject::pin(BufferObject *const boToPin[], size_t numberOfBos, uint32_t drmContextId) {
|
||||
drm_i915_gem_execbuffer2 execbuf = {};
|
||||
StackVec<drm_i915_gem_exec_object2, maxFragmentsCount + 1> execObject;
|
||||
|
||||
reinterpret_cast<uint32_t *>(this->gpuAddress)[0] = 0x05000000;
|
||||
reinterpret_cast<uint32_t *>(this->gpuAddress)[1] = 0x00000000;
|
||||
|
||||
execObject.resize(numberOfBos + 1);
|
||||
|
||||
uint32_t boIndex = 0;
|
||||
for (boIndex = 0; boIndex < (uint32_t)numberOfBos; boIndex++) {
|
||||
boToPin[boIndex]->fillExecObject(execObject[boIndex], drmContextId);
|
||||
}
|
||||
|
||||
this->fillExecObject(execObject[boIndex], drmContextId);
|
||||
|
||||
execbuf.buffers_ptr = reinterpret_cast<uintptr_t>(&execObject[0]);
|
||||
execbuf.buffer_count = boIndex + 1;
|
||||
execbuf.batch_len = alignUp(static_cast<uint32_t>(sizeof(uint32_t)), 8);
|
||||
execbuf.rsvd1 = drmContextId;
|
||||
|
||||
int err = 0;
|
||||
int ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
if (ret != 0) {
|
||||
err = this->drm->getErrno();
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int err = this->drm->getErrno();
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
int BufferObject::pin(BufferObject *const boToPin[], size_t numberOfBos, uint32_t drmContextId) {
|
||||
reinterpret_cast<uint32_t *>(this->gpuAddress)[0] = 0x05000000;
|
||||
reinterpret_cast<uint32_t *>(this->gpuAddress)[1] = 0x00000000;
|
||||
StackVec<drm_i915_gem_exec_object2, maxFragmentsCount + 1> execObject(numberOfBos + 1);
|
||||
return this->exec(4u, 0u, 0u, false, drmContextId, boToPin, numberOfBos, &execObject[0]);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user