mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Refactor: Common helper for Blit and CPU memory transfers
Change-Id: Icc61f82517e75e3066e441494af3bf9a7ffbbeef Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
33ce6910c5
commit
27f9a95af2
@@ -18,13 +18,12 @@ namespace NEO {
|
||||
|
||||
template <typename PatchSizeT>
|
||||
void Linker::patchIncrement(Device *pDevice, GraphicsAllocation *dstAllocation, size_t relocationOffset, const void *initData, uint64_t incrementValue) {
|
||||
bool useBlitter = false;
|
||||
|
||||
auto &hwInfo = pDevice->getHardwareInfo();
|
||||
auto &helper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
if (dstAllocation->isAllocatedInLocalMemoryPool() && (helper.isBlitCopyRequiredForLocalMemory(hwInfo) || helper.forceBlitterUseForGlobalBuffers(hwInfo, dstAllocation))) {
|
||||
useBlitter = true;
|
||||
}
|
||||
|
||||
bool useBlitter = (helper.isBlitCopyRequiredForLocalMemory(hwInfo, *dstAllocation) ||
|
||||
helper.forceBlitterUseForGlobalBuffers(hwInfo, dstAllocation));
|
||||
|
||||
auto initValue = ptrOffset(initData, relocationOffset);
|
||||
|
||||
@@ -32,11 +31,7 @@ void Linker::patchIncrement(Device *pDevice, GraphicsAllocation *dstAllocation,
|
||||
memcpy_s(&value, sizeof(PatchSizeT), initValue, sizeof(PatchSizeT));
|
||||
value += static_cast<PatchSizeT>(incrementValue);
|
||||
|
||||
if (useBlitter) {
|
||||
BlitHelperFunctions::blitMemoryToAllocation(*pDevice, dstAllocation, relocationOffset, &value, {sizeof(PatchSizeT), 1, 1});
|
||||
} else {
|
||||
pDevice->getMemoryManager()->copyMemoryToAllocation(dstAllocation, relocationOffset, &value, sizeof(PatchSizeT));
|
||||
}
|
||||
MemoryTransferHelper::transferMemoryToAllocation(useBlitter, *pDevice, dstAllocation, relocationOffset, &value, sizeof(PatchSizeT));
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -70,7 +70,7 @@ class HwHelper {
|
||||
virtual bool obtainBlitterPreference(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) = 0;
|
||||
virtual bool allowRenderCompression(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const = 0;
|
||||
virtual bool forceBlitterUseForGlobalBuffers(const HardwareInfo &hwInfo, GraphicsAllocation *allocation) const = 0;
|
||||
virtual LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0;
|
||||
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
|
||||
@@ -296,7 +296,7 @@ class HwHelperHw : public HwHelper {
|
||||
|
||||
bool allowRenderCompression(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo) const override;
|
||||
bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const override;
|
||||
|
||||
bool forceBlitterUseForGlobalBuffers(const HardwareInfo &hwInfo, GraphicsAllocation *allocation) const override;
|
||||
|
||||
|
||||
@@ -420,9 +420,9 @@ inline bool HwHelperHw<GfxFamily>::allowRenderCompression(const HardwareInfo &hw
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
inline bool HwHelperHw<GfxFamily>::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo) const {
|
||||
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
return (hwHelper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed) &&
|
||||
inline bool HwHelperHw<GfxFamily>::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const {
|
||||
return allocation.isAllocatedInLocalMemoryPool() &&
|
||||
(getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed) &&
|
||||
hwInfo.capabilityTable.blitterOperationsSupported;
|
||||
}
|
||||
|
||||
|
||||
@@ -722,5 +722,13 @@ void MemoryManager::overrideAllocationData(AllocationData &allocationData, const
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
}
|
||||
|
||||
bool MemoryTransferHelper::transferMemoryToAllocation(bool useBlitter, const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory, size_t srcSize) {
|
||||
if (useBlitter) {
|
||||
return (BlitHelperFunctions::blitMemoryToAllocation(device, dstAllocation, dstOffset, srcMemory, {srcSize, 1, 1}) == BlitOperationResult::Success);
|
||||
} else {
|
||||
return device.getMemoryManager()->copyMemoryToAllocation(dstAllocation, dstOffset, srcMemory, srcSize);
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -51,6 +51,10 @@ struct AddressRange {
|
||||
|
||||
constexpr size_t paddingBufferSize = 2 * MemoryConstants::megaByte;
|
||||
|
||||
namespace MemoryTransferHelper {
|
||||
bool transferMemoryToAllocation(bool useBlitter, const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory, size_t srcSize);
|
||||
}
|
||||
|
||||
class MemoryManager {
|
||||
public:
|
||||
enum AllocationStatus {
|
||||
|
||||
@@ -56,12 +56,8 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
auto &hwInfo = device.getHardwareInfo();
|
||||
auto &helper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
bool success = false;
|
||||
if (gpuAllocation->isAllocatedInLocalMemoryPool() && helper.isBlitCopyRequiredForLocalMemory(hwInfo)) {
|
||||
success = (BlitHelperFunctions::blitMemoryToAllocation(device, gpuAllocation, 0, initData, {size, 1, 1}) == BlitOperationResult::Success);
|
||||
} else {
|
||||
success = device.getMemoryManager()->copyMemoryToAllocation(gpuAllocation, 0, initData, static_cast<uint32_t>(size));
|
||||
}
|
||||
auto success = MemoryTransferHelper::transferMemoryToAllocation(helper.isBlitCopyRequiredForLocalMemory(hwInfo, *gpuAllocation),
|
||||
device, gpuAllocation, 0, initData, size);
|
||||
|
||||
UNRECOVERABLE_IF(!success);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user