diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index d0c481b1fd..a1544f214e 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -497,7 +497,7 @@ void AUBCommandStreamReceiverHw::makeResident(GraphicsAllocation &gfx template bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxAllocation) { auto cpuAddress = gfxAllocation.getUnderlyingBuffer(); - auto gpuAddress = Gmm::decanonize(gfxAllocation.getGpuAddress()); + auto gpuAddress = GmmHelper::decanonize(gfxAllocation.getGpuAddress()); auto size = gfxAllocation.getUnderlyingBufferSize(); auto allocType = gfxAllocation.getAllocationType(); diff --git a/runtime/command_stream/create_command_stream_impl.cpp b/runtime/command_stream/create_command_stream_impl.cpp index 798185e26c..0d49fb6da3 100644 --- a/runtime/command_stream/create_command_stream_impl.cpp +++ b/runtime/command_stream/create_command_stream_impl.cpp @@ -41,27 +41,27 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) { if (csr) { switch (csr) { case CSR_AUB: - Gmm::initContext(pHwInfo->pPlatform, - pHwInfo->pSkuTable, - pHwInfo->pWaTable, - pHwInfo->pSysInfo); + GmmHelper::initContext(pHwInfo->pPlatform, + pHwInfo->pSkuTable, + pHwInfo->pWaTable, + pHwInfo->pSysInfo); commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true); break; case CSR_TBX: - Gmm::initContext(pHwInfo->pPlatform, - pHwInfo->pSkuTable, - pHwInfo->pWaTable, - pHwInfo->pSysInfo); + GmmHelper::initContext(pHwInfo->pPlatform, + pHwInfo->pSkuTable, + pHwInfo->pWaTable, + pHwInfo->pSysInfo); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, false); break; case CSR_HW_WITH_AUB: commandStreamReceiver = funcCreate(*pHwInfo, true); break; case CSR_TBX_WITH_AUB: - Gmm::initContext(pHwInfo->pPlatform, - pHwInfo->pSkuTable, - pHwInfo->pWaTable, - pHwInfo->pSysInfo); + GmmHelper::initContext(pHwInfo->pPlatform, + pHwInfo->pSkuTable, + pHwInfo->pWaTable, + pHwInfo->pSysInfo); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, true); break; default: diff --git a/runtime/dll/create_command_stream.cpp b/runtime/dll/create_command_stream.cpp index 6dc3d8427b..6d30788c49 100644 --- a/runtime/dll/create_command_stream.cpp +++ b/runtime/dll/create_command_stream.cpp @@ -26,7 +26,6 @@ #include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" #include "runtime/command_stream/device_command_stream.h" #include "runtime/helpers/debug_helpers.h" -#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/os_interface/device_factory.h" #include "runtime/helpers/options.h" #include "runtime/helpers/hw_info.h" diff --git a/runtime/dll/linux/drm_neo_create.cpp b/runtime/dll/linux/drm_neo_create.cpp index 1c4e2c0977..29c7efe155 100644 --- a/runtime/dll/linux/drm_neo_create.cpp +++ b/runtime/dll/linux/drm_neo_create.cpp @@ -211,7 +211,7 @@ Drm *Drm::create(int32_t deviceOrdinal) { //turbo patch not present, we are not on custom Kernel, switch to simplified Mocs selection //do this only for GEN9+ if (device->pHwInfo->pPlatform->eRenderCoreFamily >= IGFX_GEN9_CORE) { - Gmm::useSimplifiedMocsTable = true; + GmmHelper::useSimplifiedMocsTable = true; } printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n"); } diff --git a/runtime/gmm_helper/CMakeLists.txt b/runtime/gmm_helper/CMakeLists.txt index 99f9f3da56..2dbef60dd5 100644 --- a/runtime/gmm_helper/CMakeLists.txt +++ b/runtime/gmm_helper/CMakeLists.txt @@ -20,6 +20,8 @@ set(RUNTIME_SRCS_GMM_HELPER_BASE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/gmm.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gmm.h ${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/gmm_lib.h diff --git a/runtime/gmm_helper/gmm.cpp b/runtime/gmm_helper/gmm.cpp new file mode 100644 index 0000000000..1582cbc463 --- /dev/null +++ b/runtime/gmm_helper/gmm.cpp @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2018, Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "runtime/gmm_helper/gmm.h" +#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/resource_info.h" +#include "runtime/helpers/aligned_memory.h" +#include "runtime/helpers/debug_helpers.h" +#include "runtime/helpers/ptr_math.h" +#include "runtime/helpers/surface_formats.h" +#include "runtime/helpers/hw_info.h" + +namespace OCLRT { +void Gmm::create() { + if (resourceParams.BaseWidth >= GmmHelper::maxPossiblePitch) { + resourceParams.Flags.Gpu.NoRestriction = 1; + } + + gmmResourceInfo.reset(GmmResourceInfo::create(&resourceParams)); +} + +void Gmm::queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) { + uint32_t imageWidth = static_cast(imgInfo.imgDesc->image_width); + uint32_t imageHeight = 1; + uint32_t imageDepth = 1; + uint32_t imageCount = 1; + + switch (imgInfo.imgDesc->image_type) { + case CL_MEM_OBJECT_IMAGE1D: + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + this->resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; + break; + case CL_MEM_OBJECT_IMAGE2D: + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + this->resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_2D; + imageHeight = static_cast(imgInfo.imgDesc->image_height); + break; + case CL_MEM_OBJECT_IMAGE3D: + this->resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_3D; + imageHeight = static_cast(imgInfo.imgDesc->image_height); + imageDepth = static_cast(imgInfo.imgDesc->image_depth); + break; + default: + return; + } + + if (imgInfo.imgDesc->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY || + imgInfo.imgDesc->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) { + imageCount = static_cast(imgInfo.imgDesc->image_array_size); + } + + this->resourceParams.Flags.Info.Linear = 1; + if (GmmHelper::allowTiling(*imgInfo.imgDesc)) { + this->resourceParams.Flags.Info.TiledY = 1; + } + + this->resourceParams.NoGfxMemory = 1; // dont allocate, only query for params + + this->resourceParams.Usage = GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE; + this->resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat; + this->resourceParams.Flags.Gpu.Texture = 1; + this->resourceParams.BaseWidth = imageWidth; + this->resourceParams.BaseHeight = imageHeight; + this->resourceParams.Depth = imageDepth; + this->resourceParams.ArraySize = imageCount; + this->resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = 1; + this->resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount; + if (imgInfo.imgDesc->image_row_pitch && imgInfo.imgDesc->mem_object) { + this->resourceParams.OverridePitch = (uint32_t)imgInfo.imgDesc->image_row_pitch; + this->resourceParams.Flags.Info.AllowVirtualPadding = true; + } + + applyAuxFlags(imgInfo, hwInfo); + + this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams)); + + imgInfo.size = this->gmmResourceInfo->getSizeAllocation(); + + imgInfo.rowPitch = this->gmmResourceInfo->getRenderPitch(); + if (imgInfo.rowPitch == 0) { // WA + imgInfo.rowPitch = alignUp(this->gmmResourceInfo->getBaseWidth(), this->gmmResourceInfo->getHAlign()); + imgInfo.rowPitch = imgInfo.rowPitch * (this->gmmResourceInfo->getBitsPerPixel() >> 3); + } + + // calculate slice pitch + if ((this->resourceParams.Type == GMM_RESOURCE_TYPE::RESOURCE_2D || + this->resourceParams.Type == GMM_RESOURCE_TYPE::RESOURCE_1D) && + imageCount == 1) { + // 2D or 1D or 1Darray with array_size=1 + imgInfo.slicePitch = imgInfo.size; + } else { + // 3D Image or 2D-Array or 1D-Arrays (array_size>1) + GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; + reqOffsetInfo.ReqRender = 1; + reqOffsetInfo.Slice = 1; + reqOffsetInfo.ArrayIndex = (imageCount > 1) ? 1 : 0; + + this->gmmResourceInfo->getOffset(reqOffsetInfo); + imgInfo.slicePitch = reqOffsetInfo.Render.Offset; + imgInfo.slicePitch += imgInfo.rowPitch * reqOffsetInfo.Render.YOffset; + imgInfo.slicePitch += reqOffsetInfo.Render.XOffset; + } + + if (imgInfo.plane != GMM_NO_PLANE) { + GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; + reqOffsetInfo.ReqRender = 1; + reqOffsetInfo.Slice = 0; + reqOffsetInfo.ArrayIndex = 0; + reqOffsetInfo.Plane = imgInfo.plane; + this->gmmResourceInfo->getOffset(reqOffsetInfo); + imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (this->gmmResourceInfo->getBitsPerPixel() / 8); + imgInfo.yOffset = reqOffsetInfo.Render.YOffset; + imgInfo.offset = reqOffsetInfo.Render.Offset; + } + + if (imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_FORMAT_NV12) { + GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; + reqOffsetInfo.ReqLock = 1; + reqOffsetInfo.Slice = 1; + reqOffsetInfo.ArrayIndex = 0; + reqOffsetInfo.Plane = GMM_PLANE_U; + this->gmmResourceInfo->getOffset(reqOffsetInfo); + imgInfo.yOffsetForUVPlane = reqOffsetInfo.Lock.Offset / reqOffsetInfo.Lock.Pitch; + } + + imgInfo.qPitch = queryQPitch(hwInfo.pPlatform->eRenderCoreFamily, this->resourceParams.Type); + return; +} + +uint32_t Gmm::queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType) { + if (gfxFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) { + return 0; + } + return gmmResourceInfo->getQPitch(); +} + +uint32_t Gmm::getRenderHAlignment() { + return GmmHelper::getRenderAlignment(gmmResourceInfo->getHAlign()); +} + +uint32_t Gmm::getRenderVAlignment() { + return GmmHelper::getRenderAlignment(gmmResourceInfo->getVAlign()); +} + +void Gmm::updateImgInfo(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex) { + imgDesc.image_width = gmmResourceInfo->getBaseWidth(); + imgDesc.image_row_pitch = gmmResourceInfo->getRenderPitch(); + if (imgDesc.image_row_pitch == 0) { + size_t width = alignUp(imgDesc.image_width, gmmResourceInfo->getHAlign()); + imgDesc.image_row_pitch = width * (gmmResourceInfo->getBitsPerPixel() >> 3); + } + imgDesc.image_height = gmmResourceInfo->getBaseHeight(); + imgDesc.image_depth = gmmResourceInfo->getBaseDepth(); + imgDesc.image_array_size = gmmResourceInfo->getArraySize(); + if (imgDesc.image_depth > 1 || imgDesc.image_array_size > 1) { + GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; + reqOffsetInfo.Slice = imgDesc.image_depth > 1 ? 1 : 0; + reqOffsetInfo.ArrayIndex = imgDesc.image_array_size > 1 ? 1 : 0; + reqOffsetInfo.ReqLock = 1; + gmmResourceInfo->getOffset(reqOffsetInfo); + imgDesc.image_slice_pitch = static_cast(reqOffsetInfo.Lock.Offset); + } else { + imgDesc.image_slice_pitch = gmmResourceInfo->getSizeAllocation(); + } + + GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; + reqOffsetInfo.ReqRender = 1; + reqOffsetInfo.Slice = 0; + reqOffsetInfo.ArrayIndex = arrayIndex; + reqOffsetInfo.Plane = imgInfo.plane; + gmmResourceInfo->getOffset(reqOffsetInfo); + imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (gmmResourceInfo->getBitsPerPixel() / 8); + imgInfo.yOffset = reqOffsetInfo.Render.YOffset; + imgInfo.offset = reqOffsetInfo.Render.Offset; +} + +uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, OCLPlane plane) { + GMM_RES_COPY_BLT gmmResourceCopyBLT = {}; + + if (plane == OCLPlane::PLANE_V) { + sys = ptrOffset(sys, height * pitch * 2); + pitch /= 2; + } else if (plane == OCLPlane::PLANE_U) { + sys = ptrOffset(sys, height * pitch * 2 + height * pitch / 2); + pitch /= 2; + } else if (plane == OCLPlane::PLANE_UV) { + sys = ptrOffset(sys, height * pitch * 2); + } + uint32_t size = pitch * height; + + gmmResourceCopyBLT.Sys.pData = sys; + gmmResourceCopyBLT.Gpu.pData = gpu; + gmmResourceCopyBLT.Sys.RowPitch = pitch; + gmmResourceCopyBLT.Blt.Upload = upload; + gmmResourceCopyBLT.Sys.BufferSize = size; + + return this->gmmResourceInfo->cpuBlt(&gmmResourceCopyBLT); +} + +bool Gmm::unifiedAuxTranslationCapable() const { + auto gmmFlags = this->gmmResourceInfo->getResourceFlags(); + return gmmFlags->Gpu.CCS && gmmFlags->Gpu.UnifiedAuxSurface && gmmFlags->Info.RenderCompressed; +} + +} // namespace OCLRT diff --git a/runtime/gmm_helper/gmm.h b/runtime/gmm_helper/gmm.h new file mode 100644 index 0000000000..93be9cbb7a --- /dev/null +++ b/runtime/gmm_helper/gmm.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#include +#include +#include +#include "runtime/gmm_helper/gmm_lib.h" +#include "runtime/api/cl_types.h" + +namespace OCLRT { +enum class OCLPlane; +struct HardwareInfo; +struct ImageInfo; +class GmmResourceInfo; + +class Gmm { + public: + virtual ~Gmm() = default; + + void create(); + void queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo); + + uint32_t getRenderHAlignment(); + uint32_t getRenderVAlignment(); + + void applyAuxFlags(ImageInfo &imgInfo, const HardwareInfo &hwInfo); + bool unifiedAuxTranslationCapable() const; + + uint32_t queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType); + void updateImgInfo(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex); + uint8_t resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, OCLPlane plane); + + GMM_RESCREATE_PARAMS resourceParams = {}; + std::unique_ptr gmmResourceInfo; + + bool isRenderCompressed = false; +}; +} // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_helper.cpp b/runtime/gmm_helper/gmm_helper.cpp index 7a126b490c..ecb50e56c5 100644 --- a/runtime/gmm_helper/gmm_helper.cpp +++ b/runtime/gmm_helper/gmm_helper.cpp @@ -20,31 +20,23 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/get_info.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/debug_helpers.h" -#include "runtime/helpers/ptr_math.h" #include "runtime/memory_manager/graphics_allocation.h" #include "runtime/helpers/surface_formats.h" #include "runtime/helpers/hw_info.h" #include "runtime/sku_info/operations/sku_info_transfer.h" namespace OCLRT { -void Gmm::create() { - if (resourceParams.BaseWidth >= maxPossiblePitch) { - resourceParams.Flags.Gpu.NoRestriction = 1; - } - - gmmResourceInfo.reset(GmmResourceInfo::create(&resourceParams)); -} - -bool Gmm::initContext(const PLATFORM *pPlatform, - const FeatureTable *pSkuTable, - const WorkaroundTable *pWaTable, - const GT_SYSTEM_INFO *pGtSysInfo) { - if (!Gmm::gmmClientContext) { +bool GmmHelper::initContext(const PLATFORM *pPlatform, + const FeatureTable *pSkuTable, + const WorkaroundTable *pWaTable, + const GT_SYSTEM_INFO *pGtSysInfo) { + if (!GmmHelper::gmmClientContext) { _SKU_FEATURE_TABLE gmmFtrTable = {}; _WA_TABLE gmmWaTable = {}; SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable); @@ -54,20 +46,20 @@ bool Gmm::initContext(const PLATFORM *pPlatform, } bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA); UNRECOVERABLE_IF(!success); - Gmm::gmmClientContext = createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA); + GmmHelper::gmmClientContext = GmmHelper::createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA); } - return Gmm::gmmClientContext != nullptr; + return GmmHelper::gmmClientContext != nullptr; } -void Gmm::destroyContext() { - if (Gmm::gmmClientContext) { - deleteClientContextFunc(Gmm::gmmClientContext); - Gmm::gmmClientContext = nullptr; +void GmmHelper::destroyContext() { + if (GmmHelper::gmmClientContext) { + deleteClientContextFunc(GmmHelper::gmmClientContext); + GmmHelper::gmmClientContext = nullptr; destroyGlobalContextFunc(); } } -uint32_t Gmm::getMOCS(uint32_t type) { +uint32_t GmmHelper::getMOCS(uint32_t type) { if (useSimplifiedMocsTable) { if (type == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) { return cacheDisabledIndex; @@ -76,12 +68,12 @@ uint32_t Gmm::getMOCS(uint32_t type) { } } - MEMORY_OBJECT_CONTROL_STATE mocs = Gmm::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast(type)); + MEMORY_OBJECT_CONTROL_STATE mocs = GmmHelper::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast(type)); return static_cast(mocs.DwordValue); } -Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize, bool uncacheable) { +Gmm *GmmHelper::create(const void *alignedPtr, size_t alignedSize, bool uncacheable) { auto gmm = new Gmm(); gmm->resourceParams.Type = RESOURCE_BUFFER; @@ -109,128 +101,19 @@ Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize, bool uncacheable) { return gmm; } -Gmm *Gmm::create(GMM_RESOURCE_INFO *inputGmm) { +Gmm *GmmHelper::create(GMM_RESOURCE_INFO *inputGmm) { auto gmm = new Gmm(); gmm->gmmResourceInfo.reset(GmmResourceInfo::create(inputGmm)); return gmm; } -Gmm *Gmm::createGmmAndQueryImgParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) { +Gmm *GmmHelper::createGmmAndQueryImgParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) { Gmm *gmm = new Gmm(); gmm->queryImageParams(imgInfo, hwInfo); return gmm; } -void Gmm::queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) { - uint32_t imageWidth = static_cast(imgInfo.imgDesc->image_width); - uint32_t imageHeight = 1; - uint32_t imageDepth = 1; - uint32_t imageCount = 1; - - switch (imgInfo.imgDesc->image_type) { - case CL_MEM_OBJECT_IMAGE1D: - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - this->resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; - break; - case CL_MEM_OBJECT_IMAGE2D: - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - this->resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_2D; - imageHeight = static_cast(imgInfo.imgDesc->image_height); - break; - case CL_MEM_OBJECT_IMAGE3D: - this->resourceParams.Type = GMM_RESOURCE_TYPE::RESOURCE_3D; - imageHeight = static_cast(imgInfo.imgDesc->image_height); - imageDepth = static_cast(imgInfo.imgDesc->image_depth); - break; - default: - return; - } - - if (imgInfo.imgDesc->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY || - imgInfo.imgDesc->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) { - imageCount = static_cast(imgInfo.imgDesc->image_array_size); - } - - this->resourceParams.Flags.Info.Linear = 1; - if (allowTiling(*imgInfo.imgDesc)) { - this->resourceParams.Flags.Info.TiledY = 1; - } - - this->resourceParams.NoGfxMemory = 1; // dont allocate, only query for params - - this->resourceParams.Usage = GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE; - this->resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat; - this->resourceParams.Flags.Gpu.Texture = 1; - this->resourceParams.BaseWidth = imageWidth; - this->resourceParams.BaseHeight = imageHeight; - this->resourceParams.Depth = imageDepth; - this->resourceParams.ArraySize = imageCount; - this->resourceParams.Flags.Wa.__ForceOtherHVALIGN4 = 1; - this->resourceParams.MaxLod = imgInfo.baseMipLevel + imgInfo.mipCount; - if (imgInfo.imgDesc->image_row_pitch && imgInfo.imgDesc->mem_object) { - this->resourceParams.OverridePitch = (uint32_t)imgInfo.imgDesc->image_row_pitch; - this->resourceParams.Flags.Info.AllowVirtualPadding = true; - } - - applyAuxFlags(imgInfo, hwInfo); - - this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams)); - - imgInfo.size = this->gmmResourceInfo->getSizeAllocation(); - - imgInfo.rowPitch = this->gmmResourceInfo->getRenderPitch(); - if (imgInfo.rowPitch == 0) { // WA - imgInfo.rowPitch = alignUp(this->gmmResourceInfo->getBaseWidth(), this->gmmResourceInfo->getHAlign()); - imgInfo.rowPitch = imgInfo.rowPitch * (this->gmmResourceInfo->getBitsPerPixel() >> 3); - } - - // calculate slice pitch - if ((this->resourceParams.Type == GMM_RESOURCE_TYPE::RESOURCE_2D || - this->resourceParams.Type == GMM_RESOURCE_TYPE::RESOURCE_1D) && - imageCount == 1) { - // 2D or 1D or 1Darray with array_size=1 - imgInfo.slicePitch = imgInfo.size; - } else { - // 3D Image or 2D-Array or 1D-Arrays (array_size>1) - GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; - reqOffsetInfo.ReqRender = 1; - reqOffsetInfo.Slice = 1; - reqOffsetInfo.ArrayIndex = (imageCount > 1) ? 1 : 0; - - this->gmmResourceInfo->getOffset(reqOffsetInfo); - imgInfo.slicePitch = reqOffsetInfo.Render.Offset; - imgInfo.slicePitch += imgInfo.rowPitch * reqOffsetInfo.Render.YOffset; - imgInfo.slicePitch += reqOffsetInfo.Render.XOffset; - } - - if (imgInfo.plane != GMM_NO_PLANE) { - GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; - reqOffsetInfo.ReqRender = 1; - reqOffsetInfo.Slice = 0; - reqOffsetInfo.ArrayIndex = 0; - reqOffsetInfo.Plane = imgInfo.plane; - this->gmmResourceInfo->getOffset(reqOffsetInfo); - imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (this->gmmResourceInfo->getBitsPerPixel() / 8); - imgInfo.yOffset = reqOffsetInfo.Render.YOffset; - imgInfo.offset = reqOffsetInfo.Render.Offset; - } - - if (imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_FORMAT_NV12) { - GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; - reqOffsetInfo.ReqLock = 1; - reqOffsetInfo.Slice = 1; - reqOffsetInfo.ArrayIndex = 0; - reqOffsetInfo.Plane = GMM_PLANE_U; - this->gmmResourceInfo->getOffset(reqOffsetInfo); - imgInfo.yOffsetForUVPlane = reqOffsetInfo.Lock.Offset / reqOffsetInfo.Lock.Pitch; - } - - imgInfo.qPitch = queryQPitch(hwInfo.pPlatform->eRenderCoreFamily, this->resourceParams.Type); - return; -} - -void Gmm::queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc) { +void GmmHelper::queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc) { // 1D or 2D from buffer if (imgInfo.imgDesc->image_row_pitch > 0) { imgInfo.rowPitch = imgInfo.imgDesc->image_row_pitch; @@ -242,7 +125,7 @@ void Gmm::queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAl imgInfo.qPitch = 0; } -bool Gmm::allowTiling(const cl_image_desc &imageDesc) { +bool GmmHelper::allowTiling(const cl_image_desc &imageDesc) { // consider returning tiling type instead of bool if (DebugManager.flags.ForceLinearImages.get()) { return false; @@ -260,30 +143,15 @@ bool Gmm::allowTiling(const cl_image_desc &imageDesc) { } } -uint64_t Gmm::canonize(uint64_t address) { +uint64_t GmmHelper::canonize(uint64_t address) { return ((int64_t)((address & 0xFFFFFFFFFFFF) << (64 - 48))) >> (64 - 48); } -uint64_t Gmm::decanonize(uint64_t address) { +uint64_t GmmHelper::decanonize(uint64_t address) { return (uint64_t)(address & 0xFFFFFFFFFFFF); } -uint32_t Gmm::queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType) { - if (gfxFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) { - return 0; - } - return gmmResourceInfo->getQPitch(); -} - -uint32_t Gmm::getRenderHAlignment() { - return getRenderAlignment(gmmResourceInfo->getHAlign()); -} - -uint32_t Gmm::getRenderVAlignment() { - return getRenderAlignment(gmmResourceInfo->getVAlign()); -} - -uint32_t Gmm::getRenderAlignment(uint32_t alignment) { +uint32_t GmmHelper::getRenderAlignment(uint32_t alignment) { uint32_t returnAlign = 0; if (alignment == 8) { returnAlign = 2; @@ -295,7 +163,7 @@ uint32_t Gmm::getRenderAlignment(uint32_t alignment) { return returnAlign; } -uint32_t Gmm::getRenderTileMode(uint32_t tileWalk) { +uint32_t GmmHelper::getRenderTileMode(uint32_t tileWalk) { uint32_t tileMode = 0; // TILE_MODE_LINEAR if (tileWalk == 0) { tileMode = 2; // TILE_MODE_XMAJOR; @@ -307,7 +175,7 @@ uint32_t Gmm::getRenderTileMode(uint32_t tileWalk) { return tileMode; } -uint32_t Gmm::getRenderMultisamplesCount(uint32_t numSamples) { +uint32_t GmmHelper::getRenderMultisamplesCount(uint32_t numSamples) { if (numSamples == 2) { return 1; } else if (numSamples == 4) { @@ -320,7 +188,7 @@ uint32_t Gmm::getRenderMultisamplesCount(uint32_t numSamples) { return 0; } -GMM_YUV_PLANE Gmm::convertPlane(OCLPlane oclPlane) { +GMM_YUV_PLANE GmmHelper::convertPlane(OCLPlane oclPlane) { if (oclPlane == OCLPlane::PLANE_Y) { return GMM_PLANE_Y; } else if (oclPlane == OCLPlane::PLANE_U || oclPlane == OCLPlane::PLANE_UV) { @@ -332,68 +200,8 @@ GMM_YUV_PLANE Gmm::convertPlane(OCLPlane oclPlane) { return GMM_NO_PLANE; } -void Gmm::updateImgInfo(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex) { - imgDesc.image_width = gmmResourceInfo->getBaseWidth(); - imgDesc.image_row_pitch = gmmResourceInfo->getRenderPitch(); - if (imgDesc.image_row_pitch == 0) { - size_t width = alignUp(imgDesc.image_width, gmmResourceInfo->getHAlign()); - imgDesc.image_row_pitch = width * (gmmResourceInfo->getBitsPerPixel() >> 3); - } - imgDesc.image_height = gmmResourceInfo->getBaseHeight(); - imgDesc.image_depth = gmmResourceInfo->getBaseDepth(); - imgDesc.image_array_size = gmmResourceInfo->getArraySize(); - if (imgDesc.image_depth > 1 || imgDesc.image_array_size > 1) { - GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; - reqOffsetInfo.Slice = imgDesc.image_depth > 1 ? 1 : 0; - reqOffsetInfo.ArrayIndex = imgDesc.image_array_size > 1 ? 1 : 0; - reqOffsetInfo.ReqLock = 1; - gmmResourceInfo->getOffset(reqOffsetInfo); - imgDesc.image_slice_pitch = static_cast(reqOffsetInfo.Lock.Offset); - } else { - imgDesc.image_slice_pitch = gmmResourceInfo->getSizeAllocation(); - } - - GMM_REQ_OFFSET_INFO reqOffsetInfo = {}; - reqOffsetInfo.ReqRender = 1; - reqOffsetInfo.Slice = 0; - reqOffsetInfo.ArrayIndex = arrayIndex; - reqOffsetInfo.Plane = imgInfo.plane; - gmmResourceInfo->getOffset(reqOffsetInfo); - imgInfo.xOffset = reqOffsetInfo.Render.XOffset / (gmmResourceInfo->getBitsPerPixel() / 8); - imgInfo.yOffset = reqOffsetInfo.Render.YOffset; - imgInfo.offset = reqOffsetInfo.Render.Offset; -} - -uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, OCLPlane plane) { - GMM_RES_COPY_BLT gmmResourceCopyBLT = {}; - - if (plane == OCLPlane::PLANE_V) { - sys = ptrOffset(sys, height * pitch * 2); - pitch /= 2; - } else if (plane == OCLPlane::PLANE_U) { - sys = ptrOffset(sys, height * pitch * 2 + height * pitch / 2); - pitch /= 2; - } else if (plane == OCLPlane::PLANE_UV) { - sys = ptrOffset(sys, height * pitch * 2); - } - uint32_t size = pitch * height; - - gmmResourceCopyBLT.Sys.pData = sys; - gmmResourceCopyBLT.Gpu.pData = gpu; - gmmResourceCopyBLT.Sys.RowPitch = pitch; - gmmResourceCopyBLT.Blt.Upload = upload; - gmmResourceCopyBLT.Sys.BufferSize = size; - - return this->gmmResourceInfo->cpuBlt(&gmmResourceCopyBLT); -} - -bool Gmm::unifiedAuxTranslationCapable() const { - auto gmmFlags = this->gmmResourceInfo->getResourceFlags(); - return gmmFlags->Gpu.CCS && gmmFlags->Gpu.UnifiedAuxSurface && gmmFlags->Info.RenderCompressed; -} - -bool Gmm::useSimplifiedMocsTable = false; -GMM_CLIENT_CONTEXT *Gmm::gmmClientContext = nullptr; -bool Gmm::isLoaded = false; +bool GmmHelper::useSimplifiedMocsTable = false; +GMM_CLIENT_CONTEXT *GmmHelper::gmmClientContext = nullptr; +bool GmmHelper::isLoaded = false; } // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_helper.h b/runtime/gmm_helper/gmm_helper.h index ea520f23ac..e13568ce61 100644 --- a/runtime/gmm_helper/gmm_helper.h +++ b/runtime/gmm_helper/gmm_helper.h @@ -28,76 +28,46 @@ #include "runtime/api/cl_types.h" namespace OCLRT { +enum class OCLPlane; struct HardwareInfo; struct FeatureTable; struct WorkaroundTable; struct ImageInfo; class GraphicsAllocation; -class GmmResourceInfo; +class Gmm; -enum OCLPlane { - NO_PLANE = 0, - PLANE_Y, - PLANE_U, - PLANE_V, - PLANE_UV -}; - -constexpr uint32_t cacheDisabledIndex = 0; -constexpr uint32_t cacheEnabledIndex = 4; - -class Gmm { +class GmmHelper { public: - static const uint32_t maxPossiblePitch = 2147483648; + GmmHelper() = delete; + static constexpr uint32_t cacheDisabledIndex = 0; + static constexpr uint32_t cacheEnabledIndex = 4; + static constexpr uint32_t maxPossiblePitch = 2147483648; - virtual ~Gmm() = default; - - void create(); + static Gmm *createGmmAndQueryImgParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo); static Gmm *create(const void *alignedPtr, size_t alignedSize, bool uncacheable); static Gmm *create(GMM_RESOURCE_INFO *inputGmm); - static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo); static void loadLib(); + static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo); static void destroyContext(); - static uint32_t getMOCS(uint32_t type); - - void queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo); - - static Gmm *createGmmAndQueryImgParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo); - - static void queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc); - - static bool allowTiling(const cl_image_desc &imageDesc); - static uint64_t canonize(uint64_t address); static uint64_t decanonize(uint64_t address); + static uint32_t getMOCS(uint32_t type); + static void queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc); static GMM_CUBE_FACE_ENUM getCubeFaceIndex(uint32_t target); + static bool allowTiling(const cl_image_desc &imageDesc); static uint32_t getRenderTileMode(uint32_t tileWalk); + static uint32_t getRenderAlignment(uint32_t alignment); static uint32_t getRenderMultisamplesCount(uint32_t numSamples); static GMM_YUV_PLANE convertPlane(OCLPlane oclPlane); - uint32_t getRenderHAlignment(); - uint32_t getRenderVAlignment(); - static uint32_t getRenderAlignment(uint32_t alignment); - void applyAuxFlags(ImageInfo &imgInfo, const HardwareInfo &hwInfo); - bool unifiedAuxTranslationCapable() const; - - uint32_t queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType); - - void updateImgInfo(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex); - uint8_t resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, OCLPlane plane); - - GMM_RESCREATE_PARAMS resourceParams = {}; - std::unique_ptr gmmResourceInfo; - static decltype(&GmmInitGlobalContext) initGlobalContextFunc; static decltype(&GmmDestroyGlobalContext) destroyGlobalContextFunc; static decltype(&GmmCreateClientContext) createClientContextFunc; static decltype(&GmmDeleteClientContext) deleteClientContextFunc; - bool isRenderCompressed = false; static bool useSimplifiedMocsTable; static GMM_CLIENT_CONTEXT *gmmClientContext; static bool isLoaded; diff --git a/runtime/gmm_helper/gmm_memory_base.cpp b/runtime/gmm_helper/gmm_memory_base.cpp index 8dffff562a..c2335e6553 100644 --- a/runtime/gmm_helper/gmm_memory_base.cpp +++ b/runtime/gmm_helper/gmm_memory_base.cpp @@ -33,7 +33,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, BOOLEAN BDWL3Coherency, GMM_GFX_SIZE_T SizeOverride, GMM_GFX_SIZE_T SlmGfxSpaceReserve) { - return Gmm::gmmClientContext->ConfigureDeviceAddressSpace( + return GmmHelper::gmmClientContext->ConfigureDeviceAddressSpace( {hAdapter}, {hDevice}, {pfnEscape}, @@ -46,7 +46,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, } uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() { - return static_cast(Gmm::gmmClientContext->GetInternalGpuVaRangeLimit()); + return static_cast(GmmHelper::gmmClientContext->GetInternalGpuVaRangeLimit()); } }; // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_utils.cpp b/runtime/gmm_helper/gmm_utils.cpp index e6fb4d6ea9..909ef496ae 100644 --- a/runtime/gmm_helper/gmm_utils.cpp +++ b/runtime/gmm_helper/gmm_utils.cpp @@ -20,7 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/helpers/hw_info.h" #include "runtime/helpers/surface_formats.h" diff --git a/runtime/gmm_helper/page_table_mngr_impl.cpp b/runtime/gmm_helper/page_table_mngr_impl.cpp index 134d8c2964..e104e1bb05 100644 --- a/runtime/gmm_helper/page_table_mngr_impl.cpp +++ b/runtime/gmm_helper/page_table_mngr_impl.cpp @@ -25,11 +25,11 @@ namespace OCLRT { void GmmPageTableMngr::customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager) { - Gmm::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager); + GmmHelper::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager); } GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { - auto pageTableMngrPtr = Gmm::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags); + auto pageTableMngrPtr = GmmHelper::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags); this->pageTableManager = UniquePtrType(pageTableMngrPtr, GmmPageTableMngr::customDeleter); } diff --git a/runtime/gmm_helper/resource_info_impl.cpp b/runtime/gmm_helper/resource_info_impl.cpp index 0c43ed7263..f689d6f69e 100644 --- a/runtime/gmm_helper/resource_info_impl.cpp +++ b/runtime/gmm_helper/resource_info_impl.cpp @@ -25,16 +25,16 @@ namespace OCLRT { void GmmResourceInfo::customDeleter(GMM_RESOURCE_INFO *gmmResourceInfo) { - Gmm::gmmClientContext->DestroyResInfoObject(gmmResourceInfo); + GmmHelper::gmmClientContext->DestroyResInfoObject(gmmResourceInfo); } GmmResourceInfo::GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams) { - auto resourceInfoPtr = Gmm::gmmClientContext->CreateResInfoObject(resourceCreateParams); + auto resourceInfoPtr = GmmHelper::gmmClientContext->CreateResInfoObject(resourceCreateParams); this->resourceInfo = UniquePtrType(resourceInfoPtr, GmmResourceInfo::customDeleter); } GmmResourceInfo::GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) { - auto resourceInfoPtr = Gmm::gmmClientContext->CopyResInfoObject(inputGmmResourceInfo); + auto resourceInfoPtr = GmmHelper::gmmClientContext->CopyResInfoObject(inputGmmResourceInfo); this->resourceInfo = UniquePtrType(resourceInfoPtr, GmmResourceInfo::customDeleter); } diff --git a/runtime/helpers/mipmap.cpp b/runtime/helpers/mipmap.cpp index ab5d51a7a8..bd02d3b276 100644 --- a/runtime/helpers/mipmap.cpp +++ b/runtime/helpers/mipmap.cpp @@ -22,7 +22,7 @@ #include "runtime/helpers/mipmap.h" -#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/mem_obj/image.h" diff --git a/runtime/helpers/state_base_address.inl b/runtime/helpers/state_base_address.inl index ba784eeec8..7b43fcf273 100644 --- a/runtime/helpers/state_base_address.inl +++ b/runtime/helpers/state_base_address.inl @@ -67,7 +67,7 @@ void StateBaseAddressHelper::programStateBaseAddress( pCmd->setInstructionBufferSize(MemoryConstants::sizeOf4GBinPageEntities); //set cache settings - pCmd->setStatelessDataPortAccessMemoryObjectControlState(Gmm::getMOCS(statelessMocsIndex)); - pCmd->setInstructionMemoryObjectControlState(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER)); + pCmd->setStatelessDataPortAccessMemoryObjectControlState(GmmHelper::getMOCS(statelessMocsIndex)); + pCmd->setInstructionMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER)); } } // namespace OCLRT diff --git a/runtime/helpers/surface_formats.h b/runtime/helpers/surface_formats.h index 7ffea97272..7ba569c77e 100644 --- a/runtime/helpers/surface_formats.h +++ b/runtime/helpers/surface_formats.h @@ -201,6 +201,14 @@ enum GFX3DSTATE_SURFACEFORMAT : unsigned short { NUM_GFX3DSTATE_SURFACEFORMATS }; +enum class OCLPlane { + NO_PLANE = 0, + PLANE_Y, + PLANE_U, + PLANE_V, + PLANE_UV +}; + struct SurfaceFormatInfo { cl_image_format OCLImageFormat; GMM_RESOURCE_FORMAT GMMSurfaceFormat; diff --git a/runtime/mem_obj/buffer.inl b/runtime/mem_obj/buffer.inl index 1f16109160..416445226e 100644 --- a/runtime/mem_obj/buffer.inl +++ b/runtime/mem_obj/buffer.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -73,9 +73,9 @@ void BufferHw::setArgStateful(void *memory) { if ((isAligned(bufferAddress) && isAligned(bufferSize)) || ((getFlags() & CL_MEM_READ_ONLY)) != 0) { - surfaceState->setMemoryObjectControlState(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER)); + surfaceState->setMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER)); } else { - surfaceState->setMemoryObjectControlState(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED)); + surfaceState->setMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED)); } surfaceState->setCoherencyType(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT); diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index 3f6205e1ca..0903b89df8 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -36,6 +36,7 @@ #include "runtime/mem_obj/buffer.h" #include "runtime/memory_manager/memory_manager.h" #include "runtime/os_interface/debug_settings_manager.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" #include "igfxfmid.h" @@ -190,7 +191,7 @@ 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; - auto isTilingAllowed = context->isSharedContext ? false : Gmm::allowTiling(*imageDesc); + auto isTilingAllowed = context->isSharedContext ? false : GmmHelper::allowTiling(*imageDesc); imgInfo.preferRenderCompression = isTilingAllowed; bool zeroCopy = false; @@ -205,7 +206,7 @@ Image *Image::create(Context *context, hostPtr = parentBuffer->getHostPtr(); hostPtrToSet = const_cast(hostPtr); parentBuffer->incRefInternal(); - Gmm::queryImgFromBufferParams(imgInfo, memory); + GmmHelper::queryImgFromBufferParams(imgInfo, memory); UNRECOVERABLE_IF(imgInfo.offset != 0); imgInfo.offset = parentBuffer->getOffset(); @@ -213,7 +214,7 @@ Image *Image::create(Context *context, if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) { // Retrieve sizes from GMM and apply virtual padding if buffer storage is not big enough auto queryGmmImgInfo(imgInfo); - std::unique_ptr gmm(Gmm::createGmmAndQueryImgParams(queryGmmImgInfo, hwInfo)); + std::unique_ptr gmm(GmmHelper::createGmmAndQueryImgParams(queryGmmImgInfo, hwInfo)); auto gmmAllocationSize = gmm->gmmResourceInfo->getSizeAllocation(); if (gmmAllocationSize > memory->getUnderlyingBufferSize()) { memory = memoryManager->createGraphicsAllocationWithPadding(memory, gmmAllocationSize); @@ -399,7 +400,7 @@ Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation, cl_mem_flags flags, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) { auto tileWalk = graphicsAllocation->gmm->gmmResourceInfo->getTileType(); - auto tileMode = Gmm::getRenderTileMode(tileWalk); + auto tileMode = GmmHelper::getRenderTileMode(tileWalk); bool isTiledImage = tileMode ? true : false; auto sharedImage = createImageHw(context, flags, graphicsAllocation->getUnderlyingBufferSize(), diff --git a/runtime/mem_obj/image.inl b/runtime/mem_obj/image.inl index afe9309d8a..22ea529f5a 100644 --- a/runtime/mem_obj/image.inl +++ b/runtime/mem_obj/image.inl @@ -24,6 +24,7 @@ #include "runtime/helpers/surface_formats.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/mem_obj/image.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" @@ -148,11 +149,11 @@ void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, ui } } else { auto tileWalk = gmm->gmmResourceInfo->getTileType(); - tileMode = static_cast(Gmm::getRenderTileMode(tileWalk)); + tileMode = static_cast(GmmHelper::getRenderTileMode(tileWalk)); } surfaceState->setTileMode(tileMode); - surfaceState->setMemoryObjectControlState(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE)); + surfaceState->setMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE)); surfaceState->setXOffset(this->surfaceOffsets.xOffset); surfaceState->setYOffset(this->surfaceOffsets.yOffset); @@ -240,7 +241,7 @@ void ImageHw::setMediaImageArg(void *memory) { setSurfaceMemoryObjectControlStateIndexToMocsTable( reinterpret_cast(surfaceState), - Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE)); + GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE)); if (IsNV12Image(&this->getImageFormat())) { surfaceState->setInterleaveChroma(true); diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index e16ad5690a..c439032db7 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -20,7 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/memory_manager/deferred_deleter.h" #include "runtime/memory_manager/memory_manager.h" diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index b9ca2cc3d6..dd665ab278 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -22,6 +22,7 @@ #include "runtime/helpers/basic_math.h" #include "runtime/helpers/aligned_memory.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/helpers/options.h" @@ -75,9 +76,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t return nullptr; } uint64_t offset = static_cast(reinterpret_cast(ptr) & MemoryConstants::pageMask); - MemoryAllocation *memAlloc = new MemoryAllocation(false, reinterpret_cast(ptr), Gmm::canonize(gpuVirtualAddress + offset), size, counter); + MemoryAllocation *memAlloc = new MemoryAllocation(false, reinterpret_cast(ptr), GmmHelper::canonize(gpuVirtualAddress + offset), size, counter); memAlloc->is32BitAllocation = true; - memAlloc->gpuBaseAddress = Gmm::canonize(allocator32Bit->getBase()); + memAlloc->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase()); memAlloc->sizeToFree = allocationSize; counter++; @@ -93,9 +94,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t MemoryAllocation *memoryAllocation = nullptr; if (ptrAlloc != nullptr) { - memoryAllocation = new MemoryAllocation(true, ptrAlloc, Gmm::canonize(gpuAddress), size, counter); + memoryAllocation = new MemoryAllocation(true, ptrAlloc, GmmHelper::canonize(gpuAddress), size, counter); memoryAllocation->is32BitAllocation = true; - memoryAllocation->gpuBaseAddress = Gmm::canonize(allocator32Bit->getBase()); + memoryAllocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase()); memoryAllocation->sizeToFree = allocationSize; memoryAllocation->cpuPtrAllocated = true; } diff --git a/runtime/os_interface/linux/device_factory.cpp b/runtime/os_interface/linux/device_factory.cpp index c6f30f4832..fb00f67008 100644 --- a/runtime/os_interface/linux/device_factory.cpp +++ b/runtime/os_interface/linux/device_factory.cpp @@ -75,8 +75,8 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) { DeviceFactory::numDevices = devNum; DeviceFactory::hwInfos = ptr; - return Gmm::initContext(hwInfos->pPlatform, hwInfos->pSkuTable, - hwInfos->pWaTable, hwInfos->pSysInfo); + return GmmHelper::initContext(hwInfos->pPlatform, hwInfos->pSkuTable, + hwInfos->pWaTable, hwInfos->pSysInfo); } void DeviceFactory::releaseDevices() { diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 161e253382..cfb8587ab3 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -34,6 +34,7 @@ #include "drm/i915_drm.h" #include "drm/drm.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" @@ -209,7 +210,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t } GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) { - if (!Gmm::allowTiling(*imgInfo.imgDesc)) { + if (!GmmHelper::allowTiling(*imgInfo.imgDesc)) { auto alloc = allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment); if (alloc) { alloc->gmm = gmm; diff --git a/runtime/os_interface/linux/gmm_interface_linux.cpp b/runtime/os_interface/linux/gmm_interface_linux.cpp index d691d9c9bd..06623da381 100644 --- a/runtime/os_interface/linux/gmm_interface_linux.cpp +++ b/runtime/os_interface/linux/gmm_interface_linux.cpp @@ -24,16 +24,16 @@ namespace OCLRT { -decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr; -decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr; -decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr; -decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr; +decltype(GmmHelper::initGlobalContextFunc) GmmHelper::initGlobalContextFunc = nullptr; +decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFunc = nullptr; +decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr; +decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr; -void Gmm::loadLib() { - Gmm::initGlobalContextFunc = GmmInitGlobalContext; - Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext; - Gmm::createClientContextFunc = GmmCreateClientContext; - Gmm::deleteClientContextFunc = GmmDeleteClientContext; +void GmmHelper::loadLib() { + GmmHelper::initGlobalContextFunc = GmmInitGlobalContext; + GmmHelper::destroyGlobalContextFunc = GmmDestroyGlobalContext; + GmmHelper::createClientContextFunc = GmmCreateClientContext; + GmmHelper::deleteClientContextFunc = GmmDeleteClientContext; isLoaded = true; } } // namespace OCLRT diff --git a/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp b/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp index 039f56b799..321c4cb721 100644 --- a/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp +++ b/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp @@ -34,13 +34,13 @@ GMM_STATUS(GMM_STDCALL *myPfnCreateSingletonContext) GMM_STATUS GMM_STDCALL myGmmInitGlobalContext(const PLATFORM Platform, const SKU_FEATURE_TABLE *pSkuTable, const WA_TABLE *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo, GMM_CLIENT ClientType) { return myPfnCreateSingletonContext(Platform, pSkuTable, pWaTable, pGtSysInfo); } -decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = &myGmmInitGlobalContext; -decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr; -decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr; -decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr; +decltype(GmmHelper::initGlobalContextFunc) GmmHelper::initGlobalContextFunc = &myGmmInitGlobalContext; +decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFunc = nullptr; +decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr; +decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr; std::unique_ptr gmmLib; -void Gmm::loadLib() { +void GmmHelper::loadLib() { gmmLib.reset(OsLibrary::load(Os::gmmDllName)); UNRECOVERABLE_IF(!gmmLib); @@ -50,10 +50,10 @@ void Gmm::loadLib() { auto status = openGmmFunc(&entries); if (status == GMM_SUCCESS) { myPfnCreateSingletonContext = entries.pfnCreateSingletonContext; - Gmm::destroyGlobalContextFunc = entries.pfnDestroySingletonContext; - Gmm::createClientContextFunc = entries.pfnCreateClientContext; - Gmm::deleteClientContextFunc = entries.pfnDeleteClientContext; - isLoaded = myPfnCreateSingletonContext && Gmm::destroyGlobalContextFunc && Gmm::createClientContextFunc && Gmm::deleteClientContextFunc; + GmmHelper::destroyGlobalContextFunc = entries.pfnDestroySingletonContext; + GmmHelper::createClientContextFunc = entries.pfnCreateClientContext; + GmmHelper::deleteClientContextFunc = entries.pfnDeleteClientContext; + isLoaded = myPfnCreateSingletonContext && GmmHelper::destroyGlobalContextFunc && GmmHelper::createClientContextFunc && GmmHelper::deleteClientContextFunc; } } UNRECOVERABLE_IF(!isLoaded); diff --git a/runtime/os_interface/windows/gmm_interface_static_win.cpp b/runtime/os_interface/windows/gmm_interface_static_win.cpp index dd4abce0dd..3539fcd87e 100644 --- a/runtime/os_interface/windows/gmm_interface_static_win.cpp +++ b/runtime/os_interface/windows/gmm_interface_static_win.cpp @@ -24,16 +24,16 @@ namespace OCLRT { -decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr; -decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr; -decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr; -decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr; +decltype(GmmHelper::initGlobalContextFunc) GmmHelper::initGlobalContextFunc = nullptr; +decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFunc = nullptr; +decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr; +decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr; -void Gmm::loadLib() { - Gmm::initGlobalContextFunc = GmmInitGlobalContext; - Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext; - Gmm::createClientContextFunc = GmmCreateClientContext; - Gmm::deleteClientContextFunc = GmmDeleteClientContext; +void GmmHelper::loadLib() { + GmmHelper::initGlobalContextFunc = GmmInitGlobalContext; + GmmHelper::destroyGlobalContextFunc = GmmDestroyGlobalContext; + GmmHelper::createClientContextFunc = GmmCreateClientContext; + GmmHelper::deleteClientContextFunc = GmmDeleteClientContext; isLoaded = true; } } // namespace OCLRT diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index fc94de1f99..e362b1ce22 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -24,6 +24,7 @@ #include "runtime/helpers/options.h" #include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/kmdaf_listener.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/gmm_helper/page_table_mngr.h" @@ -395,7 +396,7 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr } status = gdi->mapGpuVirtualAddress(&MapGPUVA); - gpuPtr = Gmm::canonize(MapGPUVA.VirtualAddress); + gpuPtr = GmmHelper::canonize(MapGPUVA.VirtualAddress); if (status == STATUS_PENDING) { interlockedMax(currentPagingFenceValue, MapGPUVA.PagingFenceValue); @@ -420,7 +421,7 @@ bool Wddm::freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) { NTSTATUS status = STATUS_SUCCESS; D3DKMT_FREEGPUVIRTUALADDRESS FreeGPUVA = {0}; FreeGPUVA.hAdapter = adapter; - FreeGPUVA.BaseAddress = Gmm::decanonize(gpuPtr); + FreeGPUVA.BaseAddress = GmmHelper::decanonize(gpuPtr); FreeGPUVA.Size = size; status = gdi->freeGpuVirtualAddress(&FreeGPUVA); @@ -632,7 +633,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) { alloc->handle = allocationInfo[0].hAllocation; alloc->resourceHandle = OpenResource.hResource; - alloc->gmm = Gmm::create((PGMM_RESOURCE_INFO)(allocationInfo[0].pPrivateDriverData)); + alloc->gmm = GmmHelper::create((PGMM_RESOURCE_INFO)(allocationInfo[0].pPrivateDriverData)); return true; } @@ -668,7 +669,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) { alloc->handle = allocationInfo2[0].hAllocation; alloc->resourceHandle = openResourceFromNtHandle.hResource; - alloc->gmm = Gmm::create((PGMM_RESOURCE_INFO)(allocationInfo2[0].pPrivateDriverData)); + alloc->gmm = GmmHelper::create((PGMM_RESOURCE_INFO)(allocationInfo2[0].pPrivateDriverData)); return true; } diff --git a/runtime/os_interface/windows/wddm/wddm.h b/runtime/os_interface/windows/wddm/wddm.h index 2af9600335..cea29eabd6 100644 --- a/runtime/os_interface/windows/wddm/wddm.h +++ b/runtime/os_interface/windows/wddm/wddm.h @@ -31,7 +31,6 @@ #include "runtime/memory_manager/host_ptr_defines.h" #include "runtime/utilities/debug_settings_reader.h" #include "runtime/gmm_helper/gmm_lib.h" -#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/hw_info.h" #include "gmm_memory.h" #include diff --git a/runtime/os_interface/windows/wddm/wddm_calls.cpp b/runtime/os_interface/windows/wddm/wddm_calls.cpp index 248b4ace8b..10a4f50a5f 100644 --- a/runtime/os_interface/windows/wddm/wddm_calls.cpp +++ b/runtime/os_interface/windows/wddm/wddm_calls.cpp @@ -42,13 +42,13 @@ Wddm::VirtualAllocFcn getVirtualAlloc() { } bool Wddm::initGmmContext() { - return Gmm::initContext(gfxPlatform.get(), - featureTable.get(), - waTable.get(), - gtSystemInfo.get()); + return GmmHelper::initContext(gfxPlatform.get(), + featureTable.get(), + waTable.get(), + gtSystemInfo.get()); } void Wddm::destroyGmmContext() { - Gmm::destroyContext(); + GmmHelper::destroyContext(); } } // namespace OCLRT diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index ffd99d2bd3..8ca4447719 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -24,6 +24,7 @@ #include "runtime/device/device.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/ptr_math.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/surface_formats.h" @@ -60,7 +61,7 @@ void APIENTRY WddmMemoryManager::trimCallback(_Inout_ D3DKMT_TRIMNOTIFICATION *t } GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) { - if (!Gmm::allowTiling(*imgInfo.imgDesc) && imgInfo.mipCount == 0) { + if (!GmmHelper::allowTiling(*imgInfo.imgDesc) && imgInfo.mipCount == 0) { delete gmm; return allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment); } @@ -80,7 +81,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s auto wddmAllocation = new WddmAllocation(nullptr, sizeAligned, nullptr, sizeAligned, nullptr); - gmm = Gmm::create(nullptr, sizeAligned, false); + gmm = GmmHelper::create(nullptr, sizeAligned, false); wddmAllocation->gmm = gmm; if (!wddm->createAllocation64k(wddmAllocation)) { @@ -114,7 +115,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_ auto wddmAllocation = new WddmAllocation(pSysMem, sizeAligned, pSysMem, sizeAligned, nullptr); wddmAllocation->cpuPtrAllocated = true; - gmm = Gmm::create(pSysMem, sizeAligned, uncacheable); + gmm = GmmHelper::create(pSysMem, sizeAligned, uncacheable); wddmAllocation->gmm = gmm; @@ -149,7 +150,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, const auto allocation = new WddmAllocation(ptr, size, ptrAligned, sizeAligned, reserve); allocation->allocationOffset = offset; - Gmm *gmm = Gmm::create(ptrAligned, sizeAligned, false); + Gmm *gmm = GmmHelper::create(ptrAligned, sizeAligned, false); allocation->gmm = gmm; if (createWddmAllocation(allocation, AllocationOrigin::EXTERNAL_ALLOCATION)) { return allocation; @@ -188,7 +189,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size, wddmAllocation->is32BitAllocation = true; wddmAllocation->allocationOffset = offset; - gmm = Gmm::create(ptrAligned, sizeAligned, false); + gmm = GmmHelper::create(ptrAligned, sizeAligned, false); wddmAllocation->gmm = gmm; if (!createWddmAllocation(wddmAllocation, allocationOrigin)) { @@ -200,7 +201,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size, wddmAllocation->is32BitAllocation = true; auto baseAddress = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit->getBase() : this->wddm->getGfxPartition().Heap32[1].Base; - wddmAllocation->gpuBaseAddress = Gmm::canonize(baseAddress); + wddmAllocation->gpuBaseAddress = GmmHelper::canonize(baseAddress); return wddmAllocation; } @@ -231,7 +232,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl } else if (requireSpecificBitness && this->force32bitAllocations) { is32BitAllocation = true; allocation->is32BitAllocation = true; - allocation->gpuBaseAddress = Gmm::canonize(allocator32Bit->getBase()); + allocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase()); } status = wddm->mapGpuVirtualAddress(allocation, ptr, size, is32BitAllocation, false, false); DEBUG_BREAK_IF(!status); @@ -363,7 +364,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[i].residency = new ResidencyData(); - handleStorage.fragmentStorageData[i].osHandleStorage->gmm = Gmm::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false); + handleStorage.fragmentStorageData[i].osHandleStorage->gmm = GmmHelper::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false); allocatedFragmentIndexes[allocatedFragmentsCounter] = i; allocatedFragmentsCounter++; } diff --git a/runtime/sharings/d3d/d3d_sharing.cpp b/runtime/sharings/d3d/d3d_sharing.cpp index b26ea34ac2..09f94bfc19 100644 --- a/runtime/sharings/d3d/d3d_sharing.cpp +++ b/runtime/sharings/d3d/d3d_sharing.cpp @@ -23,7 +23,7 @@ #include "runtime/sharings/d3d/d3d_sharing.h" #include "runtime/context/context.h" #include "runtime/mem_obj/image.h" -#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" using namespace OCLRT; diff --git a/runtime/sharings/d3d/d3d_sharing.h b/runtime/sharings/d3d/d3d_sharing.h index d9c54b4680..4d830fa530 100644 --- a/runtime/sharings/d3d/d3d_sharing.h +++ b/runtime/sharings/d3d/d3d_sharing.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,11 +26,11 @@ enum GMM_RESOURCE_FORMAT_ENUM; namespace OCLRT { +enum class OCLPlane; class Context; class Gmm; struct SurfaceFormatInfo; struct ImageInfo; -enum OCLPlane; template class D3DSharing : public SharingHandler { diff --git a/runtime/sharings/d3d/d3d_surface.cpp b/runtime/sharings/d3d/d3d_surface.cpp index 0ea01a7e37..bcfcd8d0d2 100644 --- a/runtime/sharings/d3d/d3d_surface.cpp +++ b/runtime/sharings/d3d/d3d_surface.cpp @@ -27,6 +27,7 @@ #include "runtime/helpers/get_info.h" #include "runtime/memory_manager/memory_manager.h" #include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" #include "mmsystem.h" using namespace OCLRT; @@ -81,7 +82,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo return nullptr; } - imgInfo.plane = Gmm::convertPlane(oclPlane); + imgInfo.plane = GmmHelper::convertPlane(oclPlane); imgInfo.surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imgFormat); bool isSharedResource = false; @@ -101,7 +102,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo imgDesc.image_width /= 2; imgDesc.image_height /= 2; } - Gmm *gmm = Gmm::createGmmAndQueryImgParams(imgInfo, context->getDevice(0)->getHardwareInfo()); + Gmm *gmm = GmmHelper::createGmmAndQueryImgParams(imgInfo, context->getDevice(0)->getHardwareInfo()); imgDesc.image_row_pitch = imgInfo.rowPitch; imgDesc.image_slice_pitch = imgInfo.slicePitch; diff --git a/runtime/sharings/d3d/d3d_surface.h b/runtime/sharings/d3d/d3d_surface.h index 18ff4e029a..def276229f 100644 --- a/runtime/sharings/d3d/d3d_surface.h +++ b/runtime/sharings/d3d/d3d_surface.h @@ -25,9 +25,9 @@ struct ErrorCodeHelper; namespace OCLRT { +enum class OCLPlane; class Image; class Context; -enum OCLPlane; class D3DSurface : public D3DSharing { typedef typename D3DTypesHelper::D3D9::D3DTexture2dDesc D3D9SurfaceDesc; diff --git a/runtime/sharings/d3d/d3d_texture.cpp b/runtime/sharings/d3d/d3d_texture.cpp index cc4a65692b..e5a75f8204 100644 --- a/runtime/sharings/d3d/d3d_texture.cpp +++ b/runtime/sharings/d3d/d3d_texture.cpp @@ -22,6 +22,7 @@ #include "runtime/context/context.h" #include "runtime/device/device.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/get_info.h" @@ -57,7 +58,7 @@ Image *D3DTexture::create2d(Context *context, D3DTexture2d *d3dTexture, cl_ } else { oclPlane = OCLPlane::PLANE_UV; } - imgInfo.plane = Gmm::convertPlane(oclPlane); + imgInfo.plane = GmmHelper::convertPlane(oclPlane); arrayIndex = subresource / 2u; } else if (subresource >= textureDesc.MipLevels * textureDesc.ArraySize) { err.set(CL_INVALID_VALUE); diff --git a/runtime/sharings/va/va_surface.cpp b/runtime/sharings/va/va_surface.cpp index fd30f48e31..117968b604 100644 --- a/runtime/sharings/va/va_surface.cpp +++ b/runtime/sharings/va/va_surface.cpp @@ -27,6 +27,7 @@ #include "runtime/memory_manager/memory_manager.h" #include "runtime/helpers/get_info.h" #include "runtime/helpers/hw_info.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" namespace OCLRT { @@ -75,7 +76,7 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false, true); - Gmm *gmm = Gmm::createGmmAndQueryImgParams(imgInfo, hwInfo); + Gmm *gmm = GmmHelper::createGmmAndQueryImgParams(imgInfo, hwInfo); DEBUG_BREAK_IF(alloc->gmm != nullptr); alloc->gmm = gmm; diff --git a/unit_tests/command_queue/multiple_map_image_tests.cpp b/unit_tests/command_queue/multiple_map_image_tests.cpp index f27b5606df..c452684c8a 100644 --- a/unit_tests/command_queue/multiple_map_image_tests.cpp +++ b/unit_tests/command_queue/multiple_map_image_tests.cpp @@ -103,7 +103,7 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test { template std::unique_ptr> createMockImage() { auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemory(1024); - auto tiledImage = Gmm::allowTiling(Traits::imageDesc); + auto tiledImage = GmmHelper::allowTiling(Traits::imageDesc); auto surfaceFormat = Image::getSurfaceFormatFromTable(Traits::flags, &Traits::imageFormat); auto img = new MockImage(context, Traits::flags, 1024, Traits::hostPtr, diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp index c92b8fb979..be3b364856 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp @@ -52,7 +52,6 @@ #include "test.h" #include "gtest/gtest.h" #include "runtime/utilities/linux/debug_env_reader.h" -#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/command_queue/gpgpu_walker.h" using namespace OCLRT; diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp index 5eff66823a..1c21a46b51 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp @@ -435,8 +435,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, stateBaseAddressTracking) { HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, stateBaseAddressProgrammingShouldMatchTracking) { typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS; - auto stateHeapMocs = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER); - auto l3CacheOnMocs = Gmm::getMOCS(CacheSettings::l3CacheOn); + auto stateHeapMocs = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER); + auto l3CacheOnMocs = GmmHelper::getMOCS(CacheSettings::l3CacheOn); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); flushTask(commandStreamReceiver); diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 9c3efa95b7..88b9096752 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -51,7 +51,6 @@ #include "unit_tests/libult/create_command_stream.h" #include "test.h" #include "runtime/utilities/linux/debug_env_reader.h" -#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/command_queue/gpgpu_walker.h" #include diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 52aa071052..49ce46a44f 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -26,6 +26,7 @@ #include "runtime/helpers/options.h" #include "runtime/helpers/ptr_math.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "unit_tests/mocks/mock_device.h" #include "unit_tests/mocks/mock_gmm.h" @@ -39,7 +40,7 @@ class GmmTests : public ::testing::Test { TEST_F(GmmTests, resourceCreation) { std::unique_ptr mm(new OsAgnosticMemoryManager); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096, false)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -54,7 +55,7 @@ TEST_F(GmmTests, resourceCreationUncacheable) { std::unique_ptr mm(new OsAgnosticMemoryManager); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096, true)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096, true)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -70,7 +71,7 @@ TEST_F(GmmTests, resourceCleanupOnDelete) { std::unique_ptr mm(new OsAgnosticMemoryManager); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096, false)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -78,12 +79,12 @@ TEST_F(GmmTests, resourceCleanupOnDelete) { } TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMMResourceIsCreatedWithNoRestrictionsFlag) { - auto maxSize = Gmm::maxPossiblePitch; + auto maxSize = GmmHelper::maxPossiblePitch; MemoryManager *mm = new OsAgnosticMemoryManager; void *pSysMem = mm->allocateSystemMemory(4096, 4096); - auto gmmRes = Gmm::create(pSysMem, maxSize, false); + auto gmmRes = GmmHelper::create(pSysMem, maxSize, false); ASSERT_TRUE(gmmRes->gmmResourceInfo.get() != nullptr); @@ -96,8 +97,8 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM TEST_F(GmmTests, givenGmmCreatedFromExistingGmmThenHelperDoesNotReleaseParentGmm) { auto size = 4096u; void *incomingPtr = (void *)0x1000; - auto gmmRes = Gmm::create(incomingPtr, size, false); - auto gmmRes2 = Gmm::create(gmmRes->gmmResourceInfo->peekHandle()); + auto gmmRes = GmmHelper::create(incomingPtr, size, false); + auto gmmRes2 = GmmHelper::create(gmmRes->gmmResourceInfo->peekHandle()); //copy is being made EXPECT_NE(gmmRes2->gmmResourceInfo->peekHandle(), gmmRes->gmmResourceInfo->peekHandle()); @@ -249,7 +250,7 @@ TEST_F(GmmTests, givenZeroRowPitchWhenQueryImgFromBufferParamsThenCalculate) { auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); size_t expectedRowPitch = imgDesc.image_width * imgInfo.surfaceFormat->ImageElementSizeInBytes; - MockGmm::queryImgFromBufferParams(imgInfo, &bufferAllocation); + GmmHelper::queryImgFromBufferParams(imgInfo, &bufferAllocation); EXPECT_EQ(imgInfo.rowPitch, expectedRowPitch); } @@ -265,7 +266,7 @@ TEST_F(GmmTests, givenNonZeroRowPitchWhenQueryImgFromBufferParamsThenUseUserValu size_t expectedRowPitch = imgDesc.image_row_pitch; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - MockGmm::queryImgFromBufferParams(imgInfo, &bufferAllocation); + GmmHelper::queryImgFromBufferParams(imgInfo, &bufferAllocation); EXPECT_EQ(imgInfo.rowPitch, expectedRowPitch); } @@ -273,34 +274,34 @@ TEST_F(GmmTests, givenNonZeroRowPitchWhenQueryImgFromBufferParamsThenUseUserValu TEST_F(GmmTests, canonize) { uint64_t addr1 = 0x7777777777777777; uint64_t addrExpected1 = 0x0000777777777777; - EXPECT_EQ(Gmm::canonize(addr1), addrExpected1); + EXPECT_EQ(GmmHelper::canonize(addr1), addrExpected1); uint64_t addr2 = 0x7FFFFFFFFFFFFFFF; uint64_t addrExpected2 = 0xFFFFFFFFFFFFFFFF; - EXPECT_EQ(Gmm::canonize(addr2), addrExpected2); + EXPECT_EQ(GmmHelper::canonize(addr2), addrExpected2); } TEST_F(GmmTests, decanonize) { uint64_t addr1 = 0x7777777777777777; uint64_t addrExpected1 = 0x0000777777777777; - EXPECT_EQ(Gmm::decanonize(addr1), addrExpected1); + EXPECT_EQ(GmmHelper::decanonize(addr1), addrExpected1); uint64_t addr2 = 0x7FFFFFFFFFFFFFFF; uint64_t addrExpected2 = 0x0000FFFFFFFFFFFF; - EXPECT_EQ(Gmm::decanonize(addr2), addrExpected2); + EXPECT_EQ(GmmHelper::decanonize(addr2), addrExpected2); } TEST_F(GmmTests, returnRenderAlignment) { uint32_t tileModes[4][2] = {{0, 2}, {1, 3}, {2, 1}, {3, 0}}; // {given, expected} for (uint32_t i = 0; i < 4; i++) { - EXPECT_EQ(Gmm::getRenderTileMode(tileModes[i][0]), tileModes[i][1]); + EXPECT_EQ(GmmHelper::getRenderTileMode(tileModes[i][0]), tileModes[i][1]); } } TEST_F(GmmTests, returnRenderTileMode) { uint32_t alignments[5][2] = {{0, 1}, {4, 1}, {8, 2}, {16, 3}, {20, 1}}; // {given, expected} for (uint32_t i = 0; i < 5; i++) { - EXPECT_EQ(Gmm::getRenderAlignment(alignments[i][0]), alignments[i][1]); + EXPECT_EQ(GmmHelper::getRenderAlignment(alignments[i][0]), alignments[i][1]); } } @@ -322,7 +323,7 @@ TEST_F(GmmTests, givenMipmapedInputWhenAskedForHalingThenNonDefaultValueIsReturn TEST_F(GmmTests, givenNumSamplesWhenAskedForMultisamplesCountThenReturnValue) { uint32_t numSamples[5][2] = {{0, 0}, {2, 1}, {4, 2}, {8, 3}, {16, 4}}; //{given, expected} for (int i = 0; i < 5; i++) { - auto result = Gmm::getRenderMultisamplesCount(numSamples[i][0]); + auto result = GmmHelper::getRenderMultisamplesCount(numSamples[i][0]); EXPECT_EQ(numSamples[i][1], result); } } @@ -345,7 +346,7 @@ class GmmTiling : public GmmTests, public ::testing::WithParamInterface { public: void checkTiling(cl_image_desc &imgDesc, bool forceLinear) { - bool allowTiling = Gmm::allowTiling(imgDesc); + bool allowTiling = GmmHelper::allowTiling(imgDesc); if (forceLinear) { EXPECT_FALSE(allowTiling); } else { @@ -413,7 +414,7 @@ TEST_F(GmmTests, converOclPlaneToGmmPlane) { {OCLPlane::PLANE_V, GMM_YUV_PLANE::GMM_PLANE_V}}; for (auto p : v) { - EXPECT_TRUE(p.second == Gmm::convertPlane(p.first)); + EXPECT_TRUE(p.second == GmmHelper::convertPlane(p.first)); } } @@ -569,7 +570,7 @@ TEST_F(GmmTests, copyResourceBlt) { } TEST(GmmTest, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenReturnTrue) { - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setUnifiedAuxTranslationCapable(); @@ -581,7 +582,7 @@ TEST(GmmTest, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenR } TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThenReturnFalse) { - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->mockResourceCreateParams.Flags.Gpu.CCS = 0; @@ -600,23 +601,23 @@ TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThe TEST(GmmTest, whenContextIsInitializedMultipleTimesThenDontOverride) { const HardwareInfo *hwinfo = *platformDevices; - EXPECT_TRUE(Gmm::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); - auto currentClientContext = Gmm::gmmClientContext; + EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); + auto currentClientContext = GmmHelper::gmmClientContext; - EXPECT_TRUE(Gmm::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); + EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); - EXPECT_EQ(currentClientContext, Gmm::gmmClientContext); + EXPECT_EQ(currentClientContext, GmmHelper::gmmClientContext); } TEST(GmmTest, whenContextIsDestroyedMultimpleTimesThenDontCrash) { const HardwareInfo *hwinfo = *platformDevices; - EXPECT_TRUE(Gmm::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); + EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); - Gmm::destroyContext(); - EXPECT_EQ(nullptr, Gmm::gmmClientContext); - Gmm::destroyContext(); + GmmHelper::destroyContext(); + EXPECT_EQ(nullptr, GmmHelper::gmmClientContext); + GmmHelper::destroyContext(); - EXPECT_TRUE(Gmm::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); + EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); } TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { @@ -648,19 +649,19 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { } TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicyWhenItIsAskedForUncachedIndexThen0IsReturned) { - Gmm::useSimplifiedMocsTable = true; - auto index = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); - auto expectedIndex = cacheDisabledIndex; + GmmHelper::useSimplifiedMocsTable = true; + auto index = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); + auto expectedIndex = GmmHelper::cacheDisabledIndex; EXPECT_EQ(expectedIndex, index); - Gmm::useSimplifiedMocsTable = false; + GmmHelper::useSimplifiedMocsTable = false; } TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicyWhenItIsAskedForCachedIndexThen4IsReturned) { - Gmm::useSimplifiedMocsTable = true; - auto index = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto expectedIndex = cacheEnabledIndex; + GmmHelper::useSimplifiedMocsTable = true; + auto index = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto expectedIndex = GmmHelper::cacheEnabledIndex; EXPECT_EQ(expectedIndex, index); - Gmm::useSimplifiedMocsTable = false; + GmmHelper::useSimplifiedMocsTable = false; } } // namespace OCLRT diff --git a/unit_tests/linux/main_linux_dll.cpp b/unit_tests/linux/main_linux_dll.cpp index b2c834df7a..b4fa5fd30b 100644 --- a/unit_tests/linux/main_linux_dll.cpp +++ b/unit_tests/linux/main_linux_dll.cpp @@ -200,7 +200,7 @@ TEST_F(DrmTests, failOnSoftPin) { } TEST_F(DrmTests, failOnParamBoost) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); @@ -210,76 +210,76 @@ TEST_F(DrmTests, failOnParamBoost) { #ifdef SUPPORT_BDW TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenBdwDeviceIsCreatedThenSimplifiedMocsSelectionIsFalse) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); useSimplifiedMocsTableBckp = false; deviceId = IBDW_GT3_WRK_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_FALSE(Gmm::useSimplifiedMocsTable); + EXPECT_FALSE(GmmHelper::useSimplifiedMocsTable); } #endif #ifdef SUPPORT_SKL TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenSklDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); useSimplifiedMocsTableBckp = false; deviceId = ISKL_GT2_DT_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_TRUE(Gmm::useSimplifiedMocsTable); + EXPECT_TRUE(GmmHelper::useSimplifiedMocsTable); } #endif #ifdef SUPPORT_KBL TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenKblDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); useSimplifiedMocsTableBckp = false; deviceId = IKBL_GT1_ULT_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_TRUE(Gmm::useSimplifiedMocsTable); + EXPECT_TRUE(GmmHelper::useSimplifiedMocsTable); } #endif #ifdef SUPPORT_BXT TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenBxtDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); useSimplifiedMocsTableBckp = false; deviceId = IBXT_X_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_TRUE(Gmm::useSimplifiedMocsTable); + EXPECT_TRUE(GmmHelper::useSimplifiedMocsTable); } #endif #ifdef SUPPORT_GLK TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenGlkDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); useSimplifiedMocsTableBckp = false; deviceId = IGLK_GT2_ULT_18EU_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_TRUE(Gmm::useSimplifiedMocsTable); + EXPECT_TRUE(GmmHelper::useSimplifiedMocsTable); } #endif #ifdef SUPPORT_CFL TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenCflDeviceIsCreatedThenSimplifiedMocsSelectionIsTrue) { - VariableBackup useSimplifiedMocsTableBckp(&Gmm::useSimplifiedMocsTable); + VariableBackup useSimplifiedMocsTableBckp(&GmmHelper::useSimplifiedMocsTable); useSimplifiedMocsTableBckp = false; deviceId = ICFL_GT1_S61_DT_DEVICE_F0_ID; failOnParamBoost = -1; auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_TRUE(Gmm::useSimplifiedMocsTable); + EXPECT_TRUE(GmmHelper::useSimplifiedMocsTable); } #endif TEST_F(DrmTests, givenKernelSupportingTurboPatchWhenDeviceIsCreatedThenSimplifiedMocsSelectionIsFalse) { auto ptr = DrmWrap::createDrm(0); EXPECT_NE(ptr, nullptr); - EXPECT_FALSE(Gmm::useSimplifiedMocsTable); + EXPECT_FALSE(GmmHelper::useSimplifiedMocsTable); } #if defined(I915_PARAM_HAS_PREEMPTION) diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index fd96944810..839e2707f5 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -142,15 +142,15 @@ LONG WINAPI UltExceptionFilter( void initializeTestHelpers() { const HardwareInfo *hwinfo = *platformDevices; - auto initialized = Gmm::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, - hwinfo->pWaTable, hwinfo->pSysInfo); + auto initialized = GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, + hwinfo->pWaTable, hwinfo->pSysInfo); ASSERT_TRUE(initialized); GlobalMockSipProgram::initSipProgram(); } void cleanTestHelpers() { GlobalMockSipProgram::shutDownSipProgram(); - Gmm::destroyContext(); + GmmHelper::destroyContext(); } std::string getHardwarePrefix() { diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index 06fbc31fa4..ec4d7e393a 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -789,7 +789,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryPtrAndSizeIsAlign ptr); auto mocs = surfaceState.getMemoryObjectControlState(); - EXPECT_EQ(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs); + EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs); alignedFree(ptr); } @@ -811,7 +811,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryPtrIsUnalignedToC offsetedPtr); auto mocs = surfaceState.getMemoryObjectControlState(); - EXPECT_EQ(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs); + EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs); alignedFree(ptr); } @@ -833,7 +833,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemorySizeIsUnalignedTo ptr); auto mocs = surfaceState.getMemoryObjectControlState(); - EXPECT_EQ(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs); + EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs); alignedFree(ptr); } @@ -857,7 +857,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryIsUnalignedToCach CL_MEM_READ_ONLY); auto mocs = surfaceState.getMemoryObjectControlState(); - EXPECT_EQ(Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs); + EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs); alignedFree(ptr); } diff --git a/unit_tests/mem_obj/image_set_arg_tests.cpp b/unit_tests/mem_obj/image_set_arg_tests.cpp index 73611efc89..7fefd59895 100644 --- a/unit_tests/mem_obj/image_set_arg_tests.cpp +++ b/unit_tests/mem_obj/image_set_arg_tests.cpp @@ -21,6 +21,7 @@ */ #include "hw_cmds.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/surface_formats.h" #include "runtime/helpers/ptr_math.h" @@ -250,7 +251,7 @@ HWTEST_F(ImageSetArgTest, givenOffsetedBufferWhenSetKernelArgImageIscalledThenFu } HWTEST_F(ImageSetArgTest, clSetKernelArgImage) { - auto imageMocs = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE); + auto imageMocs = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE); typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; cl_mem memObj = srcImage; @@ -416,7 +417,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxC typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemory(4096); - mcsAlloc->gmm = Gmm::create(nullptr, 1, false); + mcsAlloc->gmm = GmmHelper::create(nullptr, 1, false); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -513,7 +514,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationAndRenderCompressionWhenSetArgOnMult typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemory(4096); - mcsAlloc->gmm = Gmm::create(nullptr, 1, false); + mcsAlloc->gmm = GmmHelper::create(nullptr, 1, false); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -570,7 +571,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemory(4096); - mcsAlloc->gmm = Gmm::create(nullptr, 1, false); + mcsAlloc->gmm = GmmHelper::create(nullptr, 1, false); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -793,7 +794,7 @@ class ImageMediaBlockSetArgTest : public ImageSetArgTest { }; HWTEST_F(ImageMediaBlockSetArgTest, clSetKernelArgImage) { - auto imageMocs = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE); + auto imageMocs = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE); typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; cl_mem memObj = srcImage; diff --git a/unit_tests/mem_obj/nv12_image_tests.cpp b/unit_tests/mem_obj/nv12_image_tests.cpp index c775187821..b258331579 100644 --- a/unit_tests/mem_obj/nv12_image_tests.cpp +++ b/unit_tests/mem_obj/nv12_image_tests.cpp @@ -22,7 +22,7 @@ #include "runtime/helpers/surface_formats.h" #include "runtime/helpers/aligned_memory.h" -#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/mem_obj/image.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/helpers/debug_manager_state_restore.h" diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 16a6db4756..ffd9ea70b2 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -834,7 +834,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAllocationWhenMappingThenReturnFalse) { OsAgnosticMemoryManager memoryManager; - auto gmm = Gmm::create(nullptr, 123, false); + auto gmm = GmmHelper::create(nullptr, 123, false); auto allocation = memoryManager.allocateGraphicsMemory(123); allocation->gmm = gmm; @@ -1215,7 +1215,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultOsAgnosticMemoryManagerWhenItIsQueried } TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenSuccess) { - Gmm *gmm = Gmm::create(nullptr, 65536, false); + Gmm *gmm = GmmHelper::create(nullptr, 65536, false); EXPECT_NE(nullptr, gmm); delete gmm; } diff --git a/unit_tests/mocks/mock_gmm.h b/unit_tests/mocks/mock_gmm.h index 48ad33d743..a5915e3783 100644 --- a/unit_tests/mocks/mock_gmm.h +++ b/unit_tests/mocks/mock_gmm.h @@ -21,6 +21,7 @@ */ #pragma once +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "unit_tests/mocks/mock_device.h" #include "runtime/helpers/options.h" @@ -39,7 +40,7 @@ class MockGmm : public Gmm { if (!queryHwInfo) { queryHwInfo = *platformDevices; } - return std::unique_ptr(Gmm::createGmmAndQueryImgParams(imgInfo, *queryHwInfo)); + return std::unique_ptr(GmmHelper::createGmmAndQueryImgParams(imgInfo, *queryHwInfo)); } static ImageInfo initImgInfo(cl_image_desc &imgDesc, int baseMipLevel, const SurfaceFormatInfo *surfaceFormat) { diff --git a/unit_tests/mocks/mock_memory_manager.cpp b/unit_tests/mocks/mock_memory_manager.cpp index 3b431dd528..f9eabb4513 100644 --- a/unit_tests/mocks/mock_memory_manager.cpp +++ b/unit_tests/mocks/mock_memory_manager.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,7 @@ */ #include "runtime/memory_manager/deferred_deleter.h" -#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/gmm_helper/gmm.h" #include "runtime/helpers/surface_formats.h" #include "unit_tests/mocks/mock_memory_manager.h" #include diff --git a/unit_tests/mocks/mock_wddm20.h b/unit_tests/mocks/mock_wddm20.h index bc7c36d24b..c1f668c2a0 100644 --- a/unit_tests/mocks/mock_wddm20.h +++ b/unit_tests/mocks/mock_wddm20.h @@ -27,6 +27,8 @@ #include namespace OCLRT { +class GraphicsAllocation; + namespace WddmMockHelpers { struct CallResult { uint32_t called = 0; 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 7e40dcbcb4..1ae50804ca 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -1858,7 +1858,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndUnifiedAuxCapableAllocation mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; - auto gmm = Gmm::create(nullptr, 123, false); + auto gmm = GmmHelper::create(nullptr, 123, false); auto allocation = memoryManager->allocateGraphicsMemory(123, 123); allocation->gmm = gmm; diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index 043bb96aa4..85a5081fa1 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -22,6 +22,8 @@ #include "unit_tests/os_interface/windows/wddm_fixture.h" +#include "runtime/gmm_helper/gmm.h" +#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/hw_info.h" #include "runtime/helpers/options.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" @@ -105,7 +107,7 @@ TEST_F(Wddm20Tests, givenNullPageTableManagerWhenUpdateAuxTableCalledThenReturnF wddm->resetPageTableManager(nullptr); EXPECT_EQ(nullptr, wddm->getPageTableManager()); - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); auto mockGmmRes = reinterpret_cast(gmm->gmmResourceInfo.get()); mockGmmRes->setUnifiedAuxTranslationCapable(); @@ -301,8 +303,8 @@ HWTEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap1ThenItHasGpuAd bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.getAlignedSize(), false, false, true); EXPECT_TRUE(ret); - auto cannonizedHeapBase = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Base); - auto cannonizedHeapEnd = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Limit); + auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base); + auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Limit); EXPECT_GE(allocation.gpuPtr, cannonizedHeapBase); EXPECT_LE(allocation.gpuPtr, cannonizedHeapEnd); @@ -386,7 +388,7 @@ HWTEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) { EXPECT_TRUE(ret); EXPECT_NE(0u, allocation.gpuPtr); - EXPECT_EQ(allocation.gpuPtr, Gmm::canonize(allocation.gpuPtr)); + EXPECT_EQ(allocation.gpuPtr, GmmHelper::canonize(allocation.gpuPtr)); delete gmm; mm.freeSystemMemory(allocation.getUnderlyingBuffer()); @@ -466,7 +468,7 @@ TEST_F(Wddm20Tests, GetCpuGpuTime) { HWTEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenGraphicsAllocationWithSharedPropertiesIsCreated) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -504,7 +506,7 @@ HWTEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocatio HWTEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenMapGpuVaWithCpuPtrDepensOnBitness) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); diff --git a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp index f40aca37ff..48eddb0ee9 100644 --- a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -20,6 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/gmm_helper/gmm.h" +#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/os_interface/windows/wddm/wddm.h" #include "runtime/os_interface/windows/wddm_allocation.h" #include "unit_tests/os_interface/windows/mock_kmdaf_listener.h" @@ -93,7 +95,7 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafList HWTEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDafListenerNotifyMapGpuVAIsFedWithCorrectParams) { WddmAllocation allocation((void *)0x23000, 0x1000, nullptr); allocation.handle = ALLOCATION_HANDLE; - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); allocation.gmm = gmm.get(); wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), allocation.gpuPtr, false, false, false); @@ -102,7 +104,7 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmD EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter); EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice); EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation); - EXPECT_EQ(Gmm::decanonize(allocation.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress); + EXPECT_EQ(GmmHelper::decanonize(allocation.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress); EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape); } @@ -148,7 +150,7 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotif HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { WddmAllocation allocation((void *)0x23000, 0x1000, nullptr); - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); allocation.gmm = gmm.get(); wddmWithKmDafMock->createAllocation(&allocation); @@ -162,7 +164,7 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafLi HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { WddmAllocation allocation((void *)0x23000, 0x1000, nullptr); - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); allocation.gmm = gmm.get(); wddmWithKmDafMock->createAllocation64k(&allocation); @@ -177,7 +179,7 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDaf HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledThenKmDafListenerNotifyWriteTargetAndMapGpuVAIsFedWithCorrectParams) { OsHandleStorage storage; OsHandle osHandle = {0}; - auto gmm = std::unique_ptr(Gmm::create(nullptr, 1, false)); + auto gmm = std::unique_ptr(GmmHelper::create(nullptr, 1, false)); storage.fragmentStorageData[0].osHandleStorage = &osHandle; storage.fragmentStorageData[0].fragmentSize = 100; storage.fragmentStorageData[0].osHandleStorage->gmm = gmm.get(); @@ -194,7 +196,7 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalle EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter); EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice); EXPECT_EQ(osHandle.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation); - EXPECT_EQ(Gmm::decanonize(osHandle.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress); + EXPECT_EQ(GmmHelper::decanonize(osHandle.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress); EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape); } 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 f40561a2aa..2cb1299c8f 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/mem_obj/buffer.h" @@ -151,7 +152,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandle auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, false); @@ -168,7 +169,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCa auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast(1)); @@ -202,7 +203,7 @@ HWTEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleReturns32BitAllo auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -213,7 +214,7 @@ HWTEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleReturns32BitAllo EXPECT_TRUE(gpuAllocation->is32BitAllocation); uint64_t base = memoryManager->allocator32Bit->getBase(); - EXPECT_EQ(Gmm::canonize(base), gpuAllocation->gpuBaseAddress); + EXPECT_EQ(GmmHelper::canonize(base), gpuAllocation->gpuBaseAddress); } memoryManager->freeGraphicsMemory(gpuAllocation); @@ -225,7 +226,7 @@ HWTEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleDoesNotReturn32B auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -248,7 +249,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHan auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto gpuAllocation = (WddmAllocation *)memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, false); @@ -270,7 +271,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShar auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, size, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, size, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, false); @@ -285,7 +286,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandle auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(Gmm::create(pSysMem, size, false)); + std::unique_ptr gmm(GmmHelper::create(pSysMem, size, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); wddm->failOpenSharedHandle = true; @@ -562,8 +563,8 @@ HWTEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithNullptr) { auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION); ASSERT_NE(nullptr, gpuAllocation); - EXPECT_LE(Gmm::canonize(wddm->getHeap32Base()), gpuAllocation->getGpuAddress()); - EXPECT_GT(Gmm::canonize(wddm->getHeap32Base()) + wddm->getHeap32Size() - 1, gpuAllocation->getGpuAddress()); + EXPECT_LE(GmmHelper::canonize(wddm->getHeap32Base()), gpuAllocation->getGpuAddress()); + EXPECT_GT(GmmHelper::canonize(wddm->getHeap32Base()) + wddm->getHeap32Size() - 1, gpuAllocation->getGpuAddress()); EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount); memoryManager->freeGraphicsMemory(gpuAllocation); @@ -580,8 +581,8 @@ HWTEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotD EXPECT_EQ(alignSizeWholePage(misalignedPtr, misalignedSize), gpuAllocation->getUnderlyingBufferSize()); - EXPECT_LE(Gmm::canonize(wddm->getHeap32Base()), gpuAllocation->getGpuAddress()); - EXPECT_GT(Gmm::canonize(wddm->getHeap32Base()) + wddm->getHeap32Size() - 1, gpuAllocation->getGpuAddress()); + EXPECT_LE(GmmHelper::canonize(wddm->getHeap32Base()), gpuAllocation->getGpuAddress()); + EXPECT_GT(GmmHelper::canonize(wddm->getHeap32Base()) + wddm->getHeap32Size() - 1, gpuAllocation->getGpuAddress()); EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount); @@ -598,7 +599,7 @@ HWTEST_F(WddmMemoryManagerTest, Allocate32BitMemorySetsCannonizedGpuBaseAddress) ASSERT_NE(nullptr, gpuAllocation); - uint64_t cannonizedAddress = Gmm::canonize(wddm->getHeap32Base()); + uint64_t cannonizedAddress = GmmHelper::canonize(wddm->getHeap32Base()); EXPECT_EQ(cannonizedAddress, gpuAllocation->gpuBaseAddress); memoryManager->freeGraphicsMemory(gpuAllocation); @@ -614,7 +615,7 @@ HWTEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocation storage.fragmentStorageData[0].osHandleStorage->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[0].freeTheFragment = true; - storage.fragmentStorageData[0].osHandleStorage->gmm = Gmm::create(pSysMem, 4096u, false); + storage.fragmentStorageData[0].osHandleStorage->gmm = GmmHelper::create(pSysMem, 4096u, false); storage.fragmentStorageData[1].osHandleStorage = new OsHandle; storage.fragmentStorageData[1].osHandleStorage->handle = ALLOCATION_HANDLE; @@ -625,7 +626,7 @@ HWTEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocation storage.fragmentStorageData[2].osHandleStorage = new OsHandle; storage.fragmentStorageData[2].osHandleStorage->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[2].freeTheFragment = true; - storage.fragmentStorageData[2].osHandleStorage->gmm = Gmm::create(pSysMem, 4096u, false); + storage.fragmentStorageData[2].osHandleStorage->gmm = GmmHelper::create(pSysMem, 4096u, false); storage.fragmentStorageData[2].residency = new ResidencyData; memoryManager->cleanOsHandles(storage); @@ -675,7 +676,7 @@ HWTEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGp SetUpMm(); void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(Gmm::create(ptr, size, false)); + std::unique_ptr gmm(GmmHelper::create(ptr, size, false)); memoryManager->setDeferredDeleter(nullptr); setMapGpuVaFailConfigFcn(0, 1); @@ -690,7 +691,7 @@ HWTEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstM SetUpMm(); void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(Gmm::create(ptr, size, false)); + std::unique_ptr gmm(GmmHelper::create(ptr, size, false)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -708,7 +709,7 @@ HWTEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstA SetUpMm(); void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(Gmm::create(ptr, size, false)); + std::unique_ptr gmm(GmmHelper::create(ptr, size, false)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -725,12 +726,12 @@ HWTEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocat SetUpMm(); auto wddmAllocation = static_cast(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION)); ASSERT_NE(nullptr, wddmAllocation); - EXPECT_EQ(wddmAllocation->gpuBaseAddress, Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Base)); + EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base)); EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); - auto cannonizedHeapBase = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Base); - auto cannonizedHeapEnd = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Limit); + auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base); + auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Limit); EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd); @@ -745,12 +746,12 @@ HWTEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationW auto ptr = reinterpret_cast(0x1000000); auto wddmAllocation = static_cast(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION)); ASSERT_NE(nullptr, wddmAllocation); - EXPECT_EQ(wddmAllocation->gpuBaseAddress, Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Base)); + EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base)); EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); - auto cannonizedHeapBase = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Base); - auto cannonizedHeapEnd = Gmm::canonize(this->wddm->getGfxPartition().Heap32[1].Limit); + auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base); + auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Limit); EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd); @@ -1953,7 +1954,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledTh } HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVaThenMapAuxVa) { - std::unique_ptr gmm(Gmm::create(reinterpret_cast(123), 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = true; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm; @@ -1964,7 +1965,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpu GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {}; GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {}; - expectedDdiUpdateAuxTable.BaseGpuVA = Gmm::canonize(wddm.getGfxPartition().Standard.Base); + expectedDdiUpdateAuxTable.BaseGpuVA = GmmHelper::canonize(wddm.getGfxPartition().Standard.Base); expectedDdiUpdateAuxTable.BaseResInfo = gmm->gmmResourceInfo->peekHandle(); expectedDdiUpdateAuxTable.DoNotWait = true; expectedDdiUpdateAuxTable.Map = true; @@ -1973,7 +1974,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpu auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, 3, gpuVa, false, false, false); ASSERT_TRUE(result); - EXPECT_EQ(Gmm::canonize(wddm.getGfxPartition().Standard.Base), gpuVa); + EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa); EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0); } @@ -2021,7 +2022,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleas } HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) { - std::unique_ptr gmm(Gmm::create(reinterpret_cast(123), 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm; @@ -2037,7 +2038,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMapped } HWTEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) { - std::unique_ptr gmm(Gmm::create(reinterpret_cast(123), 4096u, false)); + std::unique_ptr gmm(GmmHelper::create(reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm; @@ -2056,7 +2057,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUn auto mockMngr = new NiceMock(); wddm->resetPageTableManager(mockMngr); - auto myGmm = Gmm::create(reinterpret_cast(123), 4096u, false); + auto myGmm = GmmHelper::create(reinterpret_cast(123), 4096u, false); myGmm->isRenderCompressed = false; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1;