mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
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:

committed by
Compute-Runtime-Automation

parent
d10eb1c04c
commit
54cf561e09
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -631,6 +631,11 @@ void EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(R_SURFACE_STATE *sur
|
||||
auto resourceFormat = gmm->gmmResourceInfo->getResourceFormat();
|
||||
compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
|
||||
|
||||
auto &hwHelper = HwHelper::get(gmmHelper->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
if (hwHelper.allowStatelessCompression(*gmmHelper->getHardwareInfo())) {
|
||||
compressionFormat = hwHelper.getFormatForStatelessCompression(compressionFormat);
|
||||
}
|
||||
|
||||
if (DebugManager.flags.ForceBufferCompressionFormat.get() != -1) {
|
||||
compressionFormat = DebugManager.flags.ForceBufferCompressionFormat.get();
|
||||
}
|
||||
|
@ -23,6 +23,13 @@ void EncodeSurfaceState<Family>::appendImageCompressionParams(R_SURFACE_STATE *s
|
||||
}
|
||||
|
||||
if (imageFromBuffer) {
|
||||
if (!gmmResourceInfo->getResourceFlags()->Info.MediaCompressed) {
|
||||
auto &hwHelper = HwHelper::get(gmmHelper->getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
if (hwHelper.allowStatelessCompression(*gmmHelper->getHardwareInfo())) {
|
||||
compressionFormat = hwHelper.getFormatForStatelessCompression(compressionFormat);
|
||||
}
|
||||
}
|
||||
|
||||
if (DebugManager.flags.ForceBufferCompressionFormat.get() != -1) {
|
||||
compressionFormat = DebugManager.flags.ForceBufferCompressionFormat.get();
|
||||
}
|
||||
|
@ -47,6 +47,12 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProper
|
||||
appendClearColor(blitProperties, blitCmd);
|
||||
|
||||
uint32_t compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT);
|
||||
|
||||
auto &hwHelper = HwHelper::get(rootDeviceEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
if (hwHelper.allowStatelessCompression(*rootDeviceEnvironment.getHardwareInfo())) {
|
||||
compressionFormat = hwHelper.getFormatForStatelessCompression(compressionFormat);
|
||||
}
|
||||
|
||||
if (DebugManager.flags.ForceBufferCompressionFormat.get() != -1) {
|
||||
compressionFormat = DebugManager.flags.ForceBufferCompressionFormat.get();
|
||||
}
|
||||
@ -132,6 +138,12 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForFillBuffer(NEO::Graphic
|
||||
bool dstAllocationisCompressionEnabled = dstAlloc->getDefaultGmm() && dstAlloc->getDefaultGmm()->isCompressionEnabled;
|
||||
|
||||
uint32_t compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT);
|
||||
|
||||
auto &hwHelper = HwHelper::get(rootDeviceEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
|
||||
if (hwHelper.allowStatelessCompression(*rootDeviceEnvironment.getHardwareInfo())) {
|
||||
compressionFormat = hwHelper.getFormatForStatelessCompression(compressionFormat);
|
||||
}
|
||||
|
||||
if (DebugManager.flags.ForceBufferCompressionFormat.get() != -1) {
|
||||
compressionFormat = DebugManager.flags.ForceBufferCompressionFormat.get();
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ class HwHelper {
|
||||
virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) = 0;
|
||||
virtual bool allowRenderCompression(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool allowStatelessCompression(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual uint32_t getFormatForStatelessCompression(const uint32_t format) const = 0;
|
||||
virtual bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const = 0;
|
||||
virtual LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0;
|
||||
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
|
||||
@ -318,6 +319,8 @@ class HwHelperHw : public HwHelper {
|
||||
|
||||
bool allowStatelessCompression(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
uint32_t getFormatForStatelessCompression(const uint32_t format) const override;
|
||||
|
||||
bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const override;
|
||||
|
||||
LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override;
|
||||
|
@ -451,6 +451,11 @@ inline bool HwHelperHw<GfxFamily>::allowStatelessCompression(const HardwareInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
inline uint32_t HwHelperHw<GfxFamily>::getFormatForStatelessCompression(const uint32_t format) const {
|
||||
return format;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
inline bool HwHelperHw<GfxFamily>::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const {
|
||||
return allocation.isAllocatedInLocalMemoryPool() &&
|
||||
|
@ -13,7 +13,9 @@
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
||||
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_hw_helper.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "test_traits_common.h"
|
||||
@ -896,6 +898,29 @@ HWTEST2_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBl
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenAppendBlitCommandsForFillBufferWhenStatelessCompressionIsEnabledThenApplyApplyFormatForStatelessCompression, BlitPlatforms) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableStatelessCompression.set(1);
|
||||
|
||||
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperWithCompressionFormat<FamilyType>>(defaultHwInfo->platform.eRenderCoreFamily);
|
||||
|
||||
auto blitCmd = FamilyType::cmdInitXyColorBlt;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
gmm->isCompressionEnabled = true;
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, mockMaxOsContextCount);
|
||||
mockAllocation.setGmm(gmm.get(), 0);
|
||||
|
||||
raiiFactory.mockHwHelper.compressionFormat = 0xF;
|
||||
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForFillBuffer(&mockAllocation, blitCmd, *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
|
||||
EXPECT_EQ(static_cast<uint32_t>(0xF), blitCmd.getDestinationCompressionFormat());
|
||||
}
|
||||
|
||||
using IsXeHPOrAbove = IsAtLeastProduct<IGFX_XE_HP_SDV>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenEnabledGlobalCacheInvalidationWhenProgrammingGlobalSequencerFlushThenCommandsAreProgrammed, IsXeHPOrAbove) {
|
||||
|
Reference in New Issue
Block a user