mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 23:56:39 +08:00
Update isSuitableForRenderCompression check
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
94450aa54c
commit
7094462e21
@@ -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
|
||||
|
||||
@@ -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<MemObj>(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<ClDevice>();
|
||||
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
|
||||
|
||||
@@ -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<MemObj>(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
|
||||
@@ -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};
|
||||
|
||||
@@ -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>(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<FamilyType>::tiledImagesSupported, image->isTiledAllocation());
|
||||
EXPECT_TRUE(myMemoryManager->mockMethodCalled);
|
||||
EXPECT_EQ(UnitTestHelper<FamilyType>::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>(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<FamilyType>::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>(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>(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> image(ImageHelper<Image3dDefaults>::create(&context));
|
||||
|
||||
@@ -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<bool> 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<bool> renderCompressedBuffersCapability{&defaultHwInfo->capabilityTable.ftrRenderCompressedBuffers, true};
|
||||
VariableBackup<unsigned short> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,5 +343,6 @@ OverridePreferredSlmAllocationSizePerDss = -1
|
||||
ForceL3PrefetchForComputeWalker = -1
|
||||
ForceZPassAsyncComputeThreadLimit = -1
|
||||
ForcePixelAsyncComputeThreadLimit = -1
|
||||
ToggleHintKernelDisableCompression = -1
|
||||
EnableImplicitScaling = -1
|
||||
DecompressInL3ForImage2dFromBuffer = -1
|
||||
@@ -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>(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<FamilyType>::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>(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);
|
||||
}
|
||||
Reference in New Issue
Block a user