diff --git a/opencl/source/mem_obj/CMakeLists.txt b/opencl/source/mem_obj/CMakeLists.txt index 40ddcd3d7d..c1915e8c42 100644 --- a/opencl/source/mem_obj/CMakeLists.txt +++ b/opencl/source/mem_obj/CMakeLists.txt @@ -19,9 +19,8 @@ set(RUNTIME_SRCS_MEM_OBJ ${CMAKE_CURRENT_SOURCE_DIR}/map_operations_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/mem_obj.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mem_obj.h - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}mem_obj_helper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mem_obj_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mem_obj_helper.h - ${CMAKE_CURRENT_SOURCE_DIR}/mem_obj_helper_common.inl ${CMAKE_CURRENT_SOURCE_DIR}/pipe.cpp ${CMAKE_CURRENT_SOURCE_DIR}/pipe.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}buffer_ext.cpp diff --git a/opencl/source/mem_obj/mem_obj_helper.cpp b/opencl/source/mem_obj/mem_obj_helper.cpp index 237a8451b2..8b901e3bb3 100644 --- a/opencl/source/mem_obj/mem_obj_helper.cpp +++ b/opencl/source/mem_obj/mem_obj_helper.cpp @@ -5,26 +5,179 @@ * */ -#include "opencl/source/context/context.h" -#include "opencl/source/mem_obj/mem_obj_helper_common.inl" +#include "opencl/source/mem_obj/mem_obj_helper.h" -#include "memory_properties_flags.h" +#include "shared/source/helpers/memory_properties_helpers.h" + +#include "opencl/source/cl_device/cl_device.h" +#include "opencl/source/context/context.h" +#include "opencl/source/helpers/cl_hw_helper.h" namespace NEO { -bool MemObjHelper::isSuitableForRenderCompression(bool renderCompressed, const MemoryProperties &properties, Context &context, bool preferCompression) { +bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryProperties &memoryProperties, cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, const Context &context) { + /* Check all the invalid flags combination. */ + if ((isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY)) || + (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY)) || + (isValueSet(flags, CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY)) || + (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR)) || + (isValueSet(flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR)) || + (isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)) || + (isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_WRITE_ONLY)) || + (isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS))) { + return false; + } + + return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel, context); +} + +bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryProperties &memoryProperties, cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, cl_mem parent, const Context &context) { + /* Check all the invalid flags combination. */ + if ((!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && + (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) || + isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY) || + isValueSet(flags, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY) || + isValueSet(flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR) || + isValueSet(flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR) || + isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY) || + isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS) || + isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS) || + isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_WRITE) || + isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_WRITE_ONLY) || + isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_ONLY))) { + return false; + } + + auto parentMemObj = castToObject(parent); + if (parentMemObj != nullptr && flags) { + auto parentFlags = parentMemObj->getFlags(); + /* Check whether flags are compatible with parent. */ + if (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR) || + isValueSet(flags, CL_MEM_COPY_HOST_PTR) || + isValueSet(flags, CL_MEM_USE_HOST_PTR) || + ((!isValueSet(parentFlags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && + (!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && + ((isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) || + (isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_ONLY)) || + (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) || + (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_WRITE_ONLY)) || + (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_WRITE)) || + (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_WRITE_ONLY)) || + (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_ONLY)) || + (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_WRITE_ONLY)) || + (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_READ_ONLY))))) { + return false; + } + } + + return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel, context); +} + +AllocationProperties MemObjHelper::getAllocationPropertiesWithImageInfo( + uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryProperties &memoryProperties, + const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam, bool deviceOnlyVisibilty) { + + auto deviceBitfield = MemoryPropertiesHelper::adjustDeviceBitfield(rootDeviceIndex, memoryProperties, subDevicesBitfieldParam); + AllocationProperties allocationProperties{rootDeviceIndex, allocateMemory, imgInfo, GraphicsAllocation::AllocationType::IMAGE, deviceBitfield}; + MemoryPropertiesHelper::fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo, deviceOnlyVisibilty); + return allocationProperties; +} + +bool MemObjHelper::checkMemFlagsForSubBuffer(cl_mem_flags flags) { + const cl_mem_flags allValidFlags = + CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | + CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS; + + return isFieldValid(flags, allValidFlags); +} + +SVMAllocsManager::SvmAllocationProperties MemObjHelper::getSvmAllocationProperties(cl_mem_flags flags) { + SVMAllocsManager::SvmAllocationProperties svmProperties; + svmProperties.coherent = isValueSet(flags, CL_MEM_SVM_FINE_GRAIN_BUFFER); + svmProperties.hostPtrReadOnly = isValueSet(flags, CL_MEM_HOST_READ_ONLY) || isValueSet(flags, CL_MEM_HOST_NO_ACCESS); + svmProperties.readOnly = isValueSet(flags, CL_MEM_READ_ONLY); + return svmProperties; +} + +bool MemObjHelper::isSuitableForRenderCompression(bool renderCompressedBuffers, const MemoryProperties &properties, Context &context, bool preferCompression) { + if (!renderCompressedBuffers) { + return false; + } if (context.getRootDeviceIndices().size() > 1u) { return false; } - return renderCompressed && preferCompression; + for (auto &pClDevice : context.getDevices()) { + auto rootDeviceIndex = pClDevice->getRootDeviceIndex(); + auto &hwInfo = pClDevice->getHardwareInfo(); + auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily); + if (!clHwHelper.allowRenderCompressionForContext(*pClDevice, context)) { + return false; + } + + if (context.containsMultipleSubDevices(rootDeviceIndex)) { + if (DebugManager.flags.EnableMultiTileCompression.get() <= 0) { + return false; + } + + //for unrestrictive and default context, turn on compression only for read only surfaces with no host access. + bool isContextSpecialized = (context.peekContextType() == ContextType::CONTEXT_TYPE_SPECIALIZED); + bool isReadOnlyAndHostNoAccess = (properties.flags.readOnly && properties.flags.hostNoAccess); + if (!isContextSpecialized && !isReadOnlyAndHostNoAccess) { + return false; + } + } + } + if (preferCompression) { + if (properties.flags.uncompressedHint) { + return false; + } + if (properties.flags.compressedHint) { + return true; + } + int32_t disableCompression = DebugManager.flags.ToggleHintKernelDisableCompression.get(); + if (disableCompression != -1) { + return !!disableCompression; + } else { + if (context.getResolvesRequiredInKernels()) { + return false; + } + } + return true; + } + + return properties.flags.compressedHint; } bool MemObjHelper::validateExtraMemoryProperties(const MemoryProperties &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const Context &context) { - return true; + bool compressedFlagSet = isValueSet(flags, CL_MEM_COMPRESSED_HINT_INTEL) || + isValueSet(flagsIntel, CL_MEM_COMPRESSED_HINT_INTEL); + bool uncompressedFlagSet = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) || + isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL); + if (compressedFlagSet && uncompressedFlagSet) { + return false; + } + + auto pClDevice = memoryProperties.pDevice->getSpecializedDevice(); + auto &contextRootDeviceIndices = context.getRootDeviceIndices(); + bool isRootDeviceAssociated = (contextRootDeviceIndices.find(pClDevice->getRootDeviceIndex()) != contextRootDeviceIndices.end()); + return isRootDeviceAssociated; } -const uint64_t MemObjHelper::extraFlags = 0; +const uint64_t MemObjHelper::commonFlags = CL_MEM_COMPRESSED_HINT_INTEL | CL_MEM_UNCOMPRESSED_HINT_INTEL | CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | + CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR | + CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS; -const uint64_t MemObjHelper::extraFlagsIntel = 0; +const uint64_t MemObjHelper::commonFlagsIntel = CL_MEM_COMPRESSED_HINT_INTEL | CL_MEM_UNCOMPRESSED_HINT_INTEL | CL_MEM_LOCALLY_UNCACHED_RESOURCE | + CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE | CL_MEM_48BIT_RESOURCE_INTEL; + +const uint64_t MemObjHelper::validFlagsForBuffer = commonFlags | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL | CL_MEM_FORCE_HOST_MEMORY_INTEL; + +const uint64_t MemObjHelper::validFlagsForBufferIntel = commonFlagsIntel | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL; + +const uint64_t MemObjHelper::validFlagsForImage = commonFlags | CL_MEM_NO_ACCESS_INTEL | CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_FORCE_LINEAR_STORAGE_INTEL; + +const uint64_t MemObjHelper::validFlagsForImageIntel = commonFlagsIntel; } // namespace NEO diff --git a/opencl/source/mem_obj/mem_obj_helper_common.inl b/opencl/source/mem_obj/mem_obj_helper_common.inl deleted file mode 100644 index 791e29a13d..0000000000 --- a/opencl/source/mem_obj/mem_obj_helper_common.inl +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2019-2021 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/helpers/memory_properties_helpers.h" - -#include "opencl/source/mem_obj/mem_obj_helper.h" - -namespace NEO { - -bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryProperties &memoryProperties, cl_mem_flags flags, - cl_mem_flags_intel flagsIntel, const Context &context) { - /* Check all the invalid flags combination. */ - if ((isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY)) || - (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY)) || - (isValueSet(flags, CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY)) || - (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR)) || - (isValueSet(flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR)) || - (isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)) || - (isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_WRITE_ONLY)) || - (isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS))) { - return false; - } - - return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel, context); -} - -bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryProperties &memoryProperties, cl_mem_flags flags, - cl_mem_flags_intel flagsIntel, cl_mem parent, const Context &context) { - /* Check all the invalid flags combination. */ - if ((!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && - (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) || - isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY) || - isValueSet(flags, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY) || - isValueSet(flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR) || - isValueSet(flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR) || - isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY) || - isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS) || - isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS) || - isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_WRITE) || - isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_WRITE_ONLY) || - isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_ONLY))) { - return false; - } - - auto parentMemObj = castToObject(parent); - if (parentMemObj != nullptr && flags) { - auto parentFlags = parentMemObj->getFlags(); - /* Check whether flags are compatible with parent. */ - if (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR) || - isValueSet(flags, CL_MEM_COPY_HOST_PTR) || - isValueSet(flags, CL_MEM_USE_HOST_PTR) || - ((!isValueSet(parentFlags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && - (!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && - ((isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) || - (isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_ONLY)) || - (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) || - (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_WRITE_ONLY)) || - (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_WRITE)) || - (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_WRITE_ONLY)) || - (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_ONLY)) || - (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_WRITE_ONLY)) || - (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_READ_ONLY))))) { - return false; - } - } - - return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel, context); -} - -AllocationProperties MemObjHelper::getAllocationPropertiesWithImageInfo( - uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryProperties &memoryProperties, - const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam, bool deviceOnlyVisibilty) { - - auto deviceBitfield = MemoryPropertiesHelper::adjustDeviceBitfield(rootDeviceIndex, memoryProperties, subDevicesBitfieldParam); - AllocationProperties allocationProperties{rootDeviceIndex, allocateMemory, imgInfo, GraphicsAllocation::AllocationType::IMAGE, deviceBitfield}; - MemoryPropertiesHelper::fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo, deviceOnlyVisibilty); - return allocationProperties; -} - -bool MemObjHelper::checkMemFlagsForSubBuffer(cl_mem_flags flags) { - const cl_mem_flags allValidFlags = - CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | - CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS; - - return isFieldValid(flags, allValidFlags); -} - -SVMAllocsManager::SvmAllocationProperties MemObjHelper::getSvmAllocationProperties(cl_mem_flags flags) { - SVMAllocsManager::SvmAllocationProperties svmProperties; - svmProperties.coherent = isValueSet(flags, CL_MEM_SVM_FINE_GRAIN_BUFFER); - svmProperties.hostPtrReadOnly = isValueSet(flags, CL_MEM_HOST_READ_ONLY) || isValueSet(flags, CL_MEM_HOST_NO_ACCESS); - svmProperties.readOnly = isValueSet(flags, CL_MEM_READ_ONLY); - return svmProperties; -} - -const uint64_t MemObjHelper::commonFlags = extraFlags | CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | - CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR | - CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS; - -const uint64_t MemObjHelper::commonFlagsIntel = extraFlagsIntel | CL_MEM_LOCALLY_UNCACHED_RESOURCE | - CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE | CL_MEM_48BIT_RESOURCE_INTEL; - -const uint64_t MemObjHelper::validFlagsForBuffer = commonFlags | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL | CL_MEM_FORCE_HOST_MEMORY_INTEL; - -const uint64_t MemObjHelper::validFlagsForBufferIntel = commonFlagsIntel | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL; - -const uint64_t MemObjHelper::validFlagsForImage = commonFlags | CL_MEM_NO_ACCESS_INTEL | CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_FORCE_LINEAR_STORAGE_INTEL; - -const uint64_t MemObjHelper::validFlagsForImageIntel = commonFlagsIntel; - -} // namespace NEO diff --git a/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp b/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp index 6adc787b60..c121daf4ac 100644 --- a/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp +++ b/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp @@ -218,9 +218,11 @@ TEST_F(MemoryPropertiesHelperTests, givenValidPropertiesWhenParsingMemoryPropert cl_mem_properties_intel properties[] = { CL_MEM_FLAGS, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR | - CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS, + CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS | CL_MEM_COMPRESSED_HINT_INTEL | + CL_MEM_UNCOMPRESSED_HINT_INTEL, CL_MEM_FLAGS_INTEL, - CL_MEM_LOCALLY_UNCACHED_RESOURCE | CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE, + CL_MEM_LOCALLY_UNCACHED_RESOURCE | CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE | CL_MEM_COMPRESSED_HINT_INTEL | + CL_MEM_UNCOMPRESSED_HINT_INTEL, CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL, 0}; diff --git a/opencl/test/unit_test/mem_obj/image_tests.cpp b/opencl/test/unit_test/mem_obj/image_tests.cpp index 98e3d49c56..307854a563 100644 --- a/opencl/test/unit_test/mem_obj/image_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests.cpp @@ -1174,6 +1174,63 @@ TEST_F(ImageCompressionTests, givenNonTiledImageWhenCreatingAllocationThenDontPr EXPECT_FALSE(myMemoryManager->capturedImgInfo.preferRenderCompression); } +HWTEST_F(ImageCompressionTests, givenTiledImageAndVariousFlagsWhenCreatingAllocationThenCorrectlySetPreferRenderCompression) { + imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D; + imageDesc.image_width = 5; + imageDesc.image_height = 5; + + auto newFlags = flags | CL_MEM_COMPRESSED_HINT_INTEL; + MockContext context; + auto surfaceFormat = Image::getSurfaceFormatFromTable( + newFlags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features); + auto image = std::unique_ptr(Image::create( + mockContext.get(), ClMemoryPropertiesHelper::createMemoryProperties(newFlags, 0, 0, &context.getDevice(0)->getDevice()), + newFlags, 0, surfaceFormat, &imageDesc, nullptr, retVal)); + ASSERT_NE(nullptr, image); + EXPECT_EQ(UnitTestHelper::tiledImagesSupported, image->isTiledAllocation()); + EXPECT_TRUE(myMemoryManager->mockMethodCalled); + EXPECT_EQ(UnitTestHelper::tiledImagesSupported, myMemoryManager->capturedImgInfo.preferRenderCompression); + + newFlags = flags | CL_MEM_UNCOMPRESSED_HINT_INTEL; + surfaceFormat = Image::getSurfaceFormatFromTable( + newFlags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features); + image = std::unique_ptr(Image::create( + mockContext.get(), ClMemoryPropertiesHelper::createMemoryProperties(newFlags, 0, 0, &context.getDevice(0)->getDevice()), + newFlags, 0, surfaceFormat, &imageDesc, nullptr, retVal)); + ASSERT_NE(nullptr, image); + EXPECT_EQ(UnitTestHelper::tiledImagesSupported, image->isTiledAllocation()); + EXPECT_TRUE(myMemoryManager->mockMethodCalled); + EXPECT_FALSE(myMemoryManager->capturedImgInfo.preferRenderCompression); +} + +TEST_F(ImageCompressionTests, givenNonTiledImageAndVariousFlagsWhenCreatingAllocationThenDontPreferRenderCompression) { + imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D; + imageDesc.image_width = 5; + + auto newFlags = flags | CL_MEM_COMPRESSED_HINT_INTEL; + MockContext context; + auto surfaceFormat = Image::getSurfaceFormatFromTable( + newFlags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features); + auto image = std::unique_ptr(Image::create( + mockContext.get(), ClMemoryPropertiesHelper::createMemoryProperties(newFlags, 0, 0, &context.getDevice(0)->getDevice()), + newFlags, 0, surfaceFormat, &imageDesc, nullptr, retVal)); + ASSERT_NE(nullptr, image); + EXPECT_FALSE(image->isTiledAllocation()); + EXPECT_TRUE(myMemoryManager->mockMethodCalled); + EXPECT_FALSE(myMemoryManager->capturedImgInfo.preferRenderCompression); + + newFlags = flags | CL_MEM_UNCOMPRESSED_HINT_INTEL; + surfaceFormat = Image::getSurfaceFormatFromTable( + newFlags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features); + image = std::unique_ptr(Image::create( + mockContext.get(), ClMemoryPropertiesHelper::createMemoryProperties(newFlags, 0, 0, &context.getDevice(0)->getDevice()), + newFlags, 0, surfaceFormat, &imageDesc, nullptr, retVal)); + ASSERT_NE(nullptr, image); + EXPECT_FALSE(image->isTiledAllocation()); + EXPECT_TRUE(myMemoryManager->mockMethodCalled); + EXPECT_FALSE(myMemoryManager->capturedImgInfo.preferRenderCompression); +} + TEST(ImageTest, givenImageWhenGettingCompressionOfImageThenCorrectValueIsReturned) { MockContext context; std::unique_ptr image(ImageHelper::create(&context)); diff --git a/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp b/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp index 4a9ed70f6f..9aee95e472 100644 --- a/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp +++ b/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp @@ -5,12 +5,16 @@ * */ +#include "shared/source/os_interface/hw_info_config.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/mocks/ult_device_factory.h" #include "shared/test/unit_test/utilities/base_object_utils.h" +#include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/source/helpers/cl_memory_properties_helpers.h" #include "opencl/source/mem_obj/mem_obj_helper.h" #include "opencl/test/unit_test/fixtures/image_fixture.h" +#include "opencl/test/unit_test/mocks/mock_buffer.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "gtest/gtest.h" @@ -161,4 +165,268 @@ TEST(MemObjHelper, givenContextWithMultipleRootDevicesWhenIsSuitableForRenderCom MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.pRootDevice0->getDevice()); EXPECT_FALSE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenCompressionEnabledButNotPreferredWhenCompressionHintIsPassedThenCompressionIsUsed) { + cl_mem_flags_intel flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL; + MockContext context; + MemoryProperties memoryProperties = + ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, false)); + flags = CL_MEM_COMPRESSED_HINT_INTEL; + flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, false)); + flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + flags = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, false)); +} + +TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenCompressionHintIsPassedThenCompressionIsUsed) { + cl_mem_flags_intel flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL; + MockContext context; + MemoryProperties memoryProperties = + ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); + flags = CL_MEM_COMPRESSED_HINT_INTEL; + flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); + flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + flags = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenRenderCompressionWhenCL_MEM_COMPRESSEDIsNotSetThenFalseReturned) { + cl_mem_flags_intel flagsIntel = 0; + cl_mem_flags flags = 0; + MockContext context; + MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; + EXPECT_FALSE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, false)); +} + +TEST(MemObjHelper, givenRenderCompressionWhenCL_MEM_COMPRESSEDThenTrueIsReturned) { + cl_mem_flags_intel flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL; + MockContext context; + MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelperMultiTile, givenValidExtraPropertiesWhenValidatingExtraPropertiesThenTrueIsReturned) { + UltClDeviceFactory deviceFactory{1, 4}; + cl_device_id devices[] = {deviceFactory.rootDevices[0], deviceFactory.subDevices[0], deviceFactory.subDevices[1], + deviceFactory.subDevices[2], deviceFactory.subDevices[3]}; + MockContext context(ClDeviceVector{devices, 5}); + + auto pDevice = &deviceFactory.rootDevices[0]->getDevice(); + + cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL; + cl_mem_flags_intel flagsIntel = 0; + auto memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); + + flags = CL_MEM_UNCOMPRESSED_HINT_INTEL; + flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); + + flags = 0; + flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); + + flags = 0; + flagsIntel = CL_MEM_UNCOMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); +} + +TEST(MemObjHelper, givenInvalidFlagsWhenValidatingExtraPropertiesThenFalseIsReturned) { + MemoryProperties memoryProperties; + cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL | CL_MEM_UNCOMPRESSED_HINT_INTEL; + cl_mem_flags_intel flagsIntel = 0; + MockContext context; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); + + flags = 0; + flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL | CL_MEM_UNCOMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); + + flags = CL_MEM_COMPRESSED_HINT_INTEL; + flagsIntel = CL_MEM_UNCOMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); + + flags = CL_MEM_UNCOMPRESSED_HINT_INTEL; + flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)); +} + +TEST(MemObjHelper, givenMultipleSubDevicesWhenDefaultContextIsUsedThenResourcesAreNotSuitableForCompression) { + DebugManagerStateRestore debugRestore; + DebugManager.flags.CreateMultipleSubDevices.set(4u); + initPlatform(); + MockContext context(platform()->getClDevice(0)); + MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_ONLY, 0u, 0, &context.getDevice(0)->getDevice()); + + EXPECT_FALSE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); + memoryProperties.flags.hostNoAccess = true; + EXPECT_FALSE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenContextRequiresResolveThenResourceNotSuitableForCompression) { + MemoryProperties memoryProperties; + MockContext context; + + context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED; + context.resolvesRequiredInKernels = true; + + EXPECT_FALSE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenContextNotRequiresResolveThenResourceSuitableForCompression) { + MemoryProperties memoryProperties; + MockContext context; + + context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED; + context.resolvesRequiredInKernels = false; + + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenContextNotRequiresResolveAndForceHintDisableCompressionThenResourceNotSuitableForCompression) { + DebugManagerStateRestore restore; + DebugManager.flags.ToggleHintKernelDisableCompression.set(0); + + MemoryProperties memoryProperties; + MockContext context; + + context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED; + context.resolvesRequiredInKernels = false; + + EXPECT_FALSE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenContextRequiresResolveAndForceHintEnableCompressionThenResourceSuitableForCompression) { + DebugManagerStateRestore restore; + DebugManager.flags.ToggleHintKernelDisableCompression.set(1); + + MemoryProperties memoryProperties; + MockContext context; + + context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED; + context.resolvesRequiredInKernels = true; + + EXPECT_TRUE(MemObjHelper::isSuitableForRenderCompression(true, memoryProperties, context, true)); +} + +TEST(MemObjHelper, givenDifferentCapabilityAndDebugFlagValuesWhenCheckingBufferCompressionSupportThenCorrectValueIsReturned) { + DebugManagerStateRestore debugRestore; + VariableBackup renderCompressedBuffersCapability{&defaultHwInfo->capabilityTable.ftrRenderCompressedBuffers}; + int32_t enableMultiTileCompressionValues[] = {-1, 0, 1}; + auto &clHwHelper = ClHwHelper::get(defaultHwInfo->platform.eRenderCoreFamily); + + for (auto ftrRenderCompressedBuffers : ::testing::Bool()) { + renderCompressedBuffersCapability = ftrRenderCompressedBuffers; + for (auto enableMultiTileCompressionValue : enableMultiTileCompressionValues) { + DebugManager.flags.EnableMultiTileCompression.set(enableMultiTileCompressionValue); + + MockSpecializedContext context; + auto &device = context.getDevice(0)->getDevice(); + MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &device); + auto allocationType = MockPublicAccessBuffer::getGraphicsAllocationType( + memoryProperties, context, HwHelper::renderCompressedBuffersSupported(*defaultHwInfo), false, true); + + bool expectBufferCompressed = ftrRenderCompressedBuffers && (enableMultiTileCompressionValue == 1); + if (expectBufferCompressed && clHwHelper.allowRenderCompressionForContext(*context.getDevice(0), context)) { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, allocationType); + } else { + EXPECT_NE(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, allocationType); + } + } + } +} + +TEST(MemObjHelper, givenDifferentValuesWhenCheckingBufferCompressionSupportThenCorrectValueIsReturned) { + DebugManagerStateRestore debugRestore; + VariableBackup renderCompressedBuffersCapability{&defaultHwInfo->capabilityTable.ftrRenderCompressedBuffers, true}; + VariableBackup hardwareStepping{&defaultHwInfo->platform.usRevId}; + DebugManager.flags.EnableMultiTileCompression.set(1); + + uint32_t numsSubDevices[] = {0, 2}; + cl_mem_flags flagsValues[] = {0, CL_MEM_READ_ONLY | CL_MEM_HOST_NO_ACCESS, CL_MEM_COMPRESSED_HINT_INTEL, + CL_MEM_UNCOMPRESSED_HINT_INTEL}; + cl_mem_flags_intel flagsIntelValues[] = {0, CL_MEM_COMPRESSED_HINT_INTEL, CL_MEM_UNCOMPRESSED_HINT_INTEL}; + uint32_t contextTypes[] = {ContextType::CONTEXT_TYPE_DEFAULT, ContextType::CONTEXT_TYPE_SPECIALIZED, + ContextType::CONTEXT_TYPE_UNRESTRICTIVE}; + __REVID steppingValues[] = {REVISION_A0, REVISION_B}; + const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + auto &clHwHelper = ClHwHelper::get(defaultHwInfo->platform.eRenderCoreFamily); + + for (auto stepping : steppingValues) { + hardwareStepping = hwInfoConfig.getHwRevIdFromStepping(stepping, *defaultHwInfo); + if (hardwareStepping == CommonConstants::invalidStepping) { + continue; + } + + for (auto numSubDevices : numsSubDevices) { + UltClDeviceFactory clDeviceFactory{1, numSubDevices}; + + for (auto contextType : contextTypes) { + if ((numSubDevices == 0) && (contextType != ContextType::CONTEXT_TYPE_DEFAULT)) { + continue; + } + + ClDeviceVector contextDevices; + if (contextType != ContextType::CONTEXT_TYPE_SPECIALIZED) { + contextDevices.push_back(clDeviceFactory.rootDevices[0]); + } + if (contextType != ContextType::CONTEXT_TYPE_DEFAULT) { + contextDevices.push_back(clDeviceFactory.subDevices[0]); + contextDevices.push_back(clDeviceFactory.subDevices[1]); + } + MockContext context{contextDevices}; + + for (auto flags : flagsValues) { + for (auto flagsIntel : flagsIntelValues) { + + auto &device = context.getDevice(0)->getDevice(); + MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, + 0, &device); + auto allocationType = MockPublicAccessBuffer::getGraphicsAllocationType( + memoryProperties, context, HwHelper::renderCompressedBuffersSupported(*defaultHwInfo), false, true); + + bool isCompressionDisabled = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) || + isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL); + bool expectBufferCompressed = !isCompressionDisabled; + + bool isMultiTile = (numSubDevices > 1); + if (expectBufferCompressed && isMultiTile) { + bool isBufferReadOnly = isValueSet(flags, CL_MEM_READ_ONLY | CL_MEM_HOST_NO_ACCESS); + expectBufferCompressed = clHwHelper.allowRenderCompressionForContext(*context.getDevice(0), context) && + ((contextType == ContextType::CONTEXT_TYPE_SPECIALIZED) || isBufferReadOnly); + } + + if (expectBufferCompressed) { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, allocationType); + } else { + EXPECT_NE(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, allocationType); + } + } + } + } + } + } } \ No newline at end of file diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index b41932cecc..74b284b6e0 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -343,5 +343,6 @@ OverridePreferredSlmAllocationSizePerDss = -1 ForceL3PrefetchForComputeWalker = -1 ForceZPassAsyncComputeThreadLimit = -1 ForcePixelAsyncComputeThreadLimit = -1 +ToggleHintKernelDisableCompression = -1 EnableImplicitScaling = -1 DecompressInL3ForImage2dFromBuffer = -1 \ No newline at end of file diff --git a/opencl/test/unit_test/xe_hpg_core/image_tests_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/image_tests_xe_hpg_core.cpp index a221803663..66f68647e2 100644 --- a/opencl/test/unit_test/xe_hpg_core/image_tests_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/image_tests_xe_hpg_core.cpp @@ -52,3 +52,27 @@ XE_HPG_CORETEST_F(ImageCompressionTests, GivenDifferentImageFormatsWhenCreatingI EXPECT_EQ(format.isCompressable, myMemoryManager->capturedImgInfo.preferRenderCompression); } } + +XE_HPG_CORETEST_F(ImageCompressionTests, givenRedescribableFormatWhenCreatingAllocationThenDoNotPreferRenderCompression) { + MockContext context{}; + imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D; + imageDesc.image_width = 5; + imageDesc.image_height = 5; + + auto surfaceFormat = Image::getSurfaceFormatFromTable( + flags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features); + auto image = std::unique_ptr(Image::create( + mockContext.get(), ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice()), + flags, 0, surfaceFormat, &imageDesc, nullptr, retVal)); + ASSERT_NE(nullptr, image); + EXPECT_EQ(UnitTestHelper::tiledImagesSupported, myMemoryManager->capturedImgInfo.preferRenderCompression); + + imageFormat.image_channel_order = CL_RG; + surfaceFormat = Image::getSurfaceFormatFromTable( + flags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features); + image = std::unique_ptr(Image::create( + mockContext.get(), ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice()), + flags, 0, surfaceFormat, &imageDesc, nullptr, retVal)); + ASSERT_NE(nullptr, image); + EXPECT_TRUE(myMemoryManager->capturedImgInfo.preferRenderCompression); +} \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 25d0d4ae59..3df950bee7 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -162,6 +162,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceL3PrefetchForComputeWalker, -1, "-1: defaul DECLARE_DEBUG_VARIABLE(int32_t, ForceZPassAsyncComputeThreadLimit, -1, "-1: default, >0: Limit value in STATE_COMPUTE_MODE") DECLARE_DEBUG_VARIABLE(int32_t, ForcePixelAsyncComputeThreadLimit, -1, "-1: default, >0: Limit value in STATE_COMPUTE_MODE") DECLARE_DEBUG_VARIABLE(int32_t, DecompressInL3ForImage2dFromBuffer, -1, "-1: default, 0: WA Disabled, 1: WA enabled - Enable DecompressInL3 for image 2d from compressed buffer") +DECLARE_DEBUG_VARIABLE(int32_t, ToggleHintKernelDisableCompression, -1, "-1: default - use kernel as source of hint, 0: provide hint to disable compression, 1: provide hint to enable compression") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")