Initial support for compressed L0 Images
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
parent
6e7515a12b
commit
8288fa76cb
|
@ -32,6 +32,7 @@ class L0HwHelper {
|
|||
virtual L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const = 0;
|
||||
|
||||
virtual bool isResumeWARequired() = 0;
|
||||
virtual bool imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const = 0;
|
||||
|
||||
virtual void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) const = 0;
|
||||
virtual std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const = 0;
|
||||
|
@ -52,6 +53,7 @@ class L0HwHelperHw : public L0HwHelper {
|
|||
L0HwHelperHw() = default;
|
||||
|
||||
bool isResumeWARequired() override;
|
||||
bool imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const override;
|
||||
void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) const override;
|
||||
std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const override;
|
||||
};
|
||||
|
|
|
@ -88,4 +88,13 @@ std::vector<ze_device_thread_t> L0HwHelperHw<GfxFamily>::getThreadsFromAttention
|
|||
|
||||
return threads;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool L0HwHelperHw<GfxFamily>::imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const {
|
||||
if (NEO::DebugManager.flags.RenderCompressedImagesEnabled.get() != -1) {
|
||||
return !!NEO::DebugManager.flags.RenderCompressedImagesEnabled.get();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace L0
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
|
||||
#include "level_zero/core/source/helpers/properties_parser.h"
|
||||
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
|
||||
#include "level_zero/core/source/image/image_formats.h"
|
||||
#include "level_zero/core/source/image/image_hw.h"
|
||||
|
||||
|
@ -90,6 +91,12 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
|
|||
} else {
|
||||
NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield());
|
||||
|
||||
auto &hwInfo = device->getHwInfo();
|
||||
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
properties.flags.preferCompressed = l0HwHelper.imageCompressionSupported(hwInfo);
|
||||
properties.flags.preferCompressed &= !imgInfo.linearStorage;
|
||||
|
||||
allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
}
|
||||
if (allocation == nullptr) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/test_macros/matchers.h"
|
||||
|
||||
|
@ -65,6 +66,21 @@ static void printAttentionBitmask(uint8_t *expected, uint8_t *actual, uint32_t m
|
|||
std::cout << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(L0HwHelperTest, givenL0HwHelperWhenAskingForImageCompressionSupportThenReturnFalse) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
auto &l0HwHelper = L0::L0HwHelper::get(NEO::defaultHwInfo->platform.eRenderCoreFamily);
|
||||
|
||||
EXPECT_FALSE(l0HwHelper.imageCompressionSupported(*NEO::defaultHwInfo));
|
||||
|
||||
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(1);
|
||||
EXPECT_TRUE(l0HwHelper.imageCompressionSupported(*NEO::defaultHwInfo));
|
||||
|
||||
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(0);
|
||||
EXPECT_FALSE(l0HwHelper.imageCompressionSupported(*NEO::defaultHwInfo));
|
||||
}
|
||||
|
||||
HWTEST_F(L0HwHelperTest, givenSliceSubsliceEuAndThreadIdsWhenGettingBitmaskThenCorrectBitmaskIsReturned) {
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
auto &l0HwHelper = L0::L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/gmm_helper/resource_info.h"
|
||||
#include "shared/source/helpers/surface_format_info.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_client_context.h"
|
||||
|
@ -15,6 +16,7 @@
|
|||
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
|
||||
#include "level_zero/core/source/image/image_format_desc_helper.h"
|
||||
#include "level_zero/core/source/image/image_formats.h"
|
||||
#include "level_zero/core/source/image/image_hw.h"
|
||||
|
@ -828,5 +830,93 @@ HWTEST2_F(ImageGetMemoryProperties, givenImageMemoryPropertiesExpStructureWhenGe
|
|||
EXPECT_EQ(imageInfo.rowPitch, imageMemoryPropertiesExp.rowPitch);
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageGetMemoryProperties, givenDebugFlagSetWhenCreatingImageThenEnableCompression, ImageSupport) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.ftrRenderCompressedImages = true;
|
||||
|
||||
ze_image_desc_t zeDesc = {};
|
||||
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
zeDesc.arraylevels = 1u;
|
||||
zeDesc.depth = 1u;
|
||||
zeDesc.height = 1u;
|
||||
zeDesc.width = 1u;
|
||||
zeDesc.miplevels = 1u;
|
||||
zeDesc.type = ZE_IMAGE_TYPE_2DARRAY;
|
||||
zeDesc.flags = ZE_IMAGE_FLAG_BIAS_UNCACHED;
|
||||
|
||||
zeDesc.format = {ZE_IMAGE_FORMAT_LAYOUT_32,
|
||||
ZE_IMAGE_FORMAT_TYPE_UINT,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_R,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_G,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_B,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_A};
|
||||
|
||||
{
|
||||
Image *image_ptr = nullptr;
|
||||
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_NE(nullptr, image_ptr);
|
||||
std::unique_ptr<L0::Image> image(image_ptr);
|
||||
|
||||
EXPECT_EQ(L0HwHelperHw<FamilyType>::get().imageCompressionSupported(device->getHwInfo()), image->getAllocation()->isCompressionEnabled());
|
||||
}
|
||||
|
||||
{
|
||||
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(1);
|
||||
|
||||
Image *image_ptr = nullptr;
|
||||
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_NE(nullptr, image_ptr);
|
||||
std::unique_ptr<L0::Image> image(image_ptr);
|
||||
|
||||
EXPECT_TRUE(image->getAllocation()->isCompressionEnabled());
|
||||
}
|
||||
|
||||
{
|
||||
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(0);
|
||||
|
||||
Image *image_ptr = nullptr;
|
||||
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_NE(nullptr, image_ptr);
|
||||
std::unique_ptr<L0::Image> image(image_ptr);
|
||||
|
||||
EXPECT_FALSE(image->getAllocation()->isCompressionEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageGetMemoryProperties, givenDebugFlagSetWhenCreatingLinearImageThenDontEnableCompression, ImageSupport) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.ftrRenderCompressedImages = true;
|
||||
|
||||
ze_image_desc_t zeDesc = {};
|
||||
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
zeDesc.arraylevels = 1u;
|
||||
zeDesc.depth = 1u;
|
||||
zeDesc.height = 1u;
|
||||
zeDesc.width = 1u;
|
||||
zeDesc.miplevels = 1u;
|
||||
zeDesc.type = ZE_IMAGE_TYPE_1D;
|
||||
zeDesc.flags = ZE_IMAGE_FLAG_BIAS_UNCACHED;
|
||||
|
||||
zeDesc.format = {ZE_IMAGE_FORMAT_LAYOUT_32,
|
||||
ZE_IMAGE_FORMAT_TYPE_UINT,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_R,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_G,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_B,
|
||||
ZE_IMAGE_FORMAT_SWIZZLE_A};
|
||||
|
||||
Image *image_ptr = nullptr;
|
||||
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_NE(nullptr, image_ptr);
|
||||
std::unique_ptr<L0::Image> image(image_ptr);
|
||||
|
||||
EXPECT_FALSE(image->getAllocation()->isCompressionEnabled());
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
|
Loading…
Reference in New Issue