2019-04-04 20:55:51 +08:00
|
|
|
/*
|
2022-01-31 18:12:51 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2019-04-04 20:55:51 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/device/sub_device.h"
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2019-04-04 20:55:51 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
struct ImageInfo;
|
|
|
|
struct AllocationProperties {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint32_t allocateMemory : 1;
|
|
|
|
uint32_t flushL3RequiredForRead : 1;
|
|
|
|
uint32_t flushL3RequiredForWrite : 1;
|
|
|
|
uint32_t forcePin : 1;
|
|
|
|
uint32_t uncacheable : 1;
|
|
|
|
uint32_t multiOsContextCapable : 1;
|
2019-08-07 00:01:26 +08:00
|
|
|
uint32_t readOnlyMultiStorage : 1;
|
2019-11-14 17:08:59 +08:00
|
|
|
uint32_t shareable : 1;
|
2020-02-11 00:58:02 +08:00
|
|
|
uint32_t resource48Bit : 1;
|
2020-09-03 15:57:05 +08:00
|
|
|
uint32_t isUSMHostAllocation : 1;
|
2020-09-11 21:44:09 +08:00
|
|
|
uint32_t isUSMDeviceAllocation : 1;
|
2020-10-21 16:48:09 +08:00
|
|
|
uint32_t use32BitFrontWindow : 1;
|
2021-03-23 20:10:21 +08:00
|
|
|
uint32_t crossRootDeviceAccess : 1;
|
2021-05-13 18:28:30 +08:00
|
|
|
uint32_t forceSystemMemory : 1;
|
2021-12-02 20:21:33 +08:00
|
|
|
uint32_t preferCompressed : 1;
|
|
|
|
uint32_t reserved : 17;
|
2019-04-04 20:55:51 +08:00
|
|
|
} flags;
|
|
|
|
uint32_t allFlags = 0;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(AllocationProperties::flags) == sizeof(AllocationProperties::allFlags), "");
|
2020-07-09 09:31:52 +08:00
|
|
|
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
2019-04-04 20:55:51 +08:00
|
|
|
size_t size = 0;
|
|
|
|
size_t alignment = 0;
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType allocationType = AllocationType::UNKNOWN;
|
2022-01-31 18:12:51 +08:00
|
|
|
GraphicsAllocation::UsmInitialPlacement usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::DEFAULT;
|
2019-04-04 20:55:51 +08:00
|
|
|
ImageInfo *imgInfo = nullptr;
|
2019-11-07 01:46:42 +08:00
|
|
|
bool multiStorageResource = false;
|
2021-10-04 23:23:42 +08:00
|
|
|
ColouringPolicy colouringPolicy = ColouringPolicy::DeviceCountBased;
|
|
|
|
size_t colouringGranularity = MemoryConstants::pageSize64k;
|
2019-12-10 19:16:07 +08:00
|
|
|
DeviceBitfield subDevicesBitfield{};
|
2020-07-01 16:38:19 +08:00
|
|
|
uint64_t gpuAddress = 0;
|
|
|
|
OsContext *osContext = nullptr;
|
2020-10-15 14:53:36 +08:00
|
|
|
bool useMmapObject = true;
|
2021-02-09 08:31:32 +08:00
|
|
|
uint32_t cacheRegion = 0;
|
2019-04-04 20:55:51 +08:00
|
|
|
|
2020-06-16 21:46:15 +08:00
|
|
|
AllocationProperties(uint32_t rootDeviceIndex, size_t size,
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType allocationType, DeviceBitfield subDevicesBitfieldParam)
|
2020-06-16 21:46:15 +08:00
|
|
|
: AllocationProperties(rootDeviceIndex, true, size, allocationType, false, subDevicesBitfieldParam) {}
|
2019-04-04 20:55:51 +08:00
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
AllocationProperties(uint32_t rootDeviceIndex, bool allocateMemory,
|
2019-04-04 20:55:51 +08:00
|
|
|
ImageInfo &imgInfo,
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType allocationType,
|
2020-04-14 23:07:38 +08:00
|
|
|
DeviceBitfield subDevicesBitfieldParam)
|
|
|
|
: AllocationProperties(rootDeviceIndex, allocateMemory, 0u, allocationType, false, subDevicesBitfieldParam) {
|
2019-04-04 20:55:51 +08:00
|
|
|
this->imgInfo = &imgInfo;
|
|
|
|
}
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
AllocationProperties(uint32_t rootDeviceIndex,
|
|
|
|
bool allocateMemory,
|
2019-04-04 20:55:51 +08:00
|
|
|
size_t size,
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType allocationType,
|
2020-04-14 23:07:38 +08:00
|
|
|
bool isMultiStorageAllocation,
|
|
|
|
DeviceBitfield subDevicesBitfieldParam)
|
|
|
|
: AllocationProperties(rootDeviceIndex, allocateMemory, size, allocationType, false, isMultiStorageAllocation, subDevicesBitfieldParam) {}
|
2019-04-04 20:55:51 +08:00
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
AllocationProperties(uint32_t rootDeviceIndexParam,
|
|
|
|
bool allocateMemoryParam,
|
|
|
|
size_t sizeParam,
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType allocationTypeParam,
|
2021-02-19 23:11:13 +08:00
|
|
|
bool multiOsContextCapable,
|
2019-11-07 21:15:04 +08:00
|
|
|
bool isMultiStorageAllocationParam,
|
2019-12-10 19:16:07 +08:00
|
|
|
DeviceBitfield subDevicesBitfieldParam)
|
|
|
|
: rootDeviceIndex(rootDeviceIndexParam),
|
|
|
|
size(sizeParam),
|
|
|
|
allocationType(allocationTypeParam),
|
|
|
|
multiStorageResource(isMultiStorageAllocationParam),
|
|
|
|
subDevicesBitfield(subDevicesBitfieldParam) {
|
2019-04-04 20:55:51 +08:00
|
|
|
allFlags = 0;
|
|
|
|
flags.flushL3RequiredForRead = 1;
|
|
|
|
flags.flushL3RequiredForWrite = 1;
|
2019-11-07 21:15:04 +08:00
|
|
|
flags.allocateMemory = allocateMemoryParam;
|
2021-02-19 23:11:13 +08:00
|
|
|
flags.multiOsContextCapable = multiOsContextCapable;
|
2019-04-04 20:55:51 +08:00
|
|
|
}
|
|
|
|
};
|
2020-06-02 19:38:02 +08:00
|
|
|
|
|
|
|
struct AllocationData {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint32_t allocateMemory : 1;
|
|
|
|
uint32_t allow64kbPages : 1;
|
|
|
|
uint32_t allow32Bit : 1;
|
|
|
|
uint32_t useSystemMemory : 1;
|
|
|
|
uint32_t forcePin : 1;
|
|
|
|
uint32_t uncacheable : 1;
|
|
|
|
uint32_t flushL3 : 1;
|
2021-12-03 21:52:16 +08:00
|
|
|
uint32_t preferCompressed : 1;
|
2020-06-02 19:38:02 +08:00
|
|
|
uint32_t multiOsContextCapable : 1;
|
|
|
|
uint32_t requiresCpuAccess : 1;
|
|
|
|
uint32_t shareable : 1;
|
|
|
|
uint32_t resource48Bit : 1;
|
2020-09-03 15:57:05 +08:00
|
|
|
uint32_t isUSMHostAllocation : 1;
|
2020-10-21 16:48:09 +08:00
|
|
|
uint32_t use32BitFrontWindow : 1;
|
2021-03-24 21:19:30 +08:00
|
|
|
uint32_t crossRootDeviceAccess : 1;
|
2021-08-11 18:36:04 +08:00
|
|
|
uint32_t isUSMDeviceMemory : 1;
|
2021-09-22 02:17:41 +08:00
|
|
|
uint32_t zeroMemory : 1;
|
|
|
|
uint32_t reserved : 15;
|
2020-06-02 19:38:02 +08:00
|
|
|
} flags;
|
|
|
|
uint32_t allFlags = 0;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(AllocationData::flags) == sizeof(AllocationData::allFlags), "");
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType type = AllocationType::UNKNOWN;
|
2022-01-31 18:12:51 +08:00
|
|
|
GraphicsAllocation::UsmInitialPlacement usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::DEFAULT;
|
2020-06-02 19:38:02 +08:00
|
|
|
const void *hostPtr = nullptr;
|
2020-07-01 16:38:19 +08:00
|
|
|
uint64_t gpuAddress = 0;
|
2020-06-02 19:38:02 +08:00
|
|
|
size_t size = 0;
|
|
|
|
size_t alignment = 0;
|
|
|
|
StorageInfo storageInfo = {};
|
|
|
|
ImageInfo *imgInfo = nullptr;
|
|
|
|
uint32_t rootDeviceIndex = 0;
|
2020-07-01 16:38:19 +08:00
|
|
|
OsContext *osContext = nullptr;
|
2020-10-15 14:53:36 +08:00
|
|
|
bool useMmapObject = true;
|
2021-02-09 08:31:32 +08:00
|
|
|
uint32_t cacheRegion = 0;
|
2020-06-02 19:38:02 +08:00
|
|
|
};
|
2019-04-04 20:55:51 +08:00
|
|
|
} // namespace NEO
|