2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-03-27 22:21:18 +08:00
|
|
|
#include "shared/source/helpers/common_types.h"
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cstddef>
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <cstdint>
|
2018-09-29 05:36:11 +08:00
|
|
|
#include <limits>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-27 21:08:57 +08:00
|
|
|
constexpr bool is32bit = (sizeof(void *) == 4);
|
|
|
|
constexpr bool is64bit = (sizeof(void *) == 8);
|
|
|
|
|
2020-07-08 18:09:05 +08:00
|
|
|
constexpr NEO::DeviceBitfield systemMemoryBitfield(0b0);
|
|
|
|
|
2019-11-28 01:00:52 +08:00
|
|
|
constexpr uint64_t maxNBitValue(uint64_t n) {
|
|
|
|
return ((1ULL << n) - 1);
|
|
|
|
}
|
|
|
|
static_assert(maxNBitValue(8) == std::numeric_limits<uint8_t>::max(), "");
|
|
|
|
static_assert(maxNBitValue(16) == std::numeric_limits<uint16_t>::max(), "");
|
|
|
|
static_assert(maxNBitValue(32) == std::numeric_limits<uint32_t>::max(), "");
|
2019-01-29 01:12:39 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
namespace MemoryConstants {
|
2020-01-24 19:50:59 +08:00
|
|
|
constexpr uint64_t zoneHigh = ~(uint64_t)0xFFFFFFFF;
|
|
|
|
constexpr uint64_t kiloByte = 1024;
|
|
|
|
constexpr uint64_t kiloByteShiftSize = 10;
|
|
|
|
constexpr uint64_t megaByte = 1024 * kiloByte;
|
|
|
|
constexpr uint64_t gigaByte = 1024 * megaByte;
|
|
|
|
constexpr size_t minBufferAlignment = 4;
|
|
|
|
constexpr size_t cacheLineSize = 64;
|
|
|
|
constexpr size_t pageSize = 4 * kiloByte;
|
|
|
|
constexpr size_t pageSize64k = 64 * kiloByte;
|
2021-05-12 21:58:14 +08:00
|
|
|
constexpr size_t pageSize2Mb = 2 * megaByte;
|
2020-01-24 19:50:59 +08:00
|
|
|
constexpr size_t preferredAlignment = pageSize; // alignment preferred for performance reasons, i.e. internal allocations
|
|
|
|
constexpr size_t allocationAlignment = pageSize; // alignment required to gratify incoming pointer, i.e. passed host_ptr
|
|
|
|
constexpr size_t slmWindowAlignment = 128 * kiloByte;
|
|
|
|
constexpr size_t slmWindowSize = 64 * kiloByte;
|
|
|
|
constexpr uintptr_t pageMask = (pageSize - 1);
|
|
|
|
constexpr uintptr_t page64kMask = (pageSize64k - 1);
|
|
|
|
constexpr uint64_t max32BitAppAddress = maxNBitValue(31);
|
|
|
|
constexpr uint64_t max64BitAppAddress = maxNBitValue(47);
|
|
|
|
constexpr uint32_t sizeOf4GBinPageEntities = (MemoryConstants::gigaByte * 4 - MemoryConstants::pageSize) / MemoryConstants::pageSize;
|
|
|
|
constexpr uint64_t max32BitAddress = maxNBitValue(32);
|
|
|
|
constexpr uint64_t max36BitAddress = (maxNBitValue(36));
|
|
|
|
constexpr uint64_t max48BitAddress = maxNBitValue(48);
|
|
|
|
constexpr uintptr_t page4kEntryMask = std::numeric_limits<uintptr_t>::max() & ~MemoryConstants::pageMask;
|
|
|
|
constexpr uintptr_t page64kEntryMask = std::numeric_limits<uintptr_t>::max() & ~MemoryConstants::page64kMask;
|
|
|
|
constexpr int GfxAddressBits = is64bit ? 48 : 32;
|
|
|
|
constexpr uint64_t maxSvmAddress = is64bit ? maxNBitValue(47) : maxNBitValue(32);
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2018-06-13 03:54:39 +08:00
|
|
|
} // namespace MemoryConstants
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2020-04-28 21:23:04 +08:00
|
|
|
constexpr uint64_t KB = MemoryConstants::kiloByte;
|
|
|
|
constexpr uint64_t MB = MemoryConstants::megaByte;
|
|
|
|
constexpr uint64_t GB = MemoryConstants::gigaByte;
|
|
|
|
|
2019-04-03 21:59:31 +08:00
|
|
|
namespace BlitterConstants {
|
2020-11-03 16:57:50 +08:00
|
|
|
constexpr uint64_t maxBlitWidth = 0x4000;
|
|
|
|
constexpr uint64_t maxBlitHeight = 0x4000;
|
2020-10-21 21:17:46 +08:00
|
|
|
constexpr uint64_t maxBlitSetWidth = 0x1FF80; // 0x20000 aligned to 128
|
2020-04-28 16:24:22 +08:00
|
|
|
constexpr uint64_t maxBlitSetHeight = 0x1FFC0; // 0x20000 aligned to cacheline size
|
2020-07-02 22:07:22 +08:00
|
|
|
|
|
|
|
constexpr uint64_t maxBytesPerPixel = 0x10;
|
2020-01-24 19:50:59 +08:00
|
|
|
enum class BlitDirection : uint32_t {
|
2019-07-01 17:08:58 +08:00
|
|
|
BufferToHostPtr,
|
|
|
|
HostPtrToBuffer,
|
2020-10-20 21:27:49 +08:00
|
|
|
BufferToBuffer,
|
|
|
|
HostPtrToImage,
|
|
|
|
ImageToHostPtr
|
2019-05-16 23:48:29 +08:00
|
|
|
};
|
2020-11-17 01:12:08 +08:00
|
|
|
|
|
|
|
enum PostBlitMode : int32_t {
|
|
|
|
Default = -1,
|
|
|
|
MiArbCheck = 0,
|
|
|
|
MiFlush = 1,
|
|
|
|
None = 2
|
|
|
|
};
|
2019-04-03 21:59:31 +08:00
|
|
|
} // namespace BlitterConstants
|
2020-03-27 22:21:18 +08:00
|
|
|
|
|
|
|
namespace CommonConstants {
|
|
|
|
constexpr uint32_t unspecifiedDeviceIndex = std::numeric_limits<uint32_t>::max();
|
2020-07-17 23:04:52 +08:00
|
|
|
constexpr uint32_t invalidStepping = std::numeric_limits<uint32_t>::max();
|
2020-05-26 20:11:22 +08:00
|
|
|
constexpr uint32_t maximalSimdSize = 32;
|
2020-03-27 22:21:18 +08:00
|
|
|
} // namespace CommonConstants
|