2018-06-21 17:36:47 +08:00
|
|
|
/*
|
2023-01-24 02:44:33 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-09-18 19:55:06 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2018-06-21 17:36:47 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2022-12-20 02:41:13 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2022-02-04 21:50:19 +08:00
|
|
|
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
2020-02-24 05:44:01 +08: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-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-02-24 05:44:01 +08: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 21:50:19 +08:00
|
|
|
#include "shared/source/memory_manager/allocation_type.h"
|
2022-07-26 12:58:51 +08:00
|
|
|
#include "shared/source/memory_manager/definitions/storage_info.h"
|
2018-06-21 17:36:47 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2022-04-27 18:20:10 +08:00
|
|
|
Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage,
|
2022-07-26 12:58:51 +08:00
|
|
|
bool preferCompressed, const StorageInfo &storageInfo, bool allowLargePages) : gmmHelper(gmmHelper) {
|
2018-06-29 17:48:19 +08:00
|
|
|
resourceParams.Type = RESOURCE_BUFFER;
|
|
|
|
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
2019-01-18 16:44:52 +08:00
|
|
|
resourceParams.BaseWidth64 = static_cast<uint64_t>(alignedSize);
|
2018-06-29 17:48:19 +08:00
|
|
|
resourceParams.BaseHeight = 1;
|
|
|
|
resourceParams.Depth = 1;
|
2021-04-12 22:34:35 +08:00
|
|
|
resourceParams.BaseAlignment = static_cast<uint32_t>(alignment);
|
2021-07-14 22:51:47 +08:00
|
|
|
if ((nullptr == alignedPtr) && (false == allowLargePages)) {
|
|
|
|
resourceParams.Flags.Info.NoOptimizationPadding = true;
|
|
|
|
if ((resourceParams.BaseWidth64 & MemoryConstants::page64kMask) == 0) {
|
|
|
|
resourceParams.BaseWidth64 += MemoryConstants::pageSize;
|
|
|
|
}
|
|
|
|
}
|
2022-01-05 22:24:16 +08:00
|
|
|
|
2022-02-04 21:50:19 +08:00
|
|
|
resourceParams.Usage = gmmResourceUsage;
|
2018-06-29 17:48:19 +08:00
|
|
|
resourceParams.Flags.Info.Linear = 1;
|
2023-09-13 16:37:04 +08:00
|
|
|
this->preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(gmmResourceUsage, gmmHelper->getRootDeviceEnvironment());
|
2023-07-26 22:27:51 +08:00
|
|
|
resourceParams.Flags.Info.Cacheable = !this->preferNoCpuAccess && !CacheSettingsHelper::isUncachedType(gmmResourceUsage);
|
2018-06-29 17:48:19 +08:00
|
|
|
resourceParams.Flags.Gpu.Texture = 1;
|
|
|
|
|
|
|
|
if (alignedPtr) {
|
|
|
|
resourceParams.Flags.Info.ExistingSysMem = 1;
|
2019-12-19 16:25:08 +08:00
|
|
|
resourceParams.pExistingSysMem = castToUint64(alignedPtr);
|
2018-06-29 17:48:19 +08:00
|
|
|
resourceParams.ExistingSysMemSize = alignedSize;
|
2019-01-10 21:12:10 +08:00
|
|
|
} else {
|
|
|
|
resourceParams.NoGfxMemory = 1u;
|
2018-06-29 17:48:19 +08:00
|
|
|
}
|
|
|
|
|
2019-01-18 16:44:52 +08:00
|
|
|
if (resourceParams.BaseWidth64 >= GmmHelper::maxPossiblePitch) {
|
2018-06-21 17:36:47 +08:00
|
|
|
resourceParams.Flags.Gpu.NoRestriction = 1;
|
|
|
|
}
|
|
|
|
|
2023-05-11 20:14:46 +08:00
|
|
|
preferCompressed &= !storageInfo.isLockable;
|
|
|
|
|
2021-12-03 21:52:16 +08:00
|
|
|
applyAuxFlagsForBuffer(preferCompressed);
|
2022-02-07 22:27:53 +08:00
|
|
|
applyMemoryFlags(storageInfo);
|
2021-05-20 21:49:04 +08:00
|
|
|
applyAppResource(storageInfo);
|
2021-08-06 18:46:00 +08:00
|
|
|
applyDebugOverrides();
|
2018-06-29 17:48:19 +08:00
|
|
|
|
2022-04-27 18:20:10 +08:00
|
|
|
gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &resourceParams));
|
2018-06-21 17:36:47 +08:00
|
|
|
}
|
|
|
|
|
2022-04-19 20:11:45 +08: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 18:46:00 +08:00
|
|
|
applyDebugOverrides();
|
2018-06-29 17:48:19 +08:00
|
|
|
}
|
|
|
|
|
2020-01-13 18:35:19 +08:00
|
|
|
Gmm::~Gmm() = default;
|
|
|
|
|
2022-07-26 12:58:51 +08:00
|
|
|
Gmm::Gmm(GmmHelper *gmmHelper, ImageInfo &inputOutputImgInfo, const StorageInfo &storageInfo, bool preferCompressed) : gmmHelper(gmmHelper) {
|
2019-04-01 13:22:13 +08:00
|
|
|
this->resourceParams = {};
|
2023-05-11 20:14:46 +08:00
|
|
|
preferCompressed &= !storageInfo.isLockable;
|
2021-12-03 21:52:16 +08:00
|
|
|
setupImageResourceParams(inputOutputImgInfo, preferCompressed);
|
2022-02-07 22:27:53 +08:00
|
|
|
applyMemoryFlags(storageInfo);
|
2021-05-20 21:49:04 +08:00
|
|
|
applyAppResource(storageInfo);
|
2021-08-06 18:46:00 +08:00
|
|
|
applyDebugOverrides();
|
2021-05-20 21:49:04 +08:00
|
|
|
|
2022-04-27 18:20:10 +08:00
|
|
|
this->gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &this->resourceParams));
|
2019-04-01 13:22:13 +08:00
|
|
|
UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);
|
|
|
|
|
2018-06-29 17:48:19 +08:00
|
|
|
queryImageParams(inputOutputImgInfo);
|
|
|
|
}
|
|
|
|
|
2021-12-03 21:52:16 +08:00
|
|
|
void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) {
|
2020-01-09 18:15:03 +08:00
|
|
|
uint64_t imageWidth = static_cast<uint64_t>(imgInfo.imgDesc.imageWidth);
|
2018-06-21 17:36:47 +08:00
|
|
|
uint32_t imageHeight = 1;
|
|
|
|
uint32_t imageDepth = 1;
|
|
|
|
uint32_t imageCount = 1;
|
|
|
|
|
2020-01-09 18:15:03 +08:00
|
|
|
switch (imgInfo.imgDesc.imageType) {
|
2020-01-08 18:11:54 +08:00
|
|
|
case ImageType::Image1D:
|
|
|
|
case ImageType::Image1DArray:
|
|
|
|
case ImageType::Image1DBuffer:
|
2019-04-01 13:22:13 +08:00
|
|
|
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D;
|
2018-06-21 17:36:47 +08:00
|
|
|
break;
|
2020-01-08 18:11:54 +08:00
|
|
|
case ImageType::Image2D:
|
|
|
|
case ImageType::Image2DArray:
|
2019-04-01 13:22:13 +08:00
|
|
|
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_2D;
|
2020-01-09 18:15:03 +08:00
|
|
|
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc.imageHeight);
|
2018-06-21 17:36:47 +08:00
|
|
|
break;
|
2020-01-08 18:11:54 +08:00
|
|
|
case ImageType::Image3D:
|
2019-04-01 13:22:13 +08:00
|
|
|
resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_3D;
|
2020-01-09 18:15:03 +08:00
|
|
|
imageHeight = static_cast<uint32_t>(imgInfo.imgDesc.imageHeight);
|
|
|
|
imageDepth = static_cast<uint32_t>(imgInfo.imgDesc.imageDepth);
|
2018-06-21 17:36:47 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-09 18:15:03 +08:00
|
|
|
if (imgInfo.imgDesc.imageType == ImageType::Image1DArray ||
|
|
|
|
imgInfo.imgDesc.imageType == ImageType::Image2DArray) {
|
|
|
|
imageCount = static_cast<uint32_t>(imgInfo.imgDesc.imageArraySize);
|
2018-06-21 17:36:47 +08:00
|
|
|
}
|
|
|
|
|
2019-08-26 15:27:30 +08:00
|
|
|
resourceParams.Flags.Info.Linear = imgInfo.linearStorage;
|
2018-06-21 17:36:47 +08:00
|
|
|
|
2022-12-20 02:41:13 +08:00
|
|
|
auto &gfxCoreHelper = gmmHelper->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
2023-01-24 02:44:33 +08:00
|
|
|
auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper<ProductHelper>();
|
2019-04-01 13:22:13 +08:00
|
|
|
resourceParams.NoGfxMemory = 1; // dont allocate, only query for params
|
|
|
|
|
2023-01-24 02:44:33 +08:00
|
|
|
resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, productHelper);
|
2021-08-06 18:46:00 +08:00
|
|
|
|
2023-04-27 17:50:55 +08:00
|
|
|
resourceParams.Format = imgInfo.surfaceFormat->gmmSurfaceFormat;
|
2019-04-01 13:22:13 +08:00
|
|
|
resourceParams.Flags.Gpu.Texture = 1;
|
|
|
|
resourceParams.BaseWidth64 = imageWidth;
|
|
|
|
resourceParams.BaseHeight = imageHeight;
|
|
|
|
resourceParams.Depth = imageDepth;
|
|
|
|
resourceParams.ArraySize = imageCount;
|
2022-12-08 20:22:35 +08:00
|
|
|
resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = gfxCoreHelper.hvAlign4Required();
|
2019-04-01 13:22:13 +08:00
|
|
|
resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount;
|
2018-06-21 17:36:47 +08:00
|
|
|
|
2021-12-03 21:52:16 +08:00
|
|
|
applyAuxFlagsForImage(imgInfo, preferCompressed);
|
2019-04-01 13:22:13 +08:00
|
|
|
}
|
2018-06-21 17:36:47 +08:00
|
|
|
|
2021-12-03 21:52:16 +08:00
|
|
|
void Gmm::applyAuxFlagsForBuffer(bool preferCompression) {
|
2022-12-20 02:41:13 +08:00
|
|
|
auto &rootDeviceEnvironment = gmmHelper->getRootDeviceEnvironment();
|
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
|
|
|
auto hardwareInfo = rootDeviceEnvironment.getHardwareInfo();
|
2022-12-08 20:22:35 +08:00
|
|
|
bool allowCompression = GfxCoreHelper::compressedBuffersSupported(*hardwareInfo) &&
|
2021-12-03 21:52:16 +08:00
|
|
|
preferCompression;
|
2020-11-04 22:55:09 +08:00
|
|
|
|
2021-12-03 21:52:16 +08:00
|
|
|
if (allowCompression) {
|
2022-12-08 20:22:35 +08:00
|
|
|
gfxCoreHelper.applyRenderCompressionFlag(*this, 1);
|
2020-11-04 22:55:09 +08:00
|
|
|
resourceParams.Flags.Gpu.CCS = 1;
|
|
|
|
resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
2021-06-09 00:37:54 +08:00
|
|
|
isCompressionEnabled = true;
|
2020-11-04 22:55:09 +08:00
|
|
|
}
|
2022-12-08 20:22:35 +08:00
|
|
|
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !isCompressionEnabled);
|
2021-06-26 00:21:51 +08:00
|
|
|
}
|
|
|
|
|
2021-12-03 21:52:16 +08:00
|
|
|
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferCompressed) {
|
2021-06-26 00:21:51 +08:00
|
|
|
uint8_t compressionFormat;
|
2022-12-20 02:41:13 +08:00
|
|
|
auto &rootDeviceEnvironment = gmmHelper->getRootDeviceEnvironment();
|
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
|
|
|
auto hardwareInfo = rootDeviceEnvironment.getHardwareInfo();
|
2021-06-26 00:21:51 +08:00
|
|
|
if (this->resourceParams.Flags.Info.MediaCompressed) {
|
2023-04-27 17:50:55 +08:00
|
|
|
compressionFormat = gmmHelper->getClientContext()->getMediaSurfaceStateCompressionFormat(imgInfo.surfaceFormat->gmmSurfaceFormat);
|
2021-06-26 00:21:51 +08:00
|
|
|
} else {
|
2023-04-27 17:50:55 +08:00
|
|
|
compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(imgInfo.surfaceFormat->gmmSurfaceFormat);
|
2021-06-26 00:21:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool compressionFormatSupported = false;
|
2022-12-20 02:41:13 +08:00
|
|
|
if (hardwareInfo->featureTable.flags.ftrFlatPhysCCS) {
|
2021-06-26 00:21:51 +08:00
|
|
|
compressionFormatSupported = compressionFormat != GMM_FLATCCS_FORMAT::GMM_FLATCCS_FORMAT_INVALID;
|
|
|
|
} else {
|
|
|
|
compressionFormatSupported = compressionFormat != GMM_E2ECOMP_FORMAT::GMM_E2ECOMP_FORMAT_INVALID;
|
|
|
|
}
|
|
|
|
|
2023-04-27 17:50:55 +08: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-26 00:21:51 +08:00
|
|
|
|
2022-12-20 02:41:13 +08:00
|
|
|
bool allowCompression = GfxCoreHelper::compressedImagesSupported(*hardwareInfo) &&
|
2021-12-03 21:52:16 +08:00
|
|
|
preferCompressed &&
|
|
|
|
compressionFormatSupported &&
|
2023-04-27 17:50:55 +08:00
|
|
|
imgInfo.surfaceFormat->gmmSurfaceFormat != GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12 &&
|
2021-12-03 21:52:16 +08:00
|
|
|
imgInfo.plane == GMM_YUV_PLANE_ENUM::GMM_NO_PLANE &&
|
|
|
|
!isPackedYuv;
|
2021-06-26 00:21:51 +08:00
|
|
|
|
2022-12-20 02:41:13 +08:00
|
|
|
if (imgInfo.useLocalMemory || !hardwareInfo->featureTable.flags.ftrLocalMemory) {
|
2021-12-03 21:52:16 +08:00
|
|
|
if (allowCompression) {
|
2022-12-08 20:22:35 +08:00
|
|
|
gfxCoreHelper.applyRenderCompressionFlag(*this, 1);
|
2021-06-26 00:21:51 +08:00
|
|
|
this->resourceParams.Flags.Gpu.CCS = 1;
|
|
|
|
this->resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
|
|
|
this->resourceParams.Flags.Gpu.IndirectClearColor = 1;
|
|
|
|
this->isCompressionEnabled = true;
|
|
|
|
}
|
|
|
|
}
|
2022-12-08 20:22:35 +08:00
|
|
|
gfxCoreHelper.applyAdditionalCompressionSettings(*this, !isCompressionEnabled);
|
2020-11-04 22:55:09 +08:00
|
|
|
}
|
|
|
|
|
2019-04-01 13:22:13 +08:00
|
|
|
void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
|
|
|
auto imageCount = this->gmmResourceInfo->getArraySize();
|
2018-06-21 17:36:47 +08: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 17:50:55 +08:00
|
|
|
if (imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12 || imgInfo.surfaceFormat->gmmSurfaceFormat == GMM_RESOURCE_FORMAT::GMM_FORMAT_P010) {
|
2018-06-21 17:36:47 +08: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 19:55:06 +08:00
|
|
|
UNRECOVERABLE_IF(reqOffsetInfo.Lock.Pitch == 0);
|
2018-06-21 17:36:47 +08:00
|
|
|
imgInfo.yOffsetForUVPlane = reqOffsetInfo.Lock.Offset / reqOffsetInfo.Lock.Pitch;
|
|
|
|
}
|
|
|
|
|
2018-06-28 19:38:15 +08:00
|
|
|
imgInfo.qPitch = queryQPitch(this->resourceParams.Type);
|
2018-06-21 17:36:47 +08:00
|
|
|
}
|
|
|
|
|
2018-06-28 19:38:15 +08:00
|
|
|
uint32_t Gmm::queryQPitch(GMM_RESOURCE_TYPE resType) {
|
2022-12-20 02:41:13 +08:00
|
|
|
if (gmmHelper->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
2018-06-21 17:36:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return gmmResourceInfo->getQPitch();
|
|
|
|
}
|
|
|
|
|
2023-06-27 19:25:35 +08:00
|
|
|
void Gmm::updateImgInfoAndDesc(ImageInfo &imgInfo, uint32_t arrayIndex, ImagePlane yuvPlaneType) {
|
2020-01-09 18:15:03 +08: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 17:36:47 +08:00
|
|
|
}
|
2020-01-09 18:15:03 +08:00
|
|
|
imgInfo.imgDesc.imageHeight = gmmResourceInfo->getBaseHeight();
|
2023-06-27 19:25:35 +08:00
|
|
|
if ((yuvPlaneType != ImagePlane::NO_PLANE) && (yuvPlaneType != ImagePlane::PLANE_Y)) {
|
|
|
|
imgInfo.imgDesc.imageWidth /= 2;
|
|
|
|
imgInfo.imgDesc.imageHeight /= 2;
|
|
|
|
if (yuvPlaneType != ImagePlane::PLANE_UV) {
|
|
|
|
imgInfo.imgDesc.imageRowPitch /= 2;
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 18:15:03 +08:00
|
|
|
imgInfo.imgDesc.imageDepth = gmmResourceInfo->getBaseDepth();
|
|
|
|
imgInfo.imgDesc.imageArraySize = gmmResourceInfo->getArraySize();
|
|
|
|
if (imgInfo.imgDesc.imageDepth > 1 || imgInfo.imgDesc.imageArraySize > 1) {
|
2018-06-21 17:36:47 +08:00
|
|
|
GMM_REQ_OFFSET_INFO reqOffsetInfo = {};
|
2020-01-09 18:15:03 +08:00
|
|
|
reqOffsetInfo.Slice = imgInfo.imgDesc.imageDepth > 1 ? 1 : 0;
|
|
|
|
reqOffsetInfo.ArrayIndex = imgInfo.imgDesc.imageArraySize > 1 ? 1 : 0;
|
2018-06-21 17:36:47 +08:00
|
|
|
reqOffsetInfo.ReqLock = 1;
|
|
|
|
gmmResourceInfo->getOffset(reqOffsetInfo);
|
2020-01-09 18:15:03 +08:00
|
|
|
imgInfo.imgDesc.imageSlicePitch = static_cast<size_t>(reqOffsetInfo.Lock.Offset);
|
2018-06-21 17:36:47 +08:00
|
|
|
} else {
|
2020-01-09 18:15:03 +08:00
|
|
|
imgInfo.imgDesc.imageSlicePitch = gmmResourceInfo->getSizeAllocation();
|
2018-06-21 17:36:47 +08:00
|
|
|
}
|
|
|
|
|
2019-12-17 22:01:24 +08:00
|
|
|
updateOffsetsInImgInfo(imgInfo, arrayIndex);
|
|
|
|
}
|
|
|
|
|
2020-01-09 18:15:03 +08:00
|
|
|
void Gmm::updateOffsetsInImgInfo(ImageInfo &imgInfo, uint32_t arrayIndex) {
|
2018-06-21 17:36:47 +08: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 15:57:59 +08:00
|
|
|
UNRECOVERABLE_IF(gmmResourceInfo->getBitsPerPixel() == 0u);
|
2018-06-21 17:36:47 +08:00
|
|
|
imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (gmmResourceInfo->getBitsPerPixel() / 8);
|
|
|
|
imgInfo.yOffset = reqOffsetInfo.Render.YOffset;
|
|
|
|
imgInfo.offset = reqOffsetInfo.Render.Offset;
|
|
|
|
}
|
|
|
|
|
2020-01-09 18:15:03 +08:00
|
|
|
uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, ImagePlane plane) {
|
2018-06-21 17:36:47 +08:00
|
|
|
GMM_RES_COPY_BLT gmmResourceCopyBLT = {};
|
|
|
|
|
2020-01-09 18:15:03 +08:00
|
|
|
if (plane == ImagePlane::PLANE_V) {
|
2018-06-21 17:36:47 +08:00
|
|
|
sys = ptrOffset(sys, height * pitch * 2);
|
|
|
|
pitch /= 2;
|
2020-01-09 18:15:03 +08:00
|
|
|
} else if (plane == ImagePlane::PLANE_U) {
|
2018-06-21 17:36:47 +08:00
|
|
|
sys = ptrOffset(sys, height * pitch * 2 + height * pitch / 2);
|
|
|
|
pitch /= 2;
|
2020-01-09 18:15:03 +08:00
|
|
|
} else if (plane == ImagePlane::PLANE_UV) {
|
2018-06-21 17:36:47 +08: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 18:50:29 +08:00
|
|
|
UNRECOVERABLE_IF(gmmFlags->Info.RenderCompressed && gmmFlags->Info.MediaCompressed);
|
2020-01-07 17:10:57 +08:00
|
|
|
return gmmFlags->Gpu.CCS && gmmFlags->Gpu.UnifiedAuxSurface && (gmmFlags->Info.RenderCompressed | gmmFlags->Info.MediaCompressed);
|
2018-06-21 17:36:47 +08:00
|
|
|
}
|
|
|
|
|
2019-01-30 18:29:48 +08:00
|
|
|
bool Gmm::hasMultisampleControlSurface() const {
|
|
|
|
return this->gmmResourceInfo->getResourceFlags()->Gpu.MCS;
|
|
|
|
}
|
2019-02-08 17:19:22 +08:00
|
|
|
|
2022-04-28 20:51:31 +08:00
|
|
|
GmmHelper *Gmm::getGmmHelper() const {
|
|
|
|
return this->gmmHelper;
|
|
|
|
}
|
|
|
|
|
2019-02-08 17:19:22 +08:00
|
|
|
uint32_t Gmm::getUnifiedAuxPitchTiles() {
|
|
|
|
return this->gmmResourceInfo->getRenderAuxPitchTiles();
|
|
|
|
}
|
|
|
|
uint32_t Gmm::getAuxQPitch() {
|
|
|
|
return this->gmmResourceInfo->getAuxQPitch();
|
|
|
|
}
|
2021-07-16 00:05:09 +08:00
|
|
|
|
2022-07-26 12:58:51 +08:00
|
|
|
void Gmm::applyMemoryFlags(const StorageInfo &storageInfo) {
|
2022-12-20 02:41:13 +08:00
|
|
|
auto hardwareInfo = gmmHelper->getHardwareInfo();
|
2021-07-16 00:05:09 +08:00
|
|
|
|
2021-11-25 17:31:14 +08:00
|
|
|
if (hardwareInfo->featureTable.flags.ftrLocalMemory) {
|
2022-02-09 21:14:31 +08:00
|
|
|
if (storageInfo.systemMemoryPlacement) {
|
2021-07-16 00:05:09 +08:00
|
|
|
resourceParams.Flags.Info.NonLocalOnly = 1;
|
|
|
|
} else {
|
|
|
|
if (extraMemoryFlagsRequired()) {
|
|
|
|
applyExtraMemoryFlags(storageInfo);
|
|
|
|
} else if (!storageInfo.isLockable) {
|
|
|
|
if (isCompressionEnabled || storageInfo.localOnlyRequired) {
|
|
|
|
resourceParams.Flags.Info.LocalOnly = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-11 20:14:46 +08:00
|
|
|
if (!storageInfo.isLockable) {
|
|
|
|
resourceParams.Flags.Info.NotLockable = 1;
|
|
|
|
}
|
2021-07-16 00:05:09 +08:00
|
|
|
|
2021-11-25 17:31:14 +08:00
|
|
|
if (hardwareInfo->featureTable.flags.ftrMultiTileArch) {
|
2021-07-16 00:05:09 +08:00
|
|
|
resourceParams.MultiTileArch.Enable = 1;
|
2022-02-09 21:14:31 +08:00
|
|
|
if (storageInfo.systemMemoryPlacement) {
|
2021-07-16 00:05:09 +08: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 18:46:00 +08:00
|
|
|
|
|
|
|
void Gmm::applyDebugOverrides() {
|
|
|
|
if (-1 != DebugManager.flags.OverrideGmmResourceUsageField.get()) {
|
|
|
|
resourceParams.Usage = static_cast<GMM_RESOURCE_USAGE_TYPE>(DebugManager.flags.OverrideGmmResourceUsageField.get());
|
|
|
|
}
|
2022-02-21 21:33:41 +08:00
|
|
|
|
|
|
|
if (true == (DebugManager.flags.ForceAllResourcesUncached.get())) {
|
|
|
|
resourceParams.Usage = GMM_RESOURCE_USAGE_SURFACE_UNCACHED;
|
|
|
|
}
|
2021-08-06 18:46:00 +08:00
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|