2018-06-21 11:36:47 +02:00
|
|
|
/*
|
2024-01-23 11:23:06 +00:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2018-09-18 13:55:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2018-06-21 11:36:47 +02:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/gmm_helper/gmm.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2022-12-19 18:41:13 +00:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2022-02-04 13:50:19 +00:00
|
|
|
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
|
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
|
|
|
|
#include "shared/source/gmm_helper/resource_info.h"
|
|
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
|
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
|
|
|
|
#include "shared/source/helpers/ptr_math.h"
|
|
|
|
|
#include "shared/source/helpers/surface_format_info.h"
|
2022-02-04 13:50:19 +00:00
|
|
|
#include "shared/source/memory_manager/allocation_type.h"
|
2022-07-26 04:58:51 +00:00
|
|
|
#include "shared/source/memory_manager/definitions/storage_info.h"
|
2018-06-21 11:36:47 +02:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2022-04-27 10:20:10 +00:00
|
|
|
Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage,
|
2023-11-14 17:28:21 +00:00
|
|
|
const StorageInfo &storageInfo, const GmmRequirements &gmmRequirements) : gmmHelper(gmmHelper) {
|
2018-06-29 11:48:19 +02:00
|
|
|
resourceParams.Type = RESOURCE_BUFFER;
|
|
|
|
|
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
2019-01-18 09:44:52 +01:00
|
|
|
resourceParams.BaseWidth64 = static_cast<uint64_t>(alignedSize);
|
2018-06-29 11:48:19 +02:00
|
|
|
resourceParams.BaseHeight = 1;
|
|
|
|
|
resourceParams.Depth = 1;
|
2021-04-12 14:34:35 +00:00
|
|
|
resourceParams.BaseAlignment = static_cast<uint32_t>(alignment);
|
2023-11-14 17:28:21 +00:00
|
|
|
if ((nullptr == alignedPtr) && (false == gmmRequirements.allowLargePages)) {
|
2021-07-14 16:51:47 +02:00
|
|
|
resourceParams.Flags.Info.NoOptimizationPadding = true;
|
|
|
|
|
if ((resourceParams.BaseWidth64 & MemoryConstants::page64kMask) == 0) {
|
|
|
|
|
resourceParams.BaseWidth64 += MemoryConstants::pageSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-05 15:24:16 +01:00
|
|
|
|
2022-02-04 13:50:19 +00:00
|
|
|
resourceParams.Usage = gmmResourceUsage;
|
2018-06-29 11:48:19 +02:00
|
|
|
resourceParams.Flags.Info.Linear = 1;
|
2023-11-15 15:04:20 +00:00
|
|
|
|
2023-09-13 08:37:04 +00:00
|
|
|
this->preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(gmmResourceUsage, gmmHelper->getRootDeviceEnvironment());
|
2023-11-15 15:04:20 +00:00
|
|
|
bool cacheable = !this->preferNoCpuAccess && !CacheSettingsHelper::isUncachedType(gmmResourceUsage);
|
2024-06-04 15:36:59 +00:00
|
|
|
|
|
|
|
|
gmmRequirements.overriderPreferNoCpuAccess.doOverride(this->preferNoCpuAccess);
|
2023-11-15 15:04:20 +00:00
|
|
|
gmmRequirements.overriderCacheable.doOverride(cacheable);
|
|
|
|
|
resourceParams.Flags.Info.Cacheable = cacheable;
|
|
|
|
|
|
2018-06-29 11:48:19 +02:00
|
|
|
resourceParams.Flags.Gpu.Texture = 1;
|
|
|
|
|
|
|
|
|
|
if (alignedPtr) {
|
|
|
|
|
resourceParams.Flags.Info.ExistingSysMem = 1;
|
2019-12-19 09:25:08 +01:00
|
|
|
resourceParams.pExistingSysMem = castToUint64(alignedPtr);
|
2018-06-29 11:48:19 +02:00
|
|
|
resourceParams.ExistingSysMemSize = alignedSize;
|
2019-01-10 14:12:10 +01:00
|
|
|
} else {
|
|
|
|
|
resourceParams.NoGfxMemory = 1u;
|
2018-06-29 11:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-18 09:44:52 +01:00
|
|
|
if (resourceParams.BaseWidth64 >= GmmHelper::maxPossiblePitch) {
|
2018-06-21 11:36:47 +02:00
|
|
|
resourceParams.Flags.Gpu.NoRestriction = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-14 17:28:21 +00:00
|
|
|
applyAuxFlagsForBuffer(gmmRequirements.preferCompressed && !storageInfo.isLockable);
|
2022-02-07 14:27:53 +00:00
|
|
|
applyMemoryFlags(storageInfo);
|
2021-05-20 13:49:04 +00:00
|
|
|
applyAppResource(storageInfo);
|
2021-08-06 10:46:00 +00:00
|
|
|
applyDebugOverrides();
|
2018-06-29 11:48:19 +02:00
|
|
|
|
2022-04-27 10:20:10 +00:00
|
|
|
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &resourceParams));
|
2018-06-21 11:36:47 +02:00
|
|
|
}
|
|
|
|
|
|
2022-04-19 14:11:45 +02:00
|
|
|
Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm) : Gmm(gmmHelper, inputGmm, false) {}
|
|
|
|
|
|
|
|
|
|
Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm, bool openingHandle) : gmmHelper(gmmHelper) {
|
|
|
|
|
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), inputGmm, openingHandle));
|
2021-08-06 10:46:00 +00:00
|
|
|
applyDebugOverrides();
|
2018-06-29 11:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-13 11:35:19 +01:00
|
|
|
Gmm::~Gmm() = default;
|
|
|
|
|
|
2022-07-26 04:58:51 +00:00
|
|
|
Gmm::Gmm(GmmHelper *gmmHelper, ImageInfo &inputOutputImgInfo, const StorageInfo &storageInfo, bool preferCompressed) : gmmHelper(gmmHelper) {
|
2019-04-01 07:22:13 +02:00
|
|
|
this->resourceParams = {};
|
2023-05-11 12:14:46 +00:00
|
|
|
preferCompressed &= !storageInfo.isLockable;
|
2021-12-03 13:52:16 +00:00
|
|
|
setupImageResourceParams(inputOutputImgInfo, preferCompressed);
|
2022-02-07 14:27:53 +00:00
|
|
|
applyMemoryFlags(storageInfo);
|
2021-05-20 13:49:04 +00:00
|
|
|
applyAppResource(storageInfo);
|
2021-08-06 10:46:00 +00:00
|
|
|
applyDebugOverrides();
|
2021-05-20 13:49:04 +00:00
|
|
|
|
2022-04-27 10:20:10 +00:00
|
|
|
this->gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &this->resourceParams));
|
2019-04-01 07:22:13 +02:00
|
|
|
UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);
|
|
|
|
|
|
2018-06-29 11:48:19 +02:00
|
|
|
queryImageParams(inputOutputImgInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 13:52:16 +00:00
|
|
|
void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) {
|
2020-01-09 11:15:03 +01:00
|
|
|
uint64_t imageWidth = static_cast<uint64_t>(imgInfo.imgDesc.imageWidth);
|
2018-06-21 11:36:47 +02:00
|
|
|
uint32_t imageHeight = 1;
|
|
|
|
|
uint32_t imageDepth = 1;
|
|
|
|
|
uint32_t imageCount = 1;
|
|
|
|
|
|
2020-01-09 11:15:03 +01:00
|
|
|
switch (imgInfo.imgDesc.imageType) {
|
2023-12-13 16:09:52 +00:00
|
|
|
case ImageType::image1D:
|
|
|
|
|
case ImageType::image1DArray:
|
|
|
|
|
case ImageType::image1DBuffer:
|
2019-04-01 07:22:13 +02:00
|
|
|
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D;
|
2018-06-21 11:36:47 +02:00
|
|
|
break;
|
2023-12-13 16:09:52 +00:00
|
|
|
case ImageType::image2D:
|
|
|
|
|
case ImageType::image2DArray:
|
2019-04-01 07:22:13 +02:00
|
|
|
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_2D;
|
2020-01-09 11:15:03 +01:00
|
|
|
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc.imageHeight);
|
2018-06-21 11:36:47 +02:00
|
|
|
break;
|
2023-12-13 16:09:52 +00:00
|
|
|
case ImageType::image3D:
|
2019-04-01 07:22:13 +02:00
|
|
|
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_3D;
|
2020-01-09 11:15:03 +01:00
|
|
|
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc.imageHeight);
|
|
|
|
|
imageDepth = static_cast<uint32_t>(imgInfo.imgDesc.imageDepth);
|
2018-06-21 11:36:47 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-13 16:09:52 +00:00
|
|
|
if (imgInfo.imgDesc.imageType == ImageType::image1DArray ||
|
|
|
|
|
imgInfo.imgDesc.imageType == ImageType::image2DArray) {
|
2020-01-09 11:15:03 +01:00
|
|
|
imageCount = static_cast<uint32_t>(imgInfo.imgDesc.imageArraySize);
|
2018-06-21 11:36:47 +02:00
|
|
|
}
|
|
|
|
|
|
2019-08-26 09:27:30 +02:00
|
|
|
resourceParams.Flags.Info.Linear = imgInfo.linearStorage;
|
2018-06-21 11:36:47 +02:00
|
|
|
|
2022-12-19 18:41:13 +00:00
|
|
|
auto &gfxCoreHelper = gmmHelper->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
2023-01-23 18:44:33 +00:00
|
|
|
auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper<ProductHelper>();
|
2019-04-01 07:22:13 +02:00
|
|
|
resourceParams.NoGfxMemory = 1; // dont allocate, only query for params
|
|
|
|
|
|
2023-12-11 14:24:36 +00:00
|
|
|
resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::image, false, productHelper);
|
2021-08-06 10:46:00 +00:00
|
|
|
|
2023-04-27 09:50:55 +00:00
|
|
|
resourceParams.Format = imgInfo.surfaceFormat->gmmSurfaceFormat;
|
2019-04-01 07:22:13 +02:00
|
|
|
resourceParams.Flags.Gpu.Texture = 1;
|
|
|
|
|
resourceParams.BaseWidth64 = imageWidth;
|
|
|
|
|
resourceParams.BaseHeight = imageHeight;
|
|
|
|
|
resourceParams.Depth = imageDepth;
|
|
|
|
|
resourceParams.ArraySize = imageCount;
|
2022-12-08 12:22:35 +00:00
|
|
|
resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = gfxCoreHelper.hvAlign4Required();
|
2019-04-01 07:22:13 +02:00
|
|
|
resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount;
|
2018-06-21 11:36:47 +02:00
|
|
|
|
2021-12-03 13:52:16 +00:00
|
|
|
applyAuxFlagsForImage(imgInfo, preferCompressed);
|
2019-04-01 07:22:13 +02:00
|
|
|
}
|
2018-06-21 11:36:47 +02:00
|
|
|
|
2021-12-03 13:52:16 +00:00
|
|
|
void Gmm::applyAuxFlagsForBuffer(bool preferCompression) {
|
2022-12-19 18:41:13 +00:00
|
|
|
auto &rootDeviceEnvironment = gmmHelper->getRootDeviceEnvironment();
|
|
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
|
|
|
|
auto hardwareInfo = rootDeviceEnvironment.getHardwareInfo();
|
2022-12-08 12:22:35 +00:00
|
|
|
bool allowCompression = GfxCoreHelper::compressedBuffersSupported(*hardwareInfo) &&
|
2021-12-03 13:52:16 +00:00
|
|
|
preferCompression;
|
2020-11-04 14:55:09 +00:00
|
|
|
|
2021-12-03 13:52:16 +00:00
|
|
|
if (allowCompression) {
|
2022-12-08 12:22:35 +00:00
|
|
|
gfxCoreHelper.applyRenderCompressionFlag(*this, 1);
|
2020-11-04 14:55:09 +00:00
|
|
|
resourceParams.Flags.Gpu.CCS = 1;
|
|
|
|
|
resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
2024-03-25 14:44:36 +00:00
|
|
|
compressionEnabled = true;
|
2020-11-04 14:55:09 +00:00
|
|
|
}
|
2023-10-13 19:09:28 +00:00
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.PrintGmmCompressionParams.get()) {
|
2023-10-13 19:09:28 +00:00
|
|
|
printf("\nGmm Resource compression params: \n\tFlags.Gpu.CCS: %u\n\tFlags.Gpu.UnifiedAuxSurface: %u\n\tFlags.Info.RenderCompressed: %u",
|
|
|
|
|
resourceParams.Flags.Gpu.CCS, resourceParams.Flags.Gpu.UnifiedAuxSurface, resourceParams.Flags.Info.RenderCompressed);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-25 14:44:36 +00:00
|
|
|
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !compressionEnabled);
|
2021-06-25 16:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 13:52:16 +00:00
|
|
|
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
|
2021-06-25 16:21:51 +00:00
|
|
|
uint8_t compressionFormat;
|
2022-12-19 18:41:13 +00:00
|
|
|
auto &rootDeviceEnvironment = gmmHelper->getRootDeviceEnvironment();
|
|
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
|
|
|
|
auto hardwareInfo = rootDeviceEnvironment.getHardwareInfo();
|
2021-06-25 16:21:51 +00:00
|
|
|
if (this->resourceParams.Flags.Info.MediaCompressed) {
|
2023-04-27 09:50:55 +00:00
|
|
|
compressionFormat = gmmHelper->getClientContext()->getMediaSurfaceStateCompressionFormat(imgInfo.surfaceFormat->gmmSurfaceFormat);
|
2021-06-25 16:21:51 +00:00
|
|
|
} else {
|
2023-04-27 09:50:55 +00:00
|
|
|
compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(imgInfo.surfaceFormat->gmmSurfaceFormat);
|
2021-06-25 16:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool compressionFormatSupported = false;
|
2022-12-19 18:41:13 +00:00
|
|
|
if (hardwareInfo->featureTable.flags.ftrFlatPhysCCS) {
|
2021-06-25 16:21:51 +00:00
|
|
|
compressionFormatSupported = compressionFormat != GMM_FLATCCS_FORMAT::GMM_FLATCCS_FORMAT_INVALID;
|
|
|
|
|
} else {
|
|
|
|
|
compressionFormatSupported = compressionFormat != GMM_E2ECOMP_FORMAT::GMM_E2ECOMP_FORMAT_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-27 09:50:55 +00:00
|
|
|
const bool isPackedYuv = imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_FORMAT_YUY2 ||
|
|
|
|
|
imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_FORMAT_UYVY ||
|
|
|
|
|
imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_FORMAT_YVYU ||
|
|
|
|
|
imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_FORMAT_VYUY;
|
2021-06-25 16:21:51 +00:00
|
|
|
|
2022-12-19 18:41:13 +00:00
|
|
|
bool allowCompression = GfxCoreHelper::compressedImagesSupported(*hardwareInfo) &&
|
2021-12-03 13:52:16 +00:00
|
|
|
preferCompressed &&
|
|
|
|
|
compressionFormatSupported &&
|
2023-04-27 09:50:55 +00:00
|
|
|
imgInfo.surfaceFormat->gmmSurfaceFormat != GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12 &&
|
2021-12-03 13:52:16 +00:00
|
|
|
imgInfo.plane == GMM_YUV_PLANE_ENUM::GMM_NO_PLANE &&
|
|
|
|
|
!isPackedYuv;
|
2021-06-25 16:21:51 +00:00
|
|
|
|
2022-12-19 18:41:13 +00:00
|
|
|
if (imgInfo.useLocalMemory || !hardwareInfo->featureTable.flags.ftrLocalMemory) {
|
2021-12-03 13:52:16 +00:00
|
|
|
if (allowCompression) {
|
2022-12-08 12:22:35 +00:00
|
|
|
gfxCoreHelper.applyRenderCompressionFlag(*this, 1);
|
2021-06-25 16:21:51 +00:00
|
|
|
this->resourceParams.Flags.Gpu.CCS = 1;
|
|
|
|
|
this->resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
|
|
|
|
this->resourceParams.Flags.Gpu.IndirectClearColor = 1;
|
2024-03-25 14:44:36 +00:00
|
|
|
this->compressionEnabled = true;
|
2021-06-25 16:21:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-10-13 19:09:28 +00:00
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.PrintGmmCompressionParams.get()) {
|
2023-10-13 19:09:28 +00:00
|
|
|
printf("\nGmm Resource compression params: \n\tFlags.Gpu.CCS: %u\n\tFlags.Gpu.UnifiedAuxSurface: %u\n\tFlags.Info.RenderCompressed: %u",
|
|
|
|
|
resourceParams.Flags.Gpu.CCS, resourceParams.Flags.Gpu.UnifiedAuxSurface, resourceParams.Flags.Info.RenderCompressed);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-25 14:44:36 +00:00
|
|
|
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !compressionEnabled);
|
2020-11-04 14:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-01 07:22:13 +02:00
|
|
|
void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
|
|
|
|
auto imageCount = this->gmmResourceInfo->getArraySize();
|
2018-06-21 11:36:47 +02:00
|
|
|
imgInfo.size = this->gmmResourceInfo->getSizeAllocation();
|
|
|
|
|
|
|
|
|
|
imgInfo.rowPitch = this->gmmResourceInfo->getRenderPitch();
|
|
|
|
|
if (imgInfo.rowPitch == 0) { // WA
|
|
|
|
|
imgInfo.rowPitch = alignUp(this->gmmResourceInfo->getBaseWidth(), this->gmmResourceInfo->getHAlign());
|
|
|
|
|
imgInfo.rowPitch = imgInfo.rowPitch * (this->gmmResourceInfo->getBitsPerPixel() >> 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// calculate slice pitch
|
|
|
|
|
if ((this->resourceParams.Type == GMM_RESOURCE_TYPE::RESOURCE_2D ||
|
|
|
|
|
this->resourceParams.Type == GMM_RESOURCE_TYPE::RESOURCE_1D) &&
|
|
|
|
|
imageCount == 1) {
|
|
|
|
|
// 2D or 1D or 1Darray with array_size=1
|
|
|
|
|
imgInfo.slicePitch = imgInfo.size;
|
|
|
|
|
} else {
|
|
|
|
|
// 3D Image or 2D-Array or 1D-Arrays (array_size>1)
|
|
|
|
|
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
|
|
|
|
reqOffsetInfo.ReqRender = 1;
|
|
|
|
|
reqOffsetInfo.Slice = 1;
|
|
|
|
|
reqOffsetInfo.ArrayIndex = (imageCount > 1) ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
this->gmmResourceInfo->getOffset(reqOffsetInfo);
|
|
|
|
|
imgInfo.slicePitch = reqOffsetInfo.Render.Offset;
|
|
|
|
|
imgInfo.slicePitch += imgInfo.rowPitch * reqOffsetInfo.Render.YOffset;
|
|
|
|
|
imgInfo.slicePitch += reqOffsetInfo.Render.XOffset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (imgInfo.plane != GMM_NO_PLANE) {
|
|
|
|
|
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
|
|
|
|
reqOffsetInfo.ReqRender = 1;
|
|
|
|
|
reqOffsetInfo.Slice = 0;
|
|
|
|
|
reqOffsetInfo.ArrayIndex = 0;
|
|
|
|
|
reqOffsetInfo.Plane = imgInfo.plane;
|
|
|
|
|
this->gmmResourceInfo->getOffset(reqOffsetInfo);
|
|
|
|
|
imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (this->gmmResourceInfo->getBitsPerPixel() / 8);
|
|
|
|
|
imgInfo.yOffset = reqOffsetInfo.Render.YOffset;
|
|
|
|
|
imgInfo.offset = reqOffsetInfo.Render.Offset;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-27 09:50:55 +00:00
|
|
|
if (imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12 || imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_RESOURCE_FORMAT::GMM_FORMAT_P010) {
|
2018-06-21 11:36:47 +02:00
|
|
|
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
|
|
|
|
reqOffsetInfo.ReqLock = 1;
|
|
|
|
|
reqOffsetInfo.Slice = 1;
|
|
|
|
|
reqOffsetInfo.ArrayIndex = 0;
|
|
|
|
|
reqOffsetInfo.Plane = GMM_PLANE_U;
|
|
|
|
|
this->gmmResourceInfo->getOffset(reqOffsetInfo);
|
2018-09-18 13:55:06 +02:00
|
|
|
UNRECOVERABLE_IF(reqOffsetInfo.Lock.Pitch == 0);
|
2018-06-21 11:36:47 +02:00
|
|
|
imgInfo.yOffsetForUVPlane = reqOffsetInfo.Lock.Offset / reqOffsetInfo.Lock.Pitch;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 13:38:15 +02:00
|
|
|
imgInfo.qPitch = queryQPitch(this->resourceParams.Type);
|
2018-06-21 11:36:47 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-28 13:38:15 +02:00
|
|
|
uint32_t Gmm::queryQPitch(GMM_RESOURCE_TYPE resType) {
|
2022-12-19 18:41:13 +00:00
|
|
|
if (gmmHelper->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
2018-06-21 11:36:47 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return gmmResourceInfo->getQPitch();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-27 11:25:35 +00:00
|
|
|
void Gmm::updateImgInfoAndDesc(ImageInfo &imgInfo, uint32_t arrayIndex, ImagePlane yuvPlaneType) {
|
2020-01-09 11:15:03 +01:00
|
|
|
imgInfo.imgDesc.imageWidth = gmmResourceInfo->getBaseWidth();
|
|
|
|
|
imgInfo.imgDesc.imageRowPitch = gmmResourceInfo->getRenderPitch();
|
|
|
|
|
if (imgInfo.imgDesc.imageRowPitch == 0) {
|
|
|
|
|
size_t width = alignUp(imgInfo.imgDesc.imageWidth, gmmResourceInfo->getHAlign());
|
|
|
|
|
imgInfo.imgDesc.imageRowPitch = width * (gmmResourceInfo->getBitsPerPixel() >> 3);
|
2018-06-21 11:36:47 +02:00
|
|
|
}
|
2020-01-09 11:15:03 +01:00
|
|
|
imgInfo.imgDesc.imageHeight = gmmResourceInfo->getBaseHeight();
|
2023-12-19 10:42:58 +00:00
|
|
|
if ((yuvPlaneType != ImagePlane::noPlane) && (yuvPlaneType != ImagePlane::planeY)) {
|
2023-06-27 11:25:35 +00:00
|
|
|
imgInfo.imgDesc.imageWidth /= 2;
|
|
|
|
|
imgInfo.imgDesc.imageHeight /= 2;
|
2023-12-19 10:42:58 +00:00
|
|
|
if (yuvPlaneType != ImagePlane::planeUV) {
|
2023-06-27 11:25:35 +00:00
|
|
|
imgInfo.imgDesc.imageRowPitch /= 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-09 11:15:03 +01:00
|
|
|
imgInfo.imgDesc.imageDepth = gmmResourceInfo->getBaseDepth();
|
|
|
|
|
imgInfo.imgDesc.imageArraySize = gmmResourceInfo->getArraySize();
|
|
|
|
|
if (imgInfo.imgDesc.imageDepth > 1 || imgInfo.imgDesc.imageArraySize > 1) {
|
2018-06-21 11:36:47 +02:00
|
|
|
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
2020-01-09 11:15:03 +01:00
|
|
|
reqOffsetInfo.Slice = imgInfo.imgDesc.imageDepth > 1 ? 1 : 0;
|
|
|
|
|
reqOffsetInfo.ArrayIndex = imgInfo.imgDesc.imageArraySize > 1 ? 1 : 0;
|
2018-06-21 11:36:47 +02:00
|
|
|
reqOffsetInfo.ReqLock = 1;
|
|
|
|
|
gmmResourceInfo->getOffset(reqOffsetInfo);
|
2020-01-09 11:15:03 +01:00
|
|
|
imgInfo.imgDesc.imageSlicePitch = static_cast<size_t>(reqOffsetInfo.Lock.Offset);
|
2018-06-21 11:36:47 +02:00
|
|
|
} else {
|
2020-01-09 11:15:03 +01:00
|
|
|
imgInfo.imgDesc.imageSlicePitch = gmmResourceInfo->getSizeAllocation();
|
2018-06-21 11:36:47 +02:00
|
|
|
}
|
|
|
|
|
|
2019-12-17 15:01:24 +01:00
|
|
|
updateOffsetsInImgInfo(imgInfo, arrayIndex);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 11:15:03 +01:00
|
|
|
void Gmm::updateOffsetsInImgInfo(ImageInfo &imgInfo, uint32_t arrayIndex) {
|
2018-06-21 11:36:47 +02:00
|
|
|
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
|
|
|
|
reqOffsetInfo.ReqRender = 1;
|
|
|
|
|
reqOffsetInfo.Slice = 0;
|
|
|
|
|
reqOffsetInfo.ArrayIndex = arrayIndex;
|
|
|
|
|
reqOffsetInfo.Plane = imgInfo.plane;
|
|
|
|
|
gmmResourceInfo->getOffset(reqOffsetInfo);
|
2020-04-14 09:57:59 +02:00
|
|
|
UNRECOVERABLE_IF(gmmResourceInfo->getBitsPerPixel() == 0u);
|
2018-06-21 11:36:47 +02:00
|
|
|
imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (gmmResourceInfo->getBitsPerPixel() / 8);
|
|
|
|
|
imgInfo.yOffset = reqOffsetInfo.Render.YOffset;
|
|
|
|
|
imgInfo.offset = reqOffsetInfo.Render.Offset;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 11:15:03 +01:00
|
|
|
uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, ImagePlane plane) {
|
2018-06-21 11:36:47 +02:00
|
|
|
GMM_RES_COPY_BLT gmmResourceCopyBLT = {};
|
|
|
|
|
|
2023-12-19 10:42:58 +00:00
|
|
|
if (plane == ImagePlane::planeV) {
|
2018-06-21 11:36:47 +02:00
|
|
|
sys = ptrOffset(sys, height * pitch * 2);
|
|
|
|
|
pitch /= 2;
|
2023-12-19 10:42:58 +00:00
|
|
|
} else if (plane == ImagePlane::planeU) {
|
2018-06-21 11:36:47 +02:00
|
|
|
sys = ptrOffset(sys, height * pitch * 2 + height * pitch / 2);
|
|
|
|
|
pitch /= 2;
|
2023-12-19 10:42:58 +00:00
|
|
|
} else if (plane == ImagePlane::planeUV) {
|
2018-06-21 11:36:47 +02:00
|
|
|
sys = ptrOffset(sys, height * pitch * 2);
|
|
|
|
|
}
|
|
|
|
|
uint32_t size = pitch * height;
|
|
|
|
|
|
|
|
|
|
gmmResourceCopyBLT.Sys.pData = sys;
|
|
|
|
|
gmmResourceCopyBLT.Gpu.pData = gpu;
|
|
|
|
|
gmmResourceCopyBLT.Sys.RowPitch = pitch;
|
|
|
|
|
gmmResourceCopyBLT.Blt.Upload = upload;
|
|
|
|
|
gmmResourceCopyBLT.Sys.BufferSize = size;
|
|
|
|
|
|
|
|
|
|
return this->gmmResourceInfo->cpuBlt(&gmmResourceCopyBLT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Gmm::unifiedAuxTranslationCapable() const {
|
|
|
|
|
auto gmmFlags = this->gmmResourceInfo->getResourceFlags();
|
2019-07-02 12:50:29 +02:00
|
|
|
UNRECOVERABLE_IF(gmmFlags->Info.RenderCompressed && gmmFlags->Info.MediaCompressed);
|
2020-01-07 10:10:57 +01:00
|
|
|
return gmmFlags->Gpu.CCS && gmmFlags->Gpu.UnifiedAuxSurface && (gmmFlags->Info.RenderCompressed | gmmFlags->Info.MediaCompressed);
|
2018-06-21 11:36:47 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-30 11:29:48 +01:00
|
|
|
bool Gmm::hasMultisampleControlSurface() const {
|
|
|
|
|
return this->gmmResourceInfo->getResourceFlags()->Gpu.MCS;
|
|
|
|
|
}
|
2019-02-08 10:19:22 +01:00
|
|
|
|
2022-04-28 12:51:31 +00:00
|
|
|
GmmHelper *Gmm::getGmmHelper() const {
|
|
|
|
|
return this->gmmHelper;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 10:19:22 +01:00
|
|
|
uint32_t Gmm::getUnifiedAuxPitchTiles() {
|
|
|
|
|
return this->gmmResourceInfo->getRenderAuxPitchTiles();
|
|
|
|
|
}
|
|
|
|
|
uint32_t Gmm::getAuxQPitch() {
|
|
|
|
|
return this->gmmResourceInfo->getAuxQPitch();
|
|
|
|
|
}
|
2021-07-15 16:05:09 +00:00
|
|
|
|
2022-07-26 04:58:51 +00:00
|
|
|
void Gmm::applyMemoryFlags(const StorageInfo &storageInfo) {
|
2022-12-19 18:41:13 +00:00
|
|
|
auto hardwareInfo = gmmHelper->getHardwareInfo();
|
2021-07-15 16:05:09 +00:00
|
|
|
|
2021-11-25 09:31:14 +00:00
|
|
|
if (hardwareInfo->featureTable.flags.ftrLocalMemory) {
|
2022-02-09 13:14:31 +00:00
|
|
|
if (storageInfo.systemMemoryPlacement) {
|
2021-07-15 16:05:09 +00:00
|
|
|
resourceParams.Flags.Info.NonLocalOnly = 1;
|
|
|
|
|
} else {
|
|
|
|
|
if (extraMemoryFlagsRequired()) {
|
|
|
|
|
applyExtraMemoryFlags(storageInfo);
|
|
|
|
|
} else if (!storageInfo.isLockable) {
|
2024-06-10 10:37:06 +00:00
|
|
|
if (storageInfo.localOnlyRequired) {
|
2021-07-15 16:05:09 +00:00
|
|
|
resourceParams.Flags.Info.LocalOnly = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-11 12:14:46 +00:00
|
|
|
if (!storageInfo.isLockable) {
|
|
|
|
|
resourceParams.Flags.Info.NotLockable = 1;
|
|
|
|
|
}
|
2021-07-15 16:05:09 +00:00
|
|
|
|
2021-11-25 09:31:14 +00:00
|
|
|
if (hardwareInfo->featureTable.flags.ftrMultiTileArch) {
|
2021-07-15 16:05:09 +00:00
|
|
|
resourceParams.MultiTileArch.Enable = 1;
|
2022-02-09 13:14:31 +00:00
|
|
|
if (storageInfo.systemMemoryPlacement) {
|
2021-07-15 16:05:09 +00:00
|
|
|
resourceParams.MultiTileArch.GpuVaMappingSet = hardwareInfo->gtSystemInfo.MultiTileArchInfo.TileMask;
|
|
|
|
|
resourceParams.MultiTileArch.LocalMemPreferredSet = 0;
|
|
|
|
|
resourceParams.MultiTileArch.LocalMemEligibilitySet = 0;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
auto tileSelected = std::max(storageInfo.memoryBanks.to_ulong(), 1lu);
|
|
|
|
|
|
|
|
|
|
if (storageInfo.cloningOfPageTables) {
|
|
|
|
|
resourceParams.MultiTileArch.GpuVaMappingSet = static_cast<uint8_t>(storageInfo.pageTablesVisibility.to_ulong());
|
|
|
|
|
} else {
|
|
|
|
|
resourceParams.MultiTileArch.TileInstanced = storageInfo.tileInstanced;
|
|
|
|
|
resourceParams.MultiTileArch.GpuVaMappingSet = static_cast<uint8_t>(tileSelected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resourceParams.MultiTileArch.LocalMemPreferredSet = static_cast<uint8_t>(tileSelected);
|
|
|
|
|
resourceParams.MultiTileArch.LocalMemEligibilitySet = static_cast<uint8_t>(tileSelected);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-06 10:46:00 +00:00
|
|
|
|
|
|
|
|
void Gmm::applyDebugOverrides() {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (-1 != debugManager.flags.OverrideGmmResourceUsageField.get()) {
|
|
|
|
|
resourceParams.Usage = static_cast<GMM_RESOURCE_USAGE_TYPE>(debugManager.flags.OverrideGmmResourceUsageField.get());
|
2021-08-06 10:46:00 +00:00
|
|
|
}
|
2022-02-21 13:33:41 +00:00
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (true == (debugManager.flags.ForceAllResourcesUncached.get())) {
|
2022-02-21 13:33:41 +00:00
|
|
|
resourceParams.Usage = GMM_RESOURCE_USAGE_SURFACE_UNCACHED;
|
|
|
|
|
}
|
2021-08-06 10:46:00 +00:00
|
|
|
}
|
2024-01-23 11:23:06 +00:00
|
|
|
|
|
|
|
|
const char *Gmm::getUsageTypeString() {
|
|
|
|
|
switch (resourceParams.Usage) {
|
|
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED";
|
|
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED";
|
2024-01-25 12:32:27 +00:00
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER";
|
2024-01-23 11:23:06 +00:00
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC";
|
|
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_BUFFER_CONST:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_BUFFER_CONST";
|
|
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER";
|
|
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_BUFFER:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_BUFFER";
|
|
|
|
|
case GMM_RESOURCE_USAGE_TYPE_ENUM::GMM_RESOURCE_USAGE_OCL_IMAGE:
|
|
|
|
|
return "GMM_RESOURCE_USAGE_OCL_IMAGE";
|
|
|
|
|
default:
|
|
|
|
|
return "UNKNOWN GMM USAGE TYPE";
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|