From b4ed5468a28487f66ce3331093964b05411bde09 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 1 Apr 2019 11:43:38 +0200 Subject: [PATCH] Add device index to AllocationProperties Change-Id: I3c9f7ea59bf85fbbc948ba23c2b1040f295f586c Signed-off-by: Mateusz Jablonski --- runtime/command_stream/command_stream_receiver.cpp | 4 ++-- runtime/memory_manager/memory_manager.h | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index b66bf4c267..b455df68f9 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -126,7 +126,7 @@ void CommandStreamReceiver::ensureCommandBufferAllocation(LinearStream &commandS constexpr static auto allocationType = GraphicsAllocation::AllocationType::COMMAND_BUFFER; auto allocation = this->getInternalAllocationStorage()->obtainReusableAllocation(allocationSize, allocationType).release(); if (allocation == nullptr) { - const AllocationProperties commandStreamAllocationProperties{true, allocationSize, allocationType, this->isMultiOsContextCapable()}; + const AllocationProperties commandStreamAllocationProperties{true, allocationSize, allocationType, this->isMultiOsContextCapable(), this->deviceIndex}; allocation = this->getMemoryManager()->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties); } DEBUG_BREAK_IF(allocation == nullptr); @@ -297,7 +297,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType, auto heapMemory = internalAllocationStorage->obtainReusableAllocation(finalHeapSize, allocationType).release(); if (!heapMemory) { - heapMemory = getMemoryManager()->allocateGraphicsMemoryWithProperties({finalHeapSize, allocationType}); + heapMemory = getMemoryManager()->allocateGraphicsMemoryWithProperties({finalHeapSize, allocationType, this->deviceIndex}); } else { finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize); } diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index c2682a29c0..19f98d915c 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -47,6 +47,7 @@ enum AllocationUsage { }; struct AllocationProperties { + constexpr static uint32_t noDeviceSpecified = std::numeric_limits::max(); union { struct { uint32_t allocateMemory : 1; @@ -64,13 +65,18 @@ struct AllocationProperties { size_t alignment = 0; GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::UNKNOWN; ImageInfo *imgInfo = nullptr; + uint32_t deviceIndex = AllocationProperties::noDeviceSpecified; AllocationProperties(size_t size, GraphicsAllocation::AllocationType allocationType) : AllocationProperties(true, size, allocationType) {} + + AllocationProperties(size_t size, GraphicsAllocation::AllocationType allocationType, uint32_t deviceIndex) + : AllocationProperties(true, size, allocationType, false, deviceIndex) {} AllocationProperties(bool allocateMemory, size_t size, GraphicsAllocation::AllocationType allocationType) - : AllocationProperties(allocateMemory, size, allocationType, false) {} - AllocationProperties(bool allocateMemory, size_t size, GraphicsAllocation::AllocationType allocationType, bool multiOsContextCapable) - : size(size), allocationType(allocationType) { + : AllocationProperties(allocateMemory, size, allocationType, false, AllocationProperties::noDeviceSpecified) {} + AllocationProperties(bool allocateMemory, size_t size, GraphicsAllocation::AllocationType allocationType, + bool multiOsContextCapable, uint32_t deviceIndex) + : size(size), allocationType(allocationType), deviceIndex(deviceIndex) { allFlags = 0; flags.flushL3RequiredForRead = 1; flags.flushL3RequiredForWrite = 1;