mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
y-tiling interface cleanup
Change-Id: If7e5ab7135eaa71d9215c87c2fc46188ffd42b02 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
ba2233dc6a
commit
aeb84b3e20
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@@ -1,5 +1,5 @@
|
||||
#!groovy
|
||||
dependenciesRevision='4fee4f013463a310cef14e272ff8c5e432e8e69f-1301'
|
||||
strategy='EQUAL'
|
||||
allowedCD=263
|
||||
allowedCD=260
|
||||
allowedF=5
|
||||
|
||||
@@ -182,7 +182,7 @@ class VmeBuiltinDispatchInfoBuilder : public BuiltinDispatchInfoBuilder {
|
||||
return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR;
|
||||
}
|
||||
|
||||
if (false == img->isTiledImage) {
|
||||
if (false == img->isTiledAllocation()) {
|
||||
//VME only works with tiled images.
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@@ -97,23 +97,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
||||
imageCount = static_cast<uint32_t>(imgInfo.imgDesc->image_array_size);
|
||||
}
|
||||
|
||||
resourceParams.Flags.Info.Linear = 1;
|
||||
|
||||
switch (imgInfo.tilingMode) {
|
||||
case TilingMode::DEFAULT:
|
||||
if (GmmHelper::allowTiling(*imgInfo.imgDesc)) {
|
||||
resourceParams.Flags.Info.TiledY = 1;
|
||||
}
|
||||
break;
|
||||
case TilingMode::TILE_Y:
|
||||
resourceParams.Flags.Info.TiledY = 1;
|
||||
break;
|
||||
case TilingMode::NON_TILED:
|
||||
break;
|
||||
default:
|
||||
UNRECOVERABLE_IF(true);
|
||||
break;
|
||||
}
|
||||
resourceParams.Flags.Info.Linear = imgInfo.linearStorage;
|
||||
|
||||
auto &hwHelper = HwHelper::get(GmmHelper::getInstance()->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
|
||||
@@ -134,10 +118,6 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
||||
}
|
||||
|
||||
applyAuxFlagsForImage(imgInfo);
|
||||
if (!hwHelper.supportsYTiling() && resourceParams.Flags.Info.TiledY == 1) {
|
||||
resourceParams.Flags.Info.Linear = 0;
|
||||
resourceParams.Flags.Info.TiledY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "runtime/helpers/get_info.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "runtime/memory_manager/graphics_allocation.h"
|
||||
#include "runtime/os_interface/os_library.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
@@ -81,21 +82,11 @@ void GmmHelper::queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation
|
||||
}
|
||||
|
||||
bool GmmHelper::allowTiling(const cl_image_desc &imageDesc) {
|
||||
// consider returning tiling type instead of bool
|
||||
if (DebugManager.flags.ForceLinearImages.get()) {
|
||||
return false;
|
||||
} else {
|
||||
auto imageType = imageDesc.image_type;
|
||||
auto buffer = castToObject<Buffer>(imageDesc.buffer);
|
||||
|
||||
if (imageType == CL_MEM_OBJECT_IMAGE1D ||
|
||||
imageType == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
|
||||
imageType == CL_MEM_OBJECT_IMAGE1D_BUFFER ||
|
||||
((imageType == CL_MEM_OBJECT_IMAGE2D && imageDesc.buffer))) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (!(DebugManager.flags.ForceLinearImages.get() || imageType == CL_MEM_OBJECT_IMAGE1D ||
|
||||
imageType == CL_MEM_OBJECT_IMAGE1D_ARRAY || imageType == CL_MEM_OBJECT_IMAGE1D_BUFFER || buffer));
|
||||
}
|
||||
|
||||
uint64_t GmmHelper::canonize(uint64_t address) {
|
||||
|
||||
@@ -42,7 +42,6 @@ class HwHelper {
|
||||
virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0;
|
||||
virtual bool supportsYTiling() const = 0;
|
||||
virtual bool hvAlign4Required() const = 0;
|
||||
virtual bool obtainRenderBufferCompressionPreference(const size_t size) const = 0;
|
||||
virtual void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) = 0;
|
||||
@@ -129,8 +128,6 @@ class HwHelperHw : public HwHelper {
|
||||
|
||||
bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
bool supportsYTiling() const override;
|
||||
|
||||
bool hvAlign4Required() const override;
|
||||
|
||||
bool obtainRenderBufferCompressionPreference(const size_t size) const override;
|
||||
|
||||
@@ -35,11 +35,6 @@ bool HwHelperHw<GfxFamily>::isLocalMemoryEnabled(const HardwareInfo &hwInfo) con
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool HwHelperHw<GfxFamily>::supportsYTiling() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool HwHelperHw<GfxFamily>::hvAlign4Required() const {
|
||||
return true;
|
||||
|
||||
@@ -195,13 +195,6 @@ enum class OCLPlane {
|
||||
PLANE_UV
|
||||
};
|
||||
|
||||
enum class TilingMode {
|
||||
DEFAULT = 0,
|
||||
TILE_X = 1,
|
||||
TILE_Y = 2,
|
||||
NON_TILED
|
||||
};
|
||||
|
||||
struct SurfaceFormatInfo {
|
||||
cl_image_format OCLImageFormat;
|
||||
GMM_RESOURCE_FORMAT GMMSurfaceFormat;
|
||||
@@ -226,7 +219,7 @@ struct ImageInfo {
|
||||
GMM_YUV_PLANE_ENUM plane;
|
||||
uint32_t baseMipLevel;
|
||||
uint32_t mipCount;
|
||||
TilingMode tilingMode;
|
||||
bool linearStorage;
|
||||
bool preferRenderCompression;
|
||||
bool useLocalMemory;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,6 @@ Image::Image(Context *context,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
bool createTiledImage,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const SurfaceFormatInfo &surfaceFormatInfo,
|
||||
@@ -62,7 +61,6 @@ Image::Image(Context *context,
|
||||
false,
|
||||
isObjectRedescribed),
|
||||
createFunction(nullptr),
|
||||
isTiledImage(createTiledImage),
|
||||
imageFormat(std::move(imageFormat)),
|
||||
imageDesc(imageDesc),
|
||||
surfaceFormatInfo(surfaceFormatInfo),
|
||||
@@ -183,8 +181,8 @@ Image *Image::create(Context *context,
|
||||
auto hostPtrRowPitch = imageDesc->image_row_pitch ? imageDesc->image_row_pitch : imageWidth * surfaceFormat->ImageElementSizeInBytes;
|
||||
auto hostPtrSlicePitch = imageDesc->image_slice_pitch ? imageDesc->image_slice_pitch : hostPtrRowPitch * imageHeight;
|
||||
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
|
||||
auto isTilingAllowed = context->isSharedContext ? false : GmmHelper::allowTiling(*imageDesc) && !memoryProperties.forceLinearStorage;
|
||||
imgInfo.preferRenderCompression = MemObjHelper::isSuitableForRenderCompression(isTilingAllowed, memoryProperties,
|
||||
imgInfo.linearStorage = context->isSharedContext || !GmmHelper::allowTiling(*imageDesc) || memoryProperties.forceLinearStorage;
|
||||
imgInfo.preferRenderCompression = MemObjHelper::isSuitableForRenderCompression(!imgInfo.linearStorage, memoryProperties,
|
||||
context->peekContextType(), true);
|
||||
|
||||
switch (imageDesc->image_type) {
|
||||
@@ -247,7 +245,6 @@ Image *Image::create(Context *context,
|
||||
} else if (parentImage != nullptr) {
|
||||
memory = parentImage->getGraphicsAllocation();
|
||||
memory->getDefaultGmm()->queryImageParams(imgInfo);
|
||||
isTilingAllowed = parentImage->allowTiling();
|
||||
} else {
|
||||
errcodeRet = CL_OUT_OF_HOST_MEMORY;
|
||||
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) {
|
||||
@@ -316,7 +313,7 @@ Image *Image::create(Context *context,
|
||||
}
|
||||
|
||||
image = createImageHw(context, properties, imgInfo.size, hostPtrToSet, surfaceFormat->OCLImageFormat,
|
||||
imageDescriptor, zeroCopy, memory, false, isTilingAllowed, 0, 0, surfaceFormat);
|
||||
imageDescriptor, zeroCopy, memory, false, 0, 0, surfaceFormat);
|
||||
|
||||
if (context->isProvidingPerformanceHints() && HwHelper::renderCompressedImagesSupported(context->getDevice(0)->getHardwareInfo())) {
|
||||
if (memory->getDefaultGmm()) {
|
||||
@@ -365,7 +362,7 @@ Image *Image::create(Context *context,
|
||||
copyRegion = {{imageWidth, imageHeight, std::max(imageDepth, imageCount)}};
|
||||
}
|
||||
|
||||
if (isTilingAllowed || !MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) {
|
||||
if (!imgInfo.linearStorage || !MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) {
|
||||
auto cmdQ = context->getSpecialQueue();
|
||||
|
||||
if (IsNV12Image(&image->getImageFormat())) {
|
||||
@@ -398,7 +395,7 @@ Image *Image::create(Context *context,
|
||||
Image *Image::createImageHw(Context *context, const MemoryProperties &properties, size_t size, void *hostPtr,
|
||||
const cl_image_format &imageFormat, const cl_image_desc &imageDesc,
|
||||
bool zeroCopy, GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed, bool createTiledImage, uint32_t baseMipLevel, uint32_t mipCount,
|
||||
bool isObjectRedescribed, uint32_t baseMipLevel, uint32_t mipCount,
|
||||
const SurfaceFormatInfo *surfaceFormatInfo) {
|
||||
const auto device = context->getDevice(0);
|
||||
const auto &hwInfo = device->getHardwareInfo();
|
||||
@@ -406,7 +403,7 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &properties
|
||||
auto funcCreate = imageFactory[hwInfo.platform.eRenderCoreFamily].createImageFunction;
|
||||
DEBUG_BREAK_IF(nullptr == funcCreate);
|
||||
auto image = funcCreate(context, properties, size, hostPtr, imageFormat, imageDesc,
|
||||
zeroCopy, graphicsAllocation, isObjectRedescribed, createTiledImage, baseMipLevel, mipCount, surfaceFormatInfo, nullptr);
|
||||
zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr);
|
||||
DEBUG_BREAK_IF(nullptr == image);
|
||||
image->createFunction = funcCreate;
|
||||
return image;
|
||||
@@ -415,10 +412,8 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &properties
|
||||
Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler, McsSurfaceInfo &mcsSurfaceInfo,
|
||||
GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
cl_mem_flags flags, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) {
|
||||
bool isTiledImage = graphicsAllocation->getDefaultGmm()->gmmResourceInfo->getTileModeSurfaceState() != 0;
|
||||
|
||||
auto sharedImage = createImageHw(context, flags, graphicsAllocation->getUnderlyingBufferSize(),
|
||||
nullptr, imgInfo.surfaceFormat->OCLImageFormat, *imgInfo.imgDesc, false, graphicsAllocation, false, isTiledImage, baseMipLevel, mipCount, imgInfo.surfaceFormat);
|
||||
nullptr, imgInfo.surfaceFormat->OCLImageFormat, *imgInfo.imgDesc, false, graphicsAllocation, false, baseMipLevel, mipCount, imgInfo.surfaceFormat);
|
||||
sharedImage->setSharingHandler(sharingHandler);
|
||||
sharedImage->setMcsAllocation(mcsAllocation);
|
||||
sharedImage->setQPitch(imgInfo.qPitch);
|
||||
@@ -715,7 +710,7 @@ bool Image::isCopyRequired(ImageInfo &imgInfo, const void *hostPtr) {
|
||||
|
||||
auto hostPtrRowPitch = imgInfo.imgDesc->image_row_pitch ? imgInfo.imgDesc->image_row_pitch : imageWidth * imgInfo.surfaceFormat->ImageElementSizeInBytes;
|
||||
auto hostPtrSlicePitch = imgInfo.imgDesc->image_slice_pitch ? imgInfo.imgDesc->image_slice_pitch : hostPtrRowPitch * imgInfo.imgDesc->image_height;
|
||||
auto isTilingAllowed = GmmHelper::allowTiling(*imgInfo.imgDesc);
|
||||
auto isTilingAllowed = GmmHelper::allowTiling(*imgInfo.imgDesc) && !imgInfo.linearStorage;
|
||||
|
||||
size_t pointerPassedSize = hostPtrRowPitch * imageHeight * imageDepth * imageCount;
|
||||
auto alignedSizePassedPointer = alignSizeWholePage(const_cast<void *>(hostPtr), pointerPassedSize);
|
||||
@@ -865,7 +860,6 @@ Image *Image::redescribeFillImage() {
|
||||
this->isMemObjZeroCopy(),
|
||||
this->getGraphicsAllocation(),
|
||||
true,
|
||||
isTiledImage,
|
||||
this->baseMipLevel,
|
||||
this->mipCount,
|
||||
surfaceFormat,
|
||||
@@ -913,7 +907,6 @@ Image *Image::redescribe() {
|
||||
this->isMemObjZeroCopy(),
|
||||
this->getGraphicsAllocation(),
|
||||
true,
|
||||
isTiledImage,
|
||||
this->baseMipLevel,
|
||||
this->mipCount,
|
||||
surfaceFormat,
|
||||
|
||||
@@ -33,7 +33,6 @@ typedef Image *(*ImageCreatFunc)(Context *context,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
bool isImageRedescribed,
|
||||
bool createTiledImage,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const SurfaceFormatInfo *surfaceFormatInfo,
|
||||
@@ -67,7 +66,7 @@ class Image : public MemObj {
|
||||
static Image *createImageHw(Context *context, const MemoryProperties &properties, size_t size, void *hostPtr,
|
||||
const cl_image_format &imageFormat, const cl_image_desc &imageDesc,
|
||||
bool zeroCopy, GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed, bool createTiledImage, uint32_t baseMipLevel, uint32_t mipCount, const SurfaceFormatInfo *surfaceFormatInfo = nullptr);
|
||||
bool isObjectRedescribed, uint32_t baseMipLevel, uint32_t mipCount, const SurfaceFormatInfo *surfaceFormatInfo = nullptr);
|
||||
|
||||
static Image *createSharedImage(Context *context, SharingHandler *sharingHandler, McsSurfaceInfo &mcsSurfaceInfo,
|
||||
GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
@@ -141,7 +140,6 @@ class Image : public MemObj {
|
||||
void setHostPtrSlicePitch(size_t pitch) { this->hostPtrSlicePitch = pitch; }
|
||||
size_t getImageCount() const { return imageCount; }
|
||||
void setImageCount(size_t imageCount) { this->imageCount = imageCount; }
|
||||
bool allowTiling() const override { return this->isTiledImage; }
|
||||
void setImageRowPitch(size_t rowPitch) { imageDesc.image_row_pitch = rowPitch; }
|
||||
void setImageSlicePitch(size_t slicePitch) { imageDesc.image_slice_pitch = slicePitch; }
|
||||
void setSurfaceOffsets(uint64_t offset, uint32_t xOffset, uint32_t yOffset, uint32_t yOffsetForUVPlane) {
|
||||
@@ -173,8 +171,6 @@ class Image : public MemObj {
|
||||
virtual void transformImage2dArrayTo3d(void *memory) = 0;
|
||||
virtual void transformImage3dTo2dArray(void *memory) = 0;
|
||||
|
||||
const bool isTiledImage;
|
||||
|
||||
bool hasSameDescriptor(const cl_image_desc &imageDesc) const;
|
||||
bool hasValidParentImageFormat(const cl_image_format &imageFormat) const;
|
||||
|
||||
@@ -191,7 +187,6 @@ class Image : public MemObj {
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
bool createTiledImage,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const SurfaceFormatInfo &surfaceFormatInfo,
|
||||
@@ -246,13 +241,12 @@ class ImageHw : public Image {
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
bool createTiledImage,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const SurfaceFormatInfo &surfaceFormatInfo,
|
||||
const SurfaceOffsets *surfaceOffsets = nullptr)
|
||||
: Image(context, properties, size, hostPtr, imageFormat, imageDesc,
|
||||
zeroCopy, graphicsAllocation, isObjectRedescribed, createTiledImage, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) {
|
||||
zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) {
|
||||
if (getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D ||
|
||||
getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER ||
|
||||
getImageDesc().image_type == CL_MEM_OBJECT_IMAGE2D ||
|
||||
@@ -260,6 +254,22 @@ class ImageHw : public Image {
|
||||
getImageDesc().image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
|
||||
this->imageDesc.image_depth = 0;
|
||||
}
|
||||
|
||||
switch (imageDesc.image_type) {
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_1D;
|
||||
break;
|
||||
default:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_2D;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_3D;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setImageArg(void *memory, bool setAsMediaBlockImage, uint32_t mipLevel) override;
|
||||
@@ -283,13 +293,12 @@ class ImageHw : public Image {
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
bool createTiledImage,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const SurfaceFormatInfo *surfaceFormatInfo,
|
||||
const SurfaceOffsets *surfaceOffsets) {
|
||||
UNRECOVERABLE_IF(surfaceFormatInfo == nullptr);
|
||||
auto image = new ImageHw<GfxFamily>(context,
|
||||
return new ImageHw<GfxFamily>(context,
|
||||
properties,
|
||||
size,
|
||||
hostPtr,
|
||||
@@ -298,28 +307,10 @@ class ImageHw : public Image {
|
||||
zeroCopy,
|
||||
graphicsAllocation,
|
||||
isObjectRedescribed,
|
||||
createTiledImage,
|
||||
baseMipLevel,
|
||||
mipCount,
|
||||
*surfaceFormatInfo,
|
||||
surfaceOffsets);
|
||||
|
||||
switch (imageDesc.image_type) {
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
image->surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_1D;
|
||||
break;
|
||||
default:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
image->surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_2D;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
image->surfaceType = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_3D;
|
||||
break;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
static int getShaderChannelValue(int inputShaderChannel, cl_channel_order imageChannelOrder) {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
#include "runtime/helpers/get_info.h"
|
||||
#include "runtime/memory_manager/deferred_deleter.h"
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
@@ -344,8 +345,13 @@ bool MemObj::addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags,
|
||||
mipLevel);
|
||||
}
|
||||
|
||||
bool MemObj::isTiledAllocation() const {
|
||||
auto gmm = graphicsAllocation->getDefaultGmm();
|
||||
return gmm && (gmm->gmmResourceInfo->getTileModeSurfaceState() != 0);
|
||||
}
|
||||
|
||||
bool MemObj::mappingOnCpuAllowed() const {
|
||||
return !allowTiling() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() &&
|
||||
return !isTiledAllocation() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() &&
|
||||
!(graphicsAllocation->getDefaultGmm() && graphicsAllocation->getDefaultGmm()->isRenderCompressed) &&
|
||||
MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class MemObj : public BaseObject<_cl_mem> {
|
||||
bool writeMemObjFlagsInvalid();
|
||||
bool mapMemObjFlagsInvalid(cl_map_flags mapFlags);
|
||||
|
||||
virtual bool allowTiling() const { return false; }
|
||||
MOCKABLE_VIRTUAL bool isTiledAllocation() const;
|
||||
|
||||
void *getCpuAddressForMapping();
|
||||
void *getCpuAddressForMemoryTransfer();
|
||||
|
||||
@@ -270,7 +270,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage) {
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) {
|
||||
GraphicsAllocation *alloc = nullptr;
|
||||
|
||||
if (!GmmHelper::allowTiling(*allocationData.imgInfo->imgDesc) && allocationData.imgInfo->mipCount == 0) {
|
||||
if (allocationData.imgInfo->linearStorage && allocationData.imgInfo->mipCount == 0) {
|
||||
alloc = allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
alloc->setDefaultGmm(gmm.release());
|
||||
return alloc;
|
||||
|
||||
@@ -54,7 +54,6 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tiling_mode_helper.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
#include "runtime/os_interface/linux/os_context_linux.h"
|
||||
#include "runtime/os_interface/linux/os_interface.h"
|
||||
#include "runtime/os_interface/linux/tiling_mode_helper.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
@@ -264,7 +263,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(const AllocationData
|
||||
}
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) {
|
||||
if (!GmmHelper::allowTiling(*allocationData.imgInfo->imgDesc)) {
|
||||
if (allocationData.imgInfo->linearStorage) {
|
||||
auto alloc = allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
if (alloc) {
|
||||
alloc->setDefaultGmm(gmm.release());
|
||||
@@ -443,7 +442,10 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
DEBUG_BREAK_IF(ret != 0);
|
||||
((void)(ret));
|
||||
|
||||
properties.imgInfo->tilingMode = TilingModeHelper::convert(getTiling.tiling_mode);
|
||||
if (getTiling.tiling_mode == I915_TILING_NONE) {
|
||||
properties.imgInfo->linearStorage = true;
|
||||
}
|
||||
|
||||
Gmm *gmm = new Gmm(*properties.imgInfo, createStorageInfoFromProperties(properties));
|
||||
drmAllocation->setDefaultGmm(gmm);
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct TilingModeHelper {
|
||||
static TilingMode convert(uint32_t i915TilingMode) {
|
||||
switch (i915TilingMode) {
|
||||
case I915_TILING_X:
|
||||
return TilingMode::TILE_X;
|
||||
case I915_TILING_Y:
|
||||
return TilingMode::TILE_Y;
|
||||
case I915_TILING_NONE:
|
||||
default:
|
||||
return TilingMode::NON_TILED;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
@@ -49,7 +49,7 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment)
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) {
|
||||
if (!GmmHelper::allowTiling(*allocationData.imgInfo->imgDesc) && allocationData.imgInfo->mipCount == 0) {
|
||||
if (allocationData.imgInfo->linearStorage && allocationData.imgInfo->mipCount == 0) {
|
||||
return allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ HWTEST_F(MediaImageSetArgTest, clSetKernelArgImage) {
|
||||
|
||||
typename FamilyType::MEDIA_SURFACE_STATE::TILE_MODE tileMode;
|
||||
|
||||
if (srcImage->allowTiling()) {
|
||||
if (srcImage->isTiledAllocation()) {
|
||||
tileMode = FamilyType::MEDIA_SURFACE_STATE::TILE_MODE_TILEMODE_YMAJOR;
|
||||
} else {
|
||||
tileMode = FamilyType::MEDIA_SURFACE_STATE::TILE_MODE_TILEMODE_LINEAR;
|
||||
|
||||
@@ -148,7 +148,7 @@ HWTEST_P(AUBMapImage, MapUpdateUnmapVerify) {
|
||||
uint8_t *mappedPtrStart;
|
||||
uint8_t *srcMemoryStart;
|
||||
|
||||
if (srcImage->allowTiling()) {
|
||||
if (srcImage->isTiledAllocation()) {
|
||||
mappedPtrStart = static_cast<uint8_t *>(mappedPtr);
|
||||
srcMemoryStart = srcMemory;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ HWTEST_P(AUBReadImage, simpleUnalignedMemory) {
|
||||
|
||||
auto imageMemory = srcMemory;
|
||||
|
||||
if (!srcImage->isMemObjZeroCopy() && !srcImage->allowTiling()) {
|
||||
if (!srcImage->isMemObjZeroCopy() && !srcImage->isTiledAllocation()) {
|
||||
imageMemory = (uint8_t *)(srcImage->getCpuAddress());
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ HWTEST_P(AUBCreateImageArray, CheckArrayImages) {
|
||||
cl_mem_flags flags = CL_MEM_COPY_HOST_PTR;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat);
|
||||
auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat);
|
||||
imgInfo.linearStorage = !GmmHelper::allowTiling(imageDesc);
|
||||
auto queryGmm = MockGmm::queryImgParams(imgInfo);
|
||||
|
||||
//allocate host_ptr
|
||||
@@ -238,7 +239,7 @@ HWTEST_P(AUBCreateImageHostPtr, imageWithDoubledRowPitchThatIsCreatedWithCopyHos
|
||||
data = (char *)pHostPtr;
|
||||
|
||||
uint8_t *readMemory = nullptr;
|
||||
if (image->allowTiling()) {
|
||||
if (image->isTiledAllocation()) {
|
||||
readMemory = new uint8_t[testImageDimensions * testImageDimensions * elementSize * 4];
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_depth ? imageDesc.image_depth : 1};
|
||||
@@ -251,7 +252,7 @@ HWTEST_P(AUBCreateImageHostPtr, imageWithDoubledRowPitchThatIsCreatedWithCopyHos
|
||||
|
||||
while (heightToCopy--) {
|
||||
for (unsigned int i = 0; i < imageDesc.image_width * elementSize; i++) {
|
||||
if (image->allowTiling()) {
|
||||
if (image->isTiledAllocation()) {
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(&imageStorage[i], &data[i], 1);
|
||||
} else {
|
||||
EXPECT_EQ(imageStorage[i], data[i]);
|
||||
@@ -351,7 +352,7 @@ HWTEST_P(AUBCreateImageHostPtr, imageWithRowPitchCreatedWithUseHostPtrFlagCopied
|
||||
|
||||
while (heightToCopy--) {
|
||||
for (unsigned int i = 0; i < imageDesc.image_width * elementSize; i++) {
|
||||
if (image->allowTiling()) {
|
||||
if (image->isTiledAllocation()) {
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(&imageStorage[i], &data[i], 1);
|
||||
} else {
|
||||
EXPECT_EQ(imageStorage[i], data[i]);
|
||||
@@ -401,7 +402,7 @@ HWTEST_F(AUBCreateImage, image3DCreatedWithDoubledSlicePitchWhenQueriedForDataRe
|
||||
data = (char *)host_ptr;
|
||||
|
||||
uint8_t *readMemory = nullptr;
|
||||
if (image->allowTiling()) {
|
||||
if (image->isTiledAllocation()) {
|
||||
readMemory = new uint8_t[imageSize];
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_depth};
|
||||
@@ -414,7 +415,7 @@ HWTEST_F(AUBCreateImage, image3DCreatedWithDoubledSlicePitchWhenQueriedForDataRe
|
||||
|
||||
while (depthToCopy--) {
|
||||
for (unsigned int i = 0; i < imageDesc.image_width * 4 * imageDesc.image_height; i++) {
|
||||
if (image->allowTiling()) {
|
||||
if (image->isTiledAllocation()) {
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(&imageStorage[i], &data[i], 1);
|
||||
} else {
|
||||
EXPECT_EQ(imageStorage[i], data[i]);
|
||||
|
||||
@@ -53,9 +53,6 @@ struct EnqueueMapImageParamsTest : public EnqueueMapImageTest,
|
||||
};
|
||||
|
||||
TEST_F(EnqueueMapImageTest, reuseMappedPtrForTiledImg) {
|
||||
if (!image->allowTiling()) {
|
||||
return;
|
||||
}
|
||||
auto mapFlags = CL_MAP_READ;
|
||||
const size_t origin[3] = {0, 0, 0};
|
||||
const size_t region[3] = {1, 1, 1};
|
||||
@@ -199,7 +196,6 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe
|
||||
false,
|
||||
graphicsAllocation,
|
||||
true,
|
||||
true,
|
||||
0,
|
||||
0,
|
||||
surfaceFormatInfo,
|
||||
@@ -552,7 +548,7 @@ TEST_F(EnqueueMapImageTest, GivenNonZeroCopyImageWhenMappedWithOffsetThenCorrect
|
||||
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
if (!image->allowTiling()) {
|
||||
if (!image->isTiledAllocation()) {
|
||||
EXPECT_EQ(HostPtrOffseted, ptr); // Returned pointer should be offseted
|
||||
}
|
||||
|
||||
@@ -575,7 +571,7 @@ HWTEST_F(EnqueueMapImageTest, givenSharingHandlerWhenNonReadOnlyMapAndUnmapOnNon
|
||||
std::unique_ptr<Image> image(ImageHelper<ImageUseHostPtr<Image1dDefaults>>::create(context));
|
||||
ASSERT_NE(nullptr, image);
|
||||
image->setSharingHandler(new SharingHandler());
|
||||
EXPECT_FALSE(image->allowTiling());
|
||||
EXPECT_FALSE(image->isTiledAllocation());
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
csr.taskCount = 1;
|
||||
@@ -600,7 +596,7 @@ HWTEST_F(EnqueueMapImageTest, givenSharingHandlerWhenReadOnlyMapAndUnmapOnNonTil
|
||||
std::unique_ptr<Image> image(ImageHelper<ImageUseHostPtr<Image1dDefaults>>::create(context));
|
||||
ASSERT_NE(nullptr, image);
|
||||
image->setSharingHandler(new SharingHandler());
|
||||
EXPECT_FALSE(image->allowTiling());
|
||||
EXPECT_FALSE(image->isTiledAllocation());
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
csr.taskCount = 1;
|
||||
@@ -910,7 +906,7 @@ TEST_F(EnqueueMapImageTest, givenImage1DArrayWhenEnqueueMapImageIsCalledThenRetu
|
||||
imageFormat, imageDesc,
|
||||
true,
|
||||
allocation,
|
||||
false, false, 0, 0,
|
||||
false, 0, 0,
|
||||
surfaceFormat, nullptr) {
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,34 @@
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
#include "unit_tests/helpers/variable_backup.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
|
||||
using namespace NEO;
|
||||
namespace NEO {
|
||||
extern ImageFuncs imageFactory[IGFX_MAX_CORE];
|
||||
|
||||
struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test {
|
||||
template <typename T>
|
||||
struct MockImage : public ImageHw<T> {
|
||||
using Image::mapOperationsHandler;
|
||||
using ImageHw<T>::isZeroCopy;
|
||||
using ImageHw<T>::ImageHw;
|
||||
|
||||
template <class... Params>
|
||||
MockImage(Params... params) : ImageHw<T>(params...) {
|
||||
this->createFunction = ImageHw<T>::create;
|
||||
static Image *createMockImage(Context *context,
|
||||
const MemoryProperties &properties,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
const cl_image_format &imageFormat,
|
||||
const cl_image_desc &imageDesc,
|
||||
bool zeroCopy,
|
||||
GraphicsAllocation *graphicsAllocation,
|
||||
bool isObjectRedescribed,
|
||||
uint32_t baseMipLevel,
|
||||
uint32_t mipCount,
|
||||
const SurfaceFormatInfo *surfaceFormatInfo,
|
||||
const SurfaceOffsets *surfaceOffsets) {
|
||||
return new MockImage<T>(context, properties, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation,
|
||||
isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets);
|
||||
};
|
||||
|
||||
void transferDataToHostPtr(MemObjSizeArray ©Size, MemObjOffsetArray ©Offset) override {
|
||||
@@ -88,14 +104,18 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test {
|
||||
|
||||
template <typename Traits, typename FamilyType>
|
||||
std::unique_ptr<MockImage<FamilyType>> createMockImage() {
|
||||
auto allocationSize = Traits::imageDesc.image_width * 4 * Traits::imageDesc.image_height * Traits::imageDesc.image_depth;
|
||||
auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{allocationSize});
|
||||
auto tiledImage = GmmHelper::allowTiling(Traits::imageDesc);
|
||||
auto eRenderCoreFamily = pDevice->getExecutionEnvironment()->getHardwareInfo()->platform.eRenderCoreFamily;
|
||||
|
||||
VariableBackup<ImageCreatFunc> backup(&imageFactory[eRenderCoreFamily].createImageFunction);
|
||||
imageFactory[eRenderCoreFamily].createImageFunction = MockImage<FamilyType>::createMockImage;
|
||||
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(Traits::flags, &Traits::imageFormat);
|
||||
auto img = new MockImage<FamilyType>(context, Traits::flags, allocationSize, Traits::hostPtr, Traits::imageFormat,
|
||||
Traits::imageDesc, false, mockAlloc, false, tiledImage, 0, 0, *surfaceFormat);
|
||||
return std::unique_ptr<MockImage<FamilyType>>(img);
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto img = Image::create(context, Traits::flags, surfaceFormat, &Traits::imageDesc, Traits::hostPtr, retVal);
|
||||
auto mockImage = static_cast<MockImage<FamilyType> *>(img);
|
||||
|
||||
return std::unique_ptr<MockImage<FamilyType>>(mockImage);
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
@@ -204,6 +224,7 @@ HWTEST_F(MultipleMapImageTest, givenErrorFromWriteImageWhenUnmappedOnGpuThenDont
|
||||
HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedPtrAndRemoveOnUnmap) {
|
||||
auto image = createMockImage<Image1dDefaults, FamilyType>();
|
||||
auto cmdQ = createMockCmdQ<FamilyType>();
|
||||
image->isZeroCopy = false;
|
||||
EXPECT_TRUE(image->mappingOnCpuAllowed());
|
||||
|
||||
MemObjOffsetArray origin = {{1, 0, 0}};
|
||||
@@ -225,6 +246,8 @@ HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedPt
|
||||
HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenReadOnlyMappedOnCpuThenDontMakeCpuCopy) {
|
||||
auto image = createMockImage<Image1dDefaults, FamilyType>();
|
||||
auto cmdQ = createMockCmdQ<FamilyType>();
|
||||
image->isZeroCopy = false;
|
||||
|
||||
EXPECT_TRUE(image->mappingOnCpuAllowed());
|
||||
|
||||
MemObjOffsetArray origin = {{1, 0, 0}};
|
||||
@@ -244,6 +267,8 @@ HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenReadOnlyMappedOnCpuThenDon
|
||||
HWTEST_F(MultipleMapImageTest, givenBlockedQueueWhenMappedOnCpuThenAddMappedPtrAndRemoveOnUnmap) {
|
||||
auto image = createMockImage<Image1dDefaults, FamilyType>();
|
||||
auto cmdQ = createMockCmdQ<FamilyType>();
|
||||
image->isZeroCopy = false;
|
||||
|
||||
EXPECT_TRUE(image->mappingOnCpuAllowed());
|
||||
|
||||
UserEvent mapEvent, unmapEvent;
|
||||
@@ -271,6 +296,8 @@ HWTEST_F(MultipleMapImageTest, givenBlockedQueueWhenMappedOnCpuThenAddMappedPtrA
|
||||
HWTEST_F(MultipleMapImageTest, givenBlockedQueueWhenMappedReadOnlyOnCpuThenDontMakeCpuCopy) {
|
||||
auto image = createMockImage<Image1dDefaults, FamilyType>();
|
||||
auto cmdQ = createMockCmdQ<FamilyType>();
|
||||
image->isZeroCopy = false;
|
||||
|
||||
EXPECT_TRUE(image->mappingOnCpuAllowed());
|
||||
|
||||
UserEvent mapEvent, unmapEvent;
|
||||
@@ -376,3 +403,4 @@ HWTEST_F(MultipleMapImageTest, givenOverlapingPtrWhenMappingOnCpuForWriteThenRet
|
||||
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
|
||||
EXPECT_EQ(1u, image->mapOperationsHandler.size());
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "unit_tests/helpers/variable_backup.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
@@ -239,41 +240,6 @@ TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedAndPitc
|
||||
EXPECT_EQ(imgDesc.image_row_pitch, queryGmm->gmmResourceInfo->getRenderPitch());
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenTilableImageWhenEnableForceLinearImagesThenYTilingIsDisabled) {
|
||||
DebugManagerStateRestore debugStateBackup;
|
||||
cl_image_desc imgDesc{};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
|
||||
imgDesc.image_width = 17;
|
||||
imgDesc.image_height = 17;
|
||||
imgDesc.image_depth = 17;
|
||||
|
||||
DebugManager.flags.ForceLinearImages.set(false);
|
||||
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
|
||||
auto queryGmm = MockGmm::queryImgParams(imgInfo);
|
||||
|
||||
auto &hwHelper = HwHelper::get(GmmHelper::getInstance()->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
bool supportsYTiling = hwHelper.supportsYTiling();
|
||||
|
||||
if (!supportsYTiling) {
|
||||
EXPECT_EQ(queryGmm->resourceParams.Flags.Info.Linear, 0u);
|
||||
EXPECT_EQ(queryGmm->resourceParams.Flags.Info.TiledY, 0u);
|
||||
} else {
|
||||
EXPECT_EQ(queryGmm->resourceParams.Flags.Info.Linear, 1u);
|
||||
EXPECT_EQ(queryGmm->resourceParams.Flags.Info.TiledY, 1u);
|
||||
}
|
||||
|
||||
DebugManager.flags.ForceLinearImages.set(true);
|
||||
|
||||
delete queryGmm.get();
|
||||
queryGmm.release();
|
||||
queryGmm = MockGmm::queryImgParams(imgInfo);
|
||||
|
||||
EXPECT_EQ(queryGmm->resourceParams.Flags.Info.Linear, 1u);
|
||||
EXPECT_EQ(queryGmm->resourceParams.Flags.Info.TiledY, 0u);
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenPlanarFormatsWhenQueryingImageParamsThenUVOffsetIsQueried) {
|
||||
cl_image_desc imgDesc{};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
@@ -305,19 +271,11 @@ TEST_F(GmmTests, givenTilingModeSetToTileYWhenHwSupportsTilingThenTileYFlagIsSet
|
||||
imgDesc.image_depth = 1;
|
||||
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
imgInfo.tilingMode = TilingMode::TILE_Y;
|
||||
imgInfo.linearStorage = false;
|
||||
auto gmm = std::make_unique<Gmm>(imgInfo, StorageInfo{});
|
||||
|
||||
auto &hwHelper = HwHelper::get(GmmHelper::getInstance()->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
bool supportsYTiling = hwHelper.supportsYTiling();
|
||||
|
||||
if (!supportsYTiling) {
|
||||
EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 0u);
|
||||
EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u);
|
||||
} else {
|
||||
EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 1u);
|
||||
EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 1u);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenTilingModeSetToNonTiledWhenCreatingGmmThenLinearFlagIsSet) {
|
||||
@@ -328,26 +286,13 @@ TEST_F(GmmTests, givenTilingModeSetToNonTiledWhenCreatingGmmThenLinearFlagIsSet)
|
||||
imgDesc.image_depth = 1;
|
||||
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
imgInfo.tilingMode = TilingMode::NON_TILED;
|
||||
imgInfo.linearStorage = true;
|
||||
auto gmm = std::make_unique<Gmm>(imgInfo, StorageInfo{});
|
||||
|
||||
EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 1u);
|
||||
EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u);
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenTilingModeSetToTileXWhenCreatingGmmThenUnrecoverableIfIsCalled) {
|
||||
cl_image_desc imgDesc{};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgDesc.image_width = 4;
|
||||
imgDesc.image_height = 4;
|
||||
imgDesc.image_depth = 1;
|
||||
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
imgInfo.tilingMode = TilingMode::TILE_X;
|
||||
|
||||
EXPECT_THROW(new Gmm(imgInfo, {}), std::exception);
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenZeroRowPitchWhenQueryImgFromBufferParamsThenCalculate) {
|
||||
MockGraphicsAllocation bufferAllocation(nullptr, 4096);
|
||||
|
||||
@@ -534,8 +479,12 @@ TEST_P(GmmImgFromBufferTilingTests, disallowImgFromBufferTiling) {
|
||||
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = GetParam();
|
||||
_cl_mem clMem = {};
|
||||
imgDesc.buffer = &clMem;
|
||||
|
||||
MockContext context;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
|
||||
auto buffer = std::unique_ptr<Buffer>(Buffer::create(&context, {}, 1, nullptr, retVal));
|
||||
imgDesc.buffer = buffer.get();
|
||||
|
||||
checkTiling(imgDesc, false);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ TEST_F(Image2dFromBufferTest, CreateImage2dFromBuffer) {
|
||||
EXPECT_EQ(2, buffer->getRefInternalCount());
|
||||
EXPECT_NE(nullptr, imageFromBuffer);
|
||||
|
||||
EXPECT_FALSE(imageFromBuffer->allowTiling());
|
||||
EXPECT_FALSE(imageFromBuffer->isTiledAllocation());
|
||||
EXPECT_EQ(imageFromBuffer->getCubeFaceIndex(), static_cast<uint32_t>(__GMM_NO_CUBE_MAP));
|
||||
|
||||
delete imageFromBuffer;
|
||||
|
||||
@@ -393,7 +393,7 @@ TEST(TestCreateImageUseHostPtr, CheckMemoryAllocationForDifferenHostPtrAlignment
|
||||
ASSERT_NE(nullptr, image);
|
||||
|
||||
auto address = image->getCpuAddress();
|
||||
if (result[i] && !image->allowTiling()) {
|
||||
if (result[i] && !image->isTiledAllocation()) {
|
||||
EXPECT_EQ(hostPtr[i], address);
|
||||
} else {
|
||||
EXPECT_NE(hostPtr[i], address);
|
||||
@@ -579,7 +579,7 @@ TEST_P(CreateImageHostPtr, getAddress) {
|
||||
EXPECT_NE(pHostPtr, address);
|
||||
}
|
||||
|
||||
if (flags & CL_MEM_COPY_HOST_PTR && !image->allowTiling()) {
|
||||
if (flags & CL_MEM_COPY_HOST_PTR && !image->isTiledAllocation()) {
|
||||
// Buffer should contain a copy of host memory
|
||||
EXPECT_EQ(0, memcmp(pHostPtr, address, sizeof(testImageDimensions)));
|
||||
}
|
||||
@@ -923,7 +923,7 @@ TEST_F(ImageCompressionTests, givenTiledImageWhenCreatingAllocationThenPreferRen
|
||||
|
||||
auto image = std::unique_ptr<Image>(Image::create(mockContext.get(), flags, surfaceFormat, &imageDesc, nullptr, retVal));
|
||||
ASSERT_NE(nullptr, image);
|
||||
EXPECT_TRUE(image->isTiledImage);
|
||||
EXPECT_TRUE(image->isTiledAllocation());
|
||||
EXPECT_TRUE(myMemoryManager->mockMethodCalled);
|
||||
EXPECT_TRUE(myMemoryManager->capturedImgInfo.preferRenderCompression);
|
||||
}
|
||||
@@ -936,7 +936,7 @@ TEST_F(ImageCompressionTests, givenNonTiledImageWhenCreatingAllocationThenDontPr
|
||||
|
||||
auto image = std::unique_ptr<Image>(Image::create(mockContext.get(), flags, surfaceFormat, &imageDesc, nullptr, retVal));
|
||||
ASSERT_NE(nullptr, image);
|
||||
EXPECT_FALSE(image->isTiledImage);
|
||||
EXPECT_FALSE(image->isTiledAllocation());
|
||||
EXPECT_TRUE(myMemoryManager->mockMethodCalled);
|
||||
EXPECT_FALSE(myMemoryManager->capturedImgInfo.preferRenderCompression);
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ TEST(ImageTest, givenClMemForceLinearStorageSetWhenCreateImageThenDisallowTiling
|
||||
nullptr,
|
||||
retVal));
|
||||
|
||||
EXPECT_FALSE(image->isTiledImage);
|
||||
EXPECT_FALSE(image->isTiledAllocation());
|
||||
EXPECT_NE(nullptr, image);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
@@ -1430,7 +1430,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif
|
||||
template <typename FamilyName>
|
||||
class MockImageHw : public ImageHw<FamilyName> {
|
||||
public:
|
||||
MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(context, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, false, 0, 0, surfaceFormatInfo) {
|
||||
MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(context, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) {
|
||||
}
|
||||
|
||||
void setClearColorParams(typename FamilyName::RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) override;
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_P(CreateTiledImageTest, isTiledImageIsSetForTiledImages) {
|
||||
retVal);
|
||||
ASSERT_NE(nullptr, image);
|
||||
|
||||
EXPECT_TRUE(image->isTiledImage);
|
||||
EXPECT_TRUE(image->isTiledAllocation());
|
||||
|
||||
delete image;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ TEST_P(CreateTiledImageTest, isTiledImageIsSetForSharedImages) {
|
||||
|
||||
ASSERT_NE(nullptr, image);
|
||||
|
||||
EXPECT_TRUE(image->isTiledImage);
|
||||
EXPECT_TRUE(image->isTiledAllocation());
|
||||
|
||||
delete image;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ TEST_P(CreateNonTiledImageTest, isTiledImageIsNotSetForNonTiledSharedImage) {
|
||||
|
||||
ASSERT_NE(nullptr, image);
|
||||
|
||||
EXPECT_FALSE(image->isTiledImage);
|
||||
EXPECT_FALSE(image->isTiledAllocation());
|
||||
|
||||
delete image;
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ struct NullImage : public Image {
|
||||
using Image::imageFormat;
|
||||
|
||||
NullImage() : Image(nullptr, cl_mem_flags{}, 0, nullptr, cl_image_format{},
|
||||
cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false, false,
|
||||
cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false,
|
||||
0, 0, SurfaceFormatInfo{}, nullptr) {
|
||||
}
|
||||
~NullImage() override {
|
||||
|
||||
@@ -268,8 +268,12 @@ TEST(MemObj, givenMemObjAndPointerToDiffrentStorageAndProperCommandWhenCheckIfMe
|
||||
}
|
||||
|
||||
TEST(MemObj, givenSharingHandlerWhenAskedForCpuMappingThenReturnFalse) {
|
||||
MemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
MemoryConstants::pageSize, nullptr, nullptr, allocation, true, false, false);
|
||||
memObj.setSharingHandler(new SharingHandler());
|
||||
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
|
||||
}
|
||||
@@ -277,7 +281,7 @@ TEST(MemObj, givenSharingHandlerWhenAskedForCpuMappingThenReturnFalse) {
|
||||
TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) {
|
||||
struct MyMemObj : public MemObj {
|
||||
using MemObj::MemObj;
|
||||
bool allowTiling() const override { return true; }
|
||||
bool isTiledAllocation() const override { return true; }
|
||||
};
|
||||
MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
||||
@@ -314,7 +318,7 @@ TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false);
|
||||
|
||||
EXPECT_FALSE(memObj.allowTiling());
|
||||
EXPECT_FALSE(memObj.isTiledAllocation());
|
||||
EXPECT_FALSE(memObj.peekSharingHandler());
|
||||
EXPECT_TRUE(memObj.mappingOnCpuAllowed());
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ HWTEST_F(Nv12ImageTest, setImageArgUVPlaneImageSetsOffsetedSurfaceBaseAddressAnd
|
||||
EXPECT_EQ(imageUVPlane->getGraphicsAllocation()->getGpuAddress() + surfaceOffsets.offset, surfaceState.getSurfaceBaseAddress());
|
||||
|
||||
auto tileMode = RENDER_SURFACE_STATE::TILE_MODE_LINEAR;
|
||||
if (imageNV12->allowTiling()) {
|
||||
if (imageNV12->isTiledAllocation()) {
|
||||
tileMode = RENDER_SURFACE_STATE::TILE_MODE_YMAJOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,10 @@ void MockGmmResourceInfo::setAuxQPitch(uint32_t value) {
|
||||
}
|
||||
|
||||
uint32_t MockGmmResourceInfo::getTileModeSurfaceState() {
|
||||
if (mockResourceCreateParams.Flags.Info.Linear == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mockResourceCreateParams.Type == GMM_RESOURCE_TYPE::RESOURCE_2D ||
|
||||
mockResourceCreateParams.Type == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
||||
return 3;
|
||||
|
||||
@@ -15,7 +15,7 @@ struct MockImageBase : public NEO::Image {
|
||||
using Image::imageDesc;
|
||||
|
||||
MockImageBase() : Image(nullptr, cl_mem_flags{}, 0, nullptr, cl_image_format{},
|
||||
cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false, false,
|
||||
cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false,
|
||||
0, 0, NEO::SurfaceFormatInfo{}, nullptr) {
|
||||
}
|
||||
~MockImageBase() override {
|
||||
|
||||
@@ -39,7 +39,6 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_lin.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tiling_mode_helper_tests.cpp
|
||||
)
|
||||
if(UNIX)
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_os_interface_linux})
|
||||
|
||||
@@ -1559,15 +1559,11 @@ TEST_F(DrmMemoryManagerTest, givenOsHandleWithNonTiledObjectWhenCreateFromShared
|
||||
ASSERT_NE(nullptr, gmm);
|
||||
EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.Linear);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.TiledY);
|
||||
EXPECT_EQ(TilingMode::NON_TILED, imgInfo.tilingMode);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenOsHandleWithTileYObjectWhenCreateFromSharedHandleIsCalledThenTileYGmmIsCreatedAndSetInAllocation) {
|
||||
auto &hwHelper = HwHelper::get(GmmHelper::getInstance()->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
|
||||
if (hwHelper.supportsYTiling()) {
|
||||
mock->ioctl_expected.primeFdToHandle = 1;
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
@@ -1601,12 +1597,10 @@ TEST_F(DrmMemoryManagerTest, givenOsHandleWithTileYObjectWhenCreateFromSharedHan
|
||||
|
||||
auto gmm = graphicsAllocation->getDefaultGmm();
|
||||
ASSERT_NE(nullptr, gmm);
|
||||
EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.TiledY);
|
||||
EXPECT_EQ(TilingMode::TILE_Y, imgInfo.tilingMode);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.Linear);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFailsThenReturnNullPtr) {
|
||||
osHandle handle = 1u;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/linux/tiling_mode_helper.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
using namespace NEO;
|
||||
|
||||
TEST(TilingModeHelper, givenI915ValuesWhenConvertingCorrectTilingModesAreReturned) {
|
||||
EXPECT_EQ(TilingMode::NON_TILED, TilingModeHelper::convert(I915_TILING_NONE));
|
||||
EXPECT_EQ(TilingMode::TILE_Y, TilingModeHelper::convert(I915_TILING_Y));
|
||||
EXPECT_EQ(TilingMode::TILE_X, TilingModeHelper::convert(I915_TILING_X));
|
||||
EXPECT_EQ(TilingMode::NON_TILED, TilingModeHelper::convert(I915_TILING_LAST + 1));
|
||||
}
|
||||
@@ -1240,7 +1240,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenWddmWhenAsyncDeleterIsDisable
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleterWhenCannotAllocateMemoryForTiledImageThenDrainIsCalledAndCreateAllocationIsCalledTwice) {
|
||||
cl_image_desc imgDesc;
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
|
||||
ImageInfo imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user