diff --git a/Jenkinsfile b/Jenkinsfile index a42cd73421..72771bc578 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ #!groovy dependenciesRevision='4fee4f013463a310cef14e272ff8c5e432e8e69f-1301' strategy='EQUAL' -allowedCD=263 +allowedCD=260 allowedF=5 diff --git a/runtime/built_ins/vme_dispatch_builder.h b/runtime/built_ins/vme_dispatch_builder.h index c0179a2fa8..352c5f2f05 100644 --- a/runtime/built_ins/vme_dispatch_builder.h +++ b/runtime/built_ins/vme_dispatch_builder.h @@ -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; } diff --git a/runtime/gmm_helper/gmm.cpp b/runtime/gmm_helper/gmm.cpp index df8b81b959..faadf84dfe 100644 --- a/runtime/gmm_helper/gmm.cpp +++ b/runtime/gmm_helper/gmm.cpp @@ -97,23 +97,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) { imageCount = static_cast(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) { diff --git a/runtime/gmm_helper/gmm_helper.cpp b/runtime/gmm_helper/gmm_helper.cpp index 30597ecb73..3940960e3f 100644 --- a/runtime/gmm_helper/gmm_helper.cpp +++ b/runtime/gmm_helper/gmm_helper.cpp @@ -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 imageType = imageDesc.image_type; + auto buffer = castToObject(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) { diff --git a/runtime/helpers/hw_helper.h b/runtime/helpers/hw_helper.h index 82b35a325e..19462d5c8d 100644 --- a/runtime/helpers/hw_helper.h +++ b/runtime/helpers/hw_helper.h @@ -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; diff --git a/runtime/helpers/hw_helper_bdw_plus.inl b/runtime/helpers/hw_helper_bdw_plus.inl index e32c78b206..983b950009 100644 --- a/runtime/helpers/hw_helper_bdw_plus.inl +++ b/runtime/helpers/hw_helper_bdw_plus.inl @@ -35,11 +35,6 @@ bool HwHelperHw::isLocalMemoryEnabled(const HardwareInfo &hwInfo) con return false; } -template -bool HwHelperHw::supportsYTiling() const { - return true; -} - template bool HwHelperHw::hvAlign4Required() const { return true; diff --git a/runtime/helpers/surface_formats.h b/runtime/helpers/surface_formats.h index a2aeb02f96..4357782028 100644 --- a/runtime/helpers/surface_formats.h +++ b/runtime/helpers/surface_formats.h @@ -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; }; diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index 99af526fcf..2fe7914476 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -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(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, diff --git a/runtime/mem_obj/image.h b/runtime/mem_obj/image.h index dba89a8c26..1849d8d755 100644 --- a/runtime/mem_obj/image.h +++ b/runtime/mem_obj/image.h @@ -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,43 +293,24 @@ 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(context, - properties, - size, - hostPtr, - imageFormat, - imageDesc, - 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; + return new ImageHw(context, + properties, + size, + hostPtr, + imageFormat, + imageDesc, + zeroCopy, + graphicsAllocation, + isObjectRedescribed, + baseMipLevel, + mipCount, + *surfaceFormatInfo, + surfaceOffsets); } static int getShaderChannelValue(int inputShaderChannel, cl_channel_order imageChannelOrder) { diff --git a/runtime/mem_obj/mem_obj.cpp b/runtime/mem_obj/mem_obj.cpp index 1890a0beb8..3a938ed636 100644 --- a/runtime/mem_obj/mem_obj.cpp +++ b/runtime/mem_obj/mem_obj.cpp @@ -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()); } diff --git a/runtime/mem_obj/mem_obj.h b/runtime/mem_obj/mem_obj.h index c8c114e063..8811188d79 100644 --- a/runtime/mem_obj/mem_obj.h +++ b/runtime/mem_obj/mem_obj.h @@ -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(); diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index 189f70b3e4..9af68d5b51 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -270,7 +270,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage) { GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr 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; diff --git a/runtime/os_interface/linux/CMakeLists.txt b/runtime/os_interface/linux/CMakeLists.txt index 91a8becb4b..04a96d1977 100644 --- a/runtime/os_interface/linux/CMakeLists.txt +++ b/runtime/os_interface/linux/CMakeLists.txt @@ -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) diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 7c6eee2dca..8e65c50915 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -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) { - 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); } diff --git a/runtime/os_interface/linux/tiling_mode_helper.h b/runtime/os_interface/linux/tiling_mode_helper.h deleted file mode 100644 index 48a4a690dd..0000000000 --- a/runtime/os_interface/linux/tiling_mode_helper.h +++ /dev/null @@ -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 diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index 76bdfb236f..354503cdb3 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -49,7 +49,7 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment) } GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr gmm) { - if (!GmmHelper::allowTiling(*allocationData.imgInfo->imgDesc) && allocationData.imgInfo->mipCount == 0) { + if (allocationData.imgInfo->linearStorage && allocationData.imgInfo->mipCount == 0) { return allocateGraphicsMemoryWithAlignment(allocationData); } diff --git a/unit_tests/accelerators/media_image_arg_tests.cpp b/unit_tests/accelerators/media_image_arg_tests.cpp index a58d1af14c..603aac2003 100644 --- a/unit_tests/accelerators/media_image_arg_tests.cpp +++ b/unit_tests/accelerators/media_image_arg_tests.cpp @@ -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; diff --git a/unit_tests/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp b/unit_tests/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp index 9075260f60..09cbfe78eb 100644 --- a/unit_tests/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp +++ b/unit_tests/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp @@ -148,7 +148,7 @@ HWTEST_P(AUBMapImage, MapUpdateUnmapVerify) { uint8_t *mappedPtrStart; uint8_t *srcMemoryStart; - if (srcImage->allowTiling()) { + if (srcImage->isTiledAllocation()) { mappedPtrStart = static_cast(mappedPtr); srcMemoryStart = srcMemory; diff --git a/unit_tests/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp b/unit_tests/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp index ce2701e447..d86c065e6c 100644 --- a/unit_tests/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp +++ b/unit_tests/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp @@ -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()); } diff --git a/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp b/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp index eaf10a0eca..14d12a2119 100644 --- a/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp +++ b/unit_tests/aub_tests/mem_obj/create_image_aub_tests.cpp @@ -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(&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(&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(&imageStorage[i], &data[i], 1); } else { EXPECT_EQ(imageStorage[i], data[i]); diff --git a/unit_tests/command_queue/enqueue_map_image_tests.cpp b/unit_tests/command_queue/enqueue_map_image_tests.cpp index a077b40f52..7938e1678a 100644 --- a/unit_tests/command_queue/enqueue_map_image_tests.cpp +++ b/unit_tests/command_queue/enqueue_map_image_tests.cpp @@ -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(ImageHelper>::create(context)); ASSERT_NE(nullptr, image); image->setSharingHandler(new SharingHandler()); - EXPECT_FALSE(image->allowTiling()); + EXPECT_FALSE(image->isTiledAllocation()); auto &csr = pDevice->getUltCommandStreamReceiver(); csr.taskCount = 1; @@ -600,7 +596,7 @@ HWTEST_F(EnqueueMapImageTest, givenSharingHandlerWhenReadOnlyMapAndUnmapOnNonTil std::unique_ptr image(ImageHelper>::create(context)); ASSERT_NE(nullptr, image); image->setSharingHandler(new SharingHandler()); - EXPECT_FALSE(image->allowTiling()); + EXPECT_FALSE(image->isTiledAllocation()); auto &csr = pDevice->getUltCommandStreamReceiver(); csr.taskCount = 1; @@ -910,7 +906,7 @@ TEST_F(EnqueueMapImageTest, givenImage1DArrayWhenEnqueueMapImageIsCalledThenRetu imageFormat, imageDesc, true, allocation, - false, false, 0, 0, + false, 0, 0, surfaceFormat, nullptr) { } diff --git a/unit_tests/command_queue/multiple_map_image_tests.cpp b/unit_tests/command_queue/multiple_map_image_tests.cpp index 9eb55892ba..d1f63c8b5b 100644 --- a/unit_tests/command_queue/multiple_map_image_tests.cpp +++ b/unit_tests/command_queue/multiple_map_image_tests.cpp @@ -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 struct MockImage : public ImageHw { using Image::mapOperationsHandler; + using ImageHw::isZeroCopy; + using ImageHw::ImageHw; - template - MockImage(Params... params) : ImageHw(params...) { - this->createFunction = ImageHw::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(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 std::unique_ptr> 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 backup(&imageFactory[eRenderCoreFamily].createImageFunction); + imageFactory[eRenderCoreFamily].createImageFunction = MockImage::createMockImage; auto surfaceFormat = Image::getSurfaceFormatFromTable(Traits::flags, &Traits::imageFormat); - auto img = new MockImage(context, Traits::flags, allocationSize, Traits::hostPtr, Traits::imageFormat, - Traits::imageDesc, false, mockAlloc, false, tiledImage, 0, 0, *surfaceFormat); - return std::unique_ptr>(img); + + cl_int retVal = CL_SUCCESS; + auto img = Image::create(context, Traits::flags, surfaceFormat, &Traits::imageDesc, Traits::hostPtr, retVal); + auto mockImage = static_cast *>(img); + + return std::unique_ptr>(mockImage); } template @@ -204,6 +224,7 @@ HWTEST_F(MultipleMapImageTest, givenErrorFromWriteImageWhenUnmappedOnGpuThenDont HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedPtrAndRemoveOnUnmap) { auto image = createMockImage(); auto cmdQ = createMockCmdQ(); + 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(); auto cmdQ = createMockCmdQ(); + 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(); auto cmdQ = createMockCmdQ(); + 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(); auto cmdQ = createMockCmdQ(); + 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 diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 48bc8b6e8f..df1f451376 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -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(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); - } + EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 0u); + EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u); } 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(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::create(&context, {}, 1, nullptr, retVal)); + imgDesc.buffer = buffer.get(); checkTiling(imgDesc, false); diff --git a/unit_tests/mem_obj/image2d_from_buffer_tests.cpp b/unit_tests/mem_obj/image2d_from_buffer_tests.cpp index 9ea2d3f56a..f53b46f052 100644 --- a/unit_tests/mem_obj/image2d_from_buffer_tests.cpp +++ b/unit_tests/mem_obj/image2d_from_buffer_tests.cpp @@ -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(__GMM_NO_CUBE_MAP)); delete imageFromBuffer; diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index fc88e48d98..2f567f460a 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -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::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::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 class MockImageHw : public ImageHw { public: - MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw(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(context, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) { } void setClearColorParams(typename FamilyName::RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) override; diff --git a/unit_tests/mem_obj/image_tiled_tests.cpp b/unit_tests/mem_obj/image_tiled_tests.cpp index bb13e8a701..b64232dd3e 100644 --- a/unit_tests/mem_obj/image_tiled_tests.cpp +++ b/unit_tests/mem_obj/image_tiled_tests.cpp @@ -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; } diff --git a/unit_tests/mem_obj/image_validate_tests.cpp b/unit_tests/mem_obj/image_validate_tests.cpp index 0766f4704b..44b4d3b15b 100644 --- a/unit_tests/mem_obj/image_validate_tests.cpp +++ b/unit_tests/mem_obj/image_validate_tests.cpp @@ -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 { diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index 20491f11af..e764c0f8b7 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -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()); } diff --git a/unit_tests/mem_obj/nv12_image_tests.cpp b/unit_tests/mem_obj/nv12_image_tests.cpp index 367773b1ca..77656b7c30 100644 --- a/unit_tests/mem_obj/nv12_image_tests.cpp +++ b/unit_tests/mem_obj/nv12_image_tests.cpp @@ -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; } diff --git a/unit_tests/mocks/mock_gmm_resource_info.cpp b/unit_tests/mocks/mock_gmm_resource_info.cpp index d090df414b..753f0e7887 100644 --- a/unit_tests/mocks/mock_gmm_resource_info.cpp +++ b/unit_tests/mocks/mock_gmm_resource_info.cpp @@ -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; diff --git a/unit_tests/mocks/mock_image.h b/unit_tests/mocks/mock_image.h index 30822e7aec..becc1931ab 100644 --- a/unit_tests/mocks/mock_image.h +++ b/unit_tests/mocks/mock_image.h @@ -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 { diff --git a/unit_tests/os_interface/linux/CMakeLists.txt b/unit_tests/os_interface/linux/CMakeLists.txt index 870cd29597..bcf81e8e09 100644 --- a/unit_tests/os_interface/linux/CMakeLists.txt +++ b/unit_tests/os_interface/linux/CMakeLists.txt @@ -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}) diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index 7e45e64896..4e48d2a871 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -1559,53 +1559,47 @@ 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); + mock->ioctl_expected.primeFdToHandle = 1; + mock->ioctl_expected.gemWait = 1; + mock->ioctl_expected.gemClose = 1; + mock->ioctl_expected.gemGetTiling = 1; + mock->getTilingModeOut = I915_TILING_Y; - if (hwHelper.supportsYTiling()) { - mock->ioctl_expected.primeFdToHandle = 1; - mock->ioctl_expected.gemWait = 1; - mock->ioctl_expected.gemClose = 1; - mock->ioctl_expected.gemGetTiling = 1; - mock->getTilingModeOut = I915_TILING_Y; + osHandle handle = 1u; + uint32_t boHandle = 2u; + mock->outputHandle = boHandle; - osHandle handle = 1u; - uint32_t boHandle = 2u; - mock->outputHandle = boHandle; + cl_mem_flags flags = CL_MEM_READ_ONLY; + cl_image_desc imgDesc = {}; + cl_image_format gmmImgFormat = {CL_NV12_INTEL, CL_UNORM_INT8}; + const SurfaceFormatInfo *gmmSurfaceFormat = nullptr; + ImageInfo imgInfo = {0}; - cl_mem_flags flags = CL_MEM_READ_ONLY; - cl_image_desc imgDesc = {}; - cl_image_format gmmImgFormat = {CL_NV12_INTEL, CL_UNORM_INT8}; - const SurfaceFormatInfo *gmmSurfaceFormat = nullptr; - ImageInfo imgInfo = {0}; + imgInfo.imgDesc = &imgDesc; + imgDesc.image_width = 4; + imgDesc.image_height = 4; + imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; + gmmSurfaceFormat = Image::getSurfaceFormatFromTable(flags, &gmmImgFormat); + imgInfo.surfaceFormat = gmmSurfaceFormat; + imgInfo.plane = GMM_PLANE_Y; - imgInfo.imgDesc = &imgDesc; - imgDesc.image_width = 4; - imgDesc.image_height = 4; - imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; - gmmSurfaceFormat = Image::getSurfaceFormatFromTable(flags, &gmmImgFormat); - imgInfo.surfaceFormat = gmmSurfaceFormat; - imgInfo.plane = GMM_PLANE_Y; + AllocationProperties properties(false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE); - AllocationProperties properties(false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE); + auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false); + ASSERT_NE(nullptr, graphicsAllocation); + EXPECT_EQ(boHandle, mock->getTilingHandleIn); + EXPECT_EQ(GraphicsAllocation::AllocationType::SHARED_IMAGE, graphicsAllocation->getAllocationType()); - auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false); - ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_EQ(boHandle, mock->getTilingHandleIn); - EXPECT_EQ(GraphicsAllocation::AllocationType::SHARED_IMAGE, graphicsAllocation->getAllocationType()); + auto gmm = graphicsAllocation->getDefaultGmm(); + ASSERT_NE(nullptr, gmm); + EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.Linear); - auto gmm = graphicsAllocation->getDefaultGmm(); - ASSERT_NE(nullptr, gmm); - EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.TiledY); - EXPECT_EQ(TilingMode::TILE_Y, imgInfo.tilingMode); - - memoryManager->freeGraphicsMemory(graphicsAllocation); - } + memoryManager->freeGraphicsMemory(graphicsAllocation); } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFailsThenReturnNullPtr) { diff --git a/unit_tests/os_interface/linux/tiling_mode_helper_tests.cpp b/unit_tests/os_interface/linux/tiling_mode_helper_tests.cpp deleted file mode 100644 index d51139944a..0000000000 --- a/unit_tests/os_interface/linux/tiling_mode_helper_tests.cpp +++ /dev/null @@ -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)); -} diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index 05114973e3..0734e8a99e 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -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);