Add helper to get compression format for stateless compression on XE_HP_SDV

Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2021-08-25 09:31:44 +00:00
committed by Compute-Runtime-Automation
parent d10eb1c04c
commit 54cf561e09
11 changed files with 186 additions and 1 deletions

View File

@@ -15,6 +15,8 @@
#include "opencl/source/helpers/hardware_commands_helper.h"
#include "opencl/source/mem_obj/buffer.h"
#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h"
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
#include "opencl/test/unit_test/mocks/mock_hw_helper.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "reg_configs_common.h"
@@ -579,3 +581,34 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, RenderSurfaceStateXeHPAndLaterTests, givenSpecificP
EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, rssCmd.getCoherencyType());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, RenderSurfaceStateXeHPAndLaterTests, givenEncodeBufferWhenStatelessCompressionIsEnabledThenApplyFormatForStatelessCompression) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableStatelessCompression.set(1);
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperWithCompressionFormat<FamilyType>>(defaultHwInfo->platform.eRenderCoreFamily);
auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
size_t allocationSize = MemoryConstants::pageSize;
AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, pDevice->getDeviceBitfield());
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
allocation->setDefaultGmm(new Gmm(pClDevice->getRootDeviceEnvironment().getGmmClientContext(), allocation->getUnderlyingBuffer(), allocation->getUnderlyingBufferSize(), 0, false));
allocation->getDefaultGmm()->isCompressionEnabled = true;
auto rssCmd = FamilyType::cmdInitRenderSurfaceState;
MockContext context(pClDevice);
auto multiGraphicsAllocation = MultiGraphicsAllocation(pClDevice->getRootDeviceIndex());
multiGraphicsAllocation.addAllocation(allocation);
std::unique_ptr<BufferHw<FamilyType>> buffer(static_cast<BufferHw<FamilyType> *>(
BufferHw<FamilyType>::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, multiGraphicsAllocation, false, false, false)));
raiiFactory.mockHwHelper.compressionFormat = 0xF;
EncodeSurfaceState<FamilyType>::encodeBuffer(&rssCmd, allocation->getGpuAddress(), allocation->getUnderlyingBufferSize(),
buffer->getMocsValue(false, false, pClDevice->getRootDeviceIndex()), false, false, false,
pClDevice->getNumAvailableDevices(), allocation, pClDevice->getGmmHelper(), false, 1u);
EXPECT_EQ(static_cast<uint32_t>(0xF), rssCmd.getCompressionFormat());
}

View File

@@ -14,9 +14,11 @@
#include "shared/test/common/helpers/variable_backup.h"
#include "opencl/test/unit_test/fixtures/image_fixture.h"
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_hw_helper.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "test.h"
@@ -659,3 +661,43 @@ HWTEST2_F(XeHPAndLaterImageHelperTests, givenNotMediaCompressedImageWhenAppendin
EXPECT_EQ(expectedGetSurfaceStateCompressionFormatCalled, gmmClientContext->getSurfaceStateCompressionFormatCalled);
EXPECT_EQ(expectedGetMediaSurfaceStateCompressionFormatCalled, gmmClientContext->getMediaSurfaceStateCompressionFormatCalled);
}
HWTEST2_F(XeHPAndLaterImageHelperTests, givenMediaCompressedImageWhenImageFromBufferIsCreatedAndForceBufferCompressionFormatIsSpecifiedThenApplyFormatCorrectly, CompressionParamsSupportedMatcher) {
DebugManagerStateRestore restorer;
DebugManager.flags.ForceBufferCompressionFormat.set(0x2);
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperWithCompressionFormat<FamilyType>>(defaultHwInfo->platform.eRenderCoreFamily);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE rss{};
platformsImpl->clear();
rss.setMemoryCompressionEnable(true);
mockGmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
gmmClientContext->compressionFormatToReturn = mockCompressionFormat;
EncodeSurfaceState<FamilyType>::appendImageCompressionParams(&rss, image->getMultiGraphicsAllocation().getDefaultGraphicsAllocation(),
context->getDevice(0)->getGmmHelper(), true);
EXPECT_EQ(static_cast<uint32_t>(0x2), rss.getCompressionFormat());
}
HWTEST2_F(XeHPAndLaterImageHelperTests, givenNotMediaCompressedImageWhenStatelessCompressionIsEnabledThenApplyFormatForStatelessCompression, CompressionParamsSupportedMatcher) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableStatelessCompression.set(1);
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperWithCompressionFormat<FamilyType>>(defaultHwInfo->platform.eRenderCoreFamily);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE rss{};
platformsImpl->clear();
rss.setMemoryCompressionEnable(true);
mockGmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false;
gmmClientContext->compressionFormatToReturn = mockCompressionFormat;
raiiFactory.mockHwHelper.compressionFormat = 0xF;
EncodeSurfaceState<FamilyType>::appendImageCompressionParams(&rss, image->getMultiGraphicsAllocation().getDefaultGraphicsAllocation(),
context->getDevice(0)->getGmmHelper(), true);
EXPECT_EQ(static_cast<uint32_t>(0xF), rss.getCompressionFormat());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -26,4 +26,13 @@ class MockHwHelperWithLocalMemory : public HwHelperHw<GfxFamily> {
return true;
}
};
template <typename GfxFamily>
class MockHwHelperWithCompressionFormat : public HwHelperHw<GfxFamily> {
public:
uint32_t getFormatForStatelessCompression(const uint32_t format) const override {
return compressionFormat;
}
uint32_t compressionFormat = 0;
};
} // namespace NEO

View File

@@ -16,10 +16,12 @@
#include "shared/test/unit_test/utilities/base_object_utils.h"
#include "opencl/source/command_queue/command_queue_hw.h"
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_hw_helper.h"
#include "test.h"
using namespace NEO;
@@ -710,3 +712,38 @@ XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenCommandQueueWhenAskingForCacheFlushO
EXPECT_TRUE(pHwQ->isCacheFlushForBcsRequired());
}
XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenAppendBlitCommandsForBufferWhenStatelessCompressionIsEnabledThenApplyFormatForStatelessCompression) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
DebugManager.flags.EnableStatelessCompression.set(1);
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperWithCompressionFormat<FamilyType>>(defaultHwInfo->platform.eRenderCoreFamily);
char buff[1024] = {0};
LinearStream stream(buff, 1024);
MockGraphicsAllocation clearColorAlloc;
MockContext context(clDevice.get());
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(&context, {}, MemoryConstants::pageSize64k, nullptr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
auto allocation = buffer->getGraphicsAllocation(clDevice->getRootDeviceIndex());
EXPECT_TRUE(!MemoryPool::isSystemMemoryPool(allocation->getMemoryPool()));
auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation,
0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc);
auto bltCmd = stream.getSpaceForCmd<XY_COPY_BLT>();
*bltCmd = FamilyType::cmdInitXyCopyBlt;
platformsImpl->clear();
EXPECT_EQ(platform(), nullptr);
raiiFactory.mockHwHelper.compressionFormat = 0xF;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForBuffer(blitProperties, *bltCmd, clDevice->getRootDeviceEnvironment());
EXPECT_EQ(static_cast<uint32_t>(0xF), bltCmd->getSourceCompressionFormat());
EXPECT_EQ(static_cast<uint32_t>(0xF), bltCmd->getDestinationCompressionFormat());
}

View File

@@ -79,6 +79,13 @@ XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenGenHelperWhenRevisionIsAtLeastBTh
}
}
XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenHwHelperWhenGettingFormatForStatelessCompressionThenCorrectValueIsReturned) {
auto &hwHelper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
uint32_t format = 0x2;
EXPECT_EQ(format, hwHelper.getFormatForStatelessCompression(format));
}
XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenGenHelperWhenCreateMultipleSubDevicesThenDontAllowStatelessCompression) {
DebugManagerStateRestore restore;
DebugManager.flags.CreateMultipleSubDevices.set(2);