mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Aux surface programming for Buffers [1/n]: Gmm interface improvement
Change-Id: I984b8ebee27808a236217e82bb4e910550d624c4
This commit is contained in:
committed by
sys_ocldev
parent
86565e5f06
commit
e26d67cde3
@@ -30,15 +30,46 @@
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
|
||||
namespace OCLRT {
|
||||
void Gmm::create() {
|
||||
Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable) {
|
||||
resourceParams.Type = RESOURCE_BUFFER;
|
||||
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
||||
resourceParams.BaseWidth = static_cast<uint32_t>(alignedSize);
|
||||
resourceParams.BaseHeight = 1;
|
||||
resourceParams.Depth = 1;
|
||||
if (!uncacheable) {
|
||||
resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
|
||||
} else {
|
||||
resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
|
||||
}
|
||||
resourceParams.Flags.Info.Linear = 1;
|
||||
resourceParams.Flags.Info.Cacheable = 1;
|
||||
resourceParams.Flags.Gpu.Texture = 1;
|
||||
|
||||
if (alignedPtr) {
|
||||
resourceParams.Flags.Info.ExistingSysMem = 1;
|
||||
resourceParams.pExistingSysMem = reinterpret_cast<GMM_VOIDPTR64>(alignedPtr);
|
||||
resourceParams.ExistingSysMemSize = alignedSize;
|
||||
}
|
||||
|
||||
if (resourceParams.BaseWidth >= GmmHelper::maxPossiblePitch) {
|
||||
resourceParams.Flags.Gpu.NoRestriction = 1;
|
||||
}
|
||||
|
||||
applyAuxFlagsForBuffer(false);
|
||||
|
||||
gmmResourceInfo.reset(GmmResourceInfo::create(&resourceParams));
|
||||
}
|
||||
|
||||
Gmm::Gmm(GMM_RESOURCE_INFO *inputGmm) {
|
||||
gmmResourceInfo.reset(GmmResourceInfo::create(inputGmm));
|
||||
}
|
||||
|
||||
Gmm::Gmm(ImageInfo &inputOutputImgInfo) {
|
||||
queryImageParams(inputOutputImgInfo);
|
||||
}
|
||||
|
||||
void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
||||
this->resourceParams = {};
|
||||
uint32_t imageWidth = static_cast<uint32_t>(imgInfo.imgDesc->image_width);
|
||||
uint32_t imageHeight = 1;
|
||||
uint32_t imageDepth = 1;
|
||||
@@ -90,7 +121,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
||||
this->resourceParams.Flags.Info.AllowVirtualPadding = true;
|
||||
}
|
||||
|
||||
applyAuxFlags(imgInfo);
|
||||
applyAuxFlagsForImage(imgInfo);
|
||||
|
||||
this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams));
|
||||
|
||||
@@ -144,7 +175,6 @@ void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
||||
}
|
||||
|
||||
imgInfo.qPitch = queryQPitch(this->resourceParams.Type);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t Gmm::queryQPitch(GMM_RESOURCE_TYPE resType) {
|
||||
|
||||
@@ -36,14 +36,18 @@ class GmmResourceInfo;
|
||||
class Gmm {
|
||||
public:
|
||||
virtual ~Gmm() = default;
|
||||
Gmm() = delete;
|
||||
Gmm(ImageInfo &inputOutputImgInfo);
|
||||
Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable);
|
||||
Gmm(GMM_RESOURCE_INFO *inputGmm);
|
||||
|
||||
void create();
|
||||
void queryImageParams(ImageInfo &imgInfo);
|
||||
void queryImageParams(ImageInfo &inputOutputImgInfo);
|
||||
|
||||
uint32_t getRenderHAlignment();
|
||||
uint32_t getRenderVAlignment();
|
||||
|
||||
void applyAuxFlags(ImageInfo &imgInfo);
|
||||
void applyAuxFlagsForImage(ImageInfo &imgInfo);
|
||||
void applyAuxFlagsForBuffer(bool preferRenderCompression);
|
||||
bool unifiedAuxTranslationCapable() const;
|
||||
|
||||
uint32_t queryQPitch(GMM_RESOURCE_TYPE resType);
|
||||
|
||||
@@ -73,46 +73,6 @@ uint32_t GmmHelper::getMOCS(uint32_t type) {
|
||||
return static_cast<uint32_t>(mocs.DwordValue);
|
||||
}
|
||||
|
||||
Gmm *GmmHelper::create(const void *alignedPtr, size_t alignedSize, bool uncacheable) {
|
||||
auto gmm = new Gmm();
|
||||
|
||||
gmm->resourceParams.Type = RESOURCE_BUFFER;
|
||||
gmm->resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
||||
gmm->resourceParams.BaseWidth = (uint32_t)alignedSize;
|
||||
gmm->resourceParams.BaseHeight = 1;
|
||||
gmm->resourceParams.Depth = 1;
|
||||
if (!uncacheable) {
|
||||
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
|
||||
} else {
|
||||
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
|
||||
}
|
||||
gmm->resourceParams.Flags.Info.Linear = 1;
|
||||
gmm->resourceParams.Flags.Info.Cacheable = 1;
|
||||
gmm->resourceParams.Flags.Gpu.Texture = 1;
|
||||
|
||||
if (alignedPtr != nullptr) {
|
||||
gmm->resourceParams.Flags.Info.ExistingSysMem = 1;
|
||||
gmm->resourceParams.pExistingSysMem = reinterpret_cast<GMM_VOIDPTR64>(alignedPtr);
|
||||
gmm->resourceParams.ExistingSysMemSize = alignedSize;
|
||||
}
|
||||
|
||||
gmm->create();
|
||||
|
||||
return gmm;
|
||||
}
|
||||
|
||||
Gmm *GmmHelper::create(GMM_RESOURCE_INFO *inputGmm) {
|
||||
auto gmm = new Gmm();
|
||||
gmm->gmmResourceInfo.reset(GmmResourceInfo::create(inputGmm));
|
||||
return gmm;
|
||||
}
|
||||
|
||||
Gmm *GmmHelper::createGmmAndQueryImgParams(ImageInfo &imgInfo) {
|
||||
Gmm *gmm = new Gmm();
|
||||
gmm->queryImageParams(imgInfo);
|
||||
return gmm;
|
||||
}
|
||||
|
||||
void GmmHelper::queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc) {
|
||||
// 1D or 2D from buffer
|
||||
if (imgInfo.imgDesc->image_row_pitch > 0) {
|
||||
|
||||
@@ -43,10 +43,6 @@ class GmmHelper {
|
||||
static constexpr uint32_t cacheEnabledIndex = 4;
|
||||
static constexpr uint32_t maxPossiblePitch = 2147483648;
|
||||
|
||||
static Gmm *createGmmAndQueryImgParams(ImageInfo &imgInfo);
|
||||
static Gmm *create(const void *alignedPtr, size_t alignedSize, bool uncacheable);
|
||||
static Gmm *create(GMM_RESOURCE_INFO *inputGmm);
|
||||
|
||||
static void loadLib();
|
||||
static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
||||
static void destroyContext();
|
||||
|
||||
@@ -24,5 +24,7 @@
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
|
||||
void OCLRT::Gmm::applyAuxFlags(ImageInfo &imgInfo) {
|
||||
}
|
||||
using namespace OCLRT;
|
||||
|
||||
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo) {}
|
||||
void Gmm::applyAuxFlagsForBuffer(bool preferRenderCompression) {}
|
||||
|
||||
Reference in New Issue
Block a user