mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Refactor [1/n]: Make compression preference allocation property
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4461b8ea3f
commit
7b55d38e34
@@ -73,9 +73,9 @@ Gmm::Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm) : clientC
|
||||
|
||||
Gmm::~Gmm() = default;
|
||||
|
||||
Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo) : clientContext(clientContext) {
|
||||
Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferRenderCompressed) : clientContext(clientContext) {
|
||||
this->resourceParams = {};
|
||||
setupImageResourceParams(inputOutputImgInfo);
|
||||
setupImageResourceParams(inputOutputImgInfo, preferRenderCompressed);
|
||||
applyMemoryFlags(!inputOutputImgInfo.useLocalMemory, storageInfo);
|
||||
applyAppResource(storageInfo);
|
||||
applyDebugOverrides();
|
||||
@@ -86,7 +86,7 @@ Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, Storage
|
||||
queryImageParams(inputOutputImgInfo);
|
||||
}
|
||||
|
||||
void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
||||
void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferRenderCompressed) {
|
||||
uint64_t imageWidth = static_cast<uint64_t>(imgInfo.imgDesc.imageWidth);
|
||||
uint32_t imageHeight = 1;
|
||||
uint32_t imageDepth = 1;
|
||||
@@ -138,7 +138,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
||||
resourceParams.Flags.Info.AllowVirtualPadding = true;
|
||||
}
|
||||
|
||||
applyAuxFlagsForImage(imgInfo);
|
||||
applyAuxFlagsForImage(imgInfo, preferRenderCompressed);
|
||||
}
|
||||
|
||||
void Gmm::applyAuxFlagsForBuffer(bool preferRenderCompression) {
|
||||
@@ -156,7 +156,7 @@ void Gmm::applyAuxFlagsForBuffer(bool preferRenderCompression) {
|
||||
hwHelper.applyAdditionalCompressionSettings(*this, !isCompressionEnabled);
|
||||
}
|
||||
|
||||
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo) {
|
||||
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferRenderCompressed) {
|
||||
uint8_t compressionFormat;
|
||||
if (this->resourceParams.Flags.Info.MediaCompressed) {
|
||||
compressionFormat = clientContext->getMediaSurfaceStateCompressionFormat(imgInfo.surfaceFormat->GMMSurfaceFormat);
|
||||
@@ -179,7 +179,7 @@ void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo) {
|
||||
auto hwInfo = clientContext->getHardwareInfo();
|
||||
|
||||
bool allowRenderCompression = HwHelper::renderCompressedImagesSupported(*hwInfo) &&
|
||||
imgInfo.preferRenderCompression &&
|
||||
preferRenderCompressed &&
|
||||
compressionFormatSupported &&
|
||||
imgInfo.surfaceFormat->GMMSurfaceFormat != GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12 &&
|
||||
imgInfo.plane == GMM_YUV_PLANE_ENUM::GMM_NO_PLANE &&
|
||||
|
||||
@@ -24,7 +24,7 @@ class Gmm {
|
||||
public:
|
||||
virtual ~Gmm();
|
||||
Gmm() = delete;
|
||||
Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo);
|
||||
Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferRenderCompressed);
|
||||
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable);
|
||||
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo);
|
||||
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferRenderCompressed, bool systemMemoryPool, StorageInfo storageInfo, bool allowLargePages);
|
||||
@@ -54,8 +54,8 @@ class Gmm {
|
||||
bool useSystemMemoryPool = true;
|
||||
|
||||
protected:
|
||||
void applyAuxFlagsForImage(ImageInfo &imgInfo);
|
||||
void setupImageResourceParams(ImageInfo &imgInfo);
|
||||
void applyAuxFlagsForImage(ImageInfo &imgInfo, bool preferRenderCompressed);
|
||||
void setupImageResourceParams(ImageInfo &imgInfo, bool preferRenderCompressed);
|
||||
bool extraMemoryFlagsRequired();
|
||||
void applyExtraMemoryFlags(const StorageInfo &storageInfo);
|
||||
void applyDebugOverrides();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -239,7 +239,6 @@ struct ImageInfo {
|
||||
uint32_t baseMipLevel;
|
||||
uint32_t mipCount;
|
||||
bool linearStorage;
|
||||
bool preferRenderCompression;
|
||||
bool useLocalMemory;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ struct AllocationProperties {
|
||||
uint32_t use32BitFrontWindow : 1;
|
||||
uint32_t crossRootDeviceAccess : 1;
|
||||
uint32_t forceSystemMemory : 1;
|
||||
uint32_t reserved : 18;
|
||||
uint32_t preferCompressed : 1;
|
||||
uint32_t reserved : 17;
|
||||
} flags;
|
||||
uint32_t allFlags = 0;
|
||||
};
|
||||
|
||||
@@ -425,7 +425,8 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
allocationData.flags.uncacheable = properties.flags.uncacheable;
|
||||
allocationData.flags.flushL3 =
|
||||
(mayRequireL3Flush ? properties.flags.flushL3RequiredForRead | properties.flags.flushL3RequiredForWrite : 0u);
|
||||
allocationData.flags.preferRenderCompressed = CompressionSelector::preferRenderCompressedBuffer(properties, *hwInfo);
|
||||
allocationData.flags.preferRenderCompressed = properties.flags.preferCompressed;
|
||||
allocationData.flags.preferRenderCompressed |= CompressionSelector::preferRenderCompressedBuffer(properties, *hwInfo);
|
||||
allocationData.flags.multiOsContextCapable = properties.flags.multiOsContextCapable;
|
||||
|
||||
if (properties.allocationType == GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA) {
|
||||
@@ -560,7 +561,8 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
|
||||
}
|
||||
|
||||
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForImage(const AllocationData &allocationData) {
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo, allocationData.storageInfo);
|
||||
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo,
|
||||
allocationData.storageInfo, allocationData.flags.preferRenderCompressed);
|
||||
|
||||
// AllocationData needs to be reconfigured for System Memory paths
|
||||
AllocationData allocationDataWithSize = allocationData;
|
||||
|
||||
@@ -229,7 +229,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedH
|
||||
graphicsAllocation->set32BitAllocation(requireSpecificBitness);
|
||||
|
||||
if (properties.imgInfo) {
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties));
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties), false);
|
||||
graphicsAllocation->setDefaultGmm(gmm);
|
||||
}
|
||||
|
||||
@@ -468,7 +468,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
|
||||
if (allocationData.type == GraphicsAllocation::AllocationType::IMAGE ||
|
||||
allocationData.type == GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY) {
|
||||
allocationData.imgInfo->useLocalMemory = true;
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo, allocationData.storageInfo);
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo,
|
||||
allocationData.storageInfo, allocationData.flags.preferRenderCompressed);
|
||||
sizeAligned64k = alignUp(allocationData.imgInfo->size, MemoryConstants::pageSize64k);
|
||||
} else {
|
||||
sizeAligned64k = alignUp(allocationData.size, MemoryConstants::pageSize64k);
|
||||
|
||||
@@ -684,7 +684,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
}
|
||||
}
|
||||
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties));
|
||||
Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo,
|
||||
createStorageInfoFromProperties(properties), properties.flags.preferCompressed);
|
||||
drmAllocation->setDefaultGmm(gmm);
|
||||
}
|
||||
return drmAllocation;
|
||||
@@ -1243,7 +1244,8 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
bool createSingleHandle = 1 == numHandles;
|
||||
if (allocationData.type == GraphicsAllocation::AllocationType::IMAGE) {
|
||||
allocationData.imgInfo->useLocalMemory = true;
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo, allocationData.storageInfo);
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo,
|
||||
allocationData.storageInfo, allocationData.flags.preferRenderCompressed);
|
||||
sizeAligned = alignUp(allocationData.imgInfo->size, MemoryConstants::pageSize64k);
|
||||
} else {
|
||||
if (allocationData.type == GraphicsAllocation::AllocationType::WRITE_COMBINED) {
|
||||
|
||||
@@ -969,7 +969,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
if (allocationData.type == GraphicsAllocation::AllocationType::IMAGE ||
|
||||
allocationData.type == GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY) {
|
||||
allocationData.imgInfo->useLocalMemory = true;
|
||||
gmm = std::make_unique<Gmm>(gmmClientContext, *allocationData.imgInfo, allocationData.storageInfo);
|
||||
gmm = std::make_unique<Gmm>(gmmClientContext, *allocationData.imgInfo, allocationData.storageInfo, allocationData.flags.preferRenderCompressed);
|
||||
alignment = MemoryConstants::pageSize64k;
|
||||
sizeAligned = allocationData.imgInfo->size;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user