2022-02-04 21:50:19 +08:00
|
|
|
/*
|
2025-03-20 18:00:35 +08:00
|
|
|
* Copyright (C) 2022-2025 Intel Corporation
|
2022-02-04 21:50:19 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "shared/source/gmm_helper/gmm_lib.h"
|
|
|
|
|
2022-06-27 22:58:29 +08:00
|
|
|
namespace CacheSettings {
|
2024-05-27 17:27:22 +08:00
|
|
|
inline constexpr uint32_t unknownMocs = -1;
|
2022-06-27 22:58:29 +08:00
|
|
|
} // namespace CacheSettings
|
|
|
|
|
2022-02-04 21:50:19 +08:00
|
|
|
namespace NEO {
|
|
|
|
enum class AllocationType;
|
2022-02-10 02:03:05 +08:00
|
|
|
struct HardwareInfo;
|
2023-01-24 02:44:33 +08:00
|
|
|
class ProductHelper;
|
2023-09-13 16:37:04 +08:00
|
|
|
struct RootDeviceEnvironment;
|
2022-02-04 21:50:19 +08:00
|
|
|
|
2022-02-09 01:15:22 +08:00
|
|
|
struct CacheSettingsHelper {
|
2025-04-09 20:25:15 +08:00
|
|
|
static GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper, const HardwareInfo *hwInfo);
|
2025-03-28 20:24:28 +08:00
|
|
|
static GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageTypeForUserPtr(bool isCacheFlushRequired, const void *userPtr, size_t size, const ProductHelper &productHelper);
|
2022-02-09 01:15:22 +08:00
|
|
|
|
2022-04-13 21:47:52 +08:00
|
|
|
static constexpr bool isUncachedType(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType) {
|
|
|
|
return ((gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC) ||
|
|
|
|
(gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED) ||
|
2024-01-05 23:51:04 +08:00
|
|
|
(gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) ||
|
|
|
|
(gmmResourceUsageType == GMM_RESOURCE_USAGE_SURFACE_UNCACHED));
|
2022-04-13 21:47:52 +08:00
|
|
|
}
|
|
|
|
|
2023-09-13 16:37:04 +08:00
|
|
|
static bool preferNoCpuAccess(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const RootDeviceEnvironment &rootDeviceEnvironment);
|
2023-05-15 21:22:05 +08:00
|
|
|
|
2022-02-09 01:15:22 +08:00
|
|
|
protected:
|
2025-04-09 20:25:15 +08:00
|
|
|
static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper, const HardwareInfo *hwInfo);
|
2024-01-31 22:17:57 +08:00
|
|
|
static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingDisabled(AllocationType allocationType, const ProductHelper &productHelper);
|
2022-02-09 01:15:22 +08:00
|
|
|
};
|
2025-04-09 20:25:15 +08:00
|
|
|
} // namespace NEO
|