mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Correct media compression format for blitter operations on planar images
Set most significant bit for chroma planes. Move common logic to helper function. Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9959896957
commit
944319b3d9
@@ -309,6 +309,8 @@ struct EncodeWA {
|
||||
static void setAdditionalPipeControlFlagsForNonPipelineStateCommand(PipeControlArgs &args);
|
||||
|
||||
static void addPipeControlBeforeStateBaseAddress(LinearStream &commandStream, const HardwareInfo &hwInfo, bool isRcs);
|
||||
|
||||
static void adjustCompressionFormatForPlanarImage(uint32_t &compressionFormat, GMM_YUV_PLANE_ENUM plane);
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -438,6 +438,10 @@ inline void EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(LinearStre
|
||||
NEO::EncodeWA<GfxFamily>::addPipeControlPriorToNonPipelinedStateCommand(commandStream, args, hwInfo, isRcs);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
inline void EncodeWA<GfxFamily>::adjustCompressionFormatForPlanarImage(uint32_t &compressionFormat, GMM_YUV_PLANE_ENUM plane) {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
inline void EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(EncodeSurfaceStateArgs &args) {
|
||||
auto surfaceState = reinterpret_cast<R_SURFACE_STATE *>(args.outMemory);
|
||||
|
||||
@@ -694,6 +694,15 @@ inline void EncodeWA<Family>::addPipeControlPriorToNonPipelinedStateCommand(Line
|
||||
MemorySynchronizationCommands<Family>::addPipeControl(commandStream, args);
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
void EncodeWA<Family>::adjustCompressionFormatForPlanarImage(uint32_t &compressionFormat, GMM_YUV_PLANE_ENUM plane) {
|
||||
if (plane == GMM_PLANE_Y) {
|
||||
compressionFormat &= 0xf;
|
||||
} else if ((plane == GMM_PLANE_U) || (plane == GMM_PLANE_V)) {
|
||||
compressionFormat |= 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
inline void EncodeStoreMemory<Family>::programStoreDataImm(MI_STORE_DATA_IMM *cmdBuffer,
|
||||
uint64_t gpuAddress,
|
||||
|
||||
@@ -16,15 +16,11 @@ void EncodeSurfaceState<Family>::appendImageCompressionParams(R_SURFACE_STATE *s
|
||||
const auto ccsMode = R_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E;
|
||||
const auto mcsLceMode = R_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS_LCE;
|
||||
if ((ccsMode == surfaceState->getAuxiliarySurfaceMode() || mcsLceMode == surfaceState->getAuxiliarySurfaceMode() || surfaceState->getMemoryCompressionEnable())) {
|
||||
uint8_t compressionFormat;
|
||||
uint32_t compressionFormat;
|
||||
auto gmmResourceInfo = allocation->getDefaultGmm()->gmmResourceInfo.get();
|
||||
if (gmmResourceInfo->getResourceFlags()->Info.MediaCompressed) {
|
||||
compressionFormat = gmmHelper->getClientContext()->getMediaSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat());
|
||||
if (plane == GMM_PLANE_Y) {
|
||||
compressionFormat &= 0xf;
|
||||
} else if ((plane == GMM_PLANE_U) || (plane == GMM_PLANE_V)) {
|
||||
compressionFormat |= 0x10;
|
||||
}
|
||||
EncodeWA<Family>::adjustCompressionFormatForPlanarImage(compressionFormat, plane);
|
||||
} else {
|
||||
compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat());
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ void BlitCommandsHelper<Family>::appendColorDepth(const BlitProperties &blitProp
|
||||
}
|
||||
|
||||
template <>
|
||||
void BlitCommandsHelper<Family>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
void BlitCommandsHelper<Family>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch,
|
||||
GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails,
|
||||
const RootDeviceEnvironment &rootDeviceEnvironment, GMM_YUV_PLANE_ENUM plane) {
|
||||
if (allocation.getDefaultGmm()) {
|
||||
auto gmmResourceInfo = allocation.getDefaultGmm()->gmmResourceInfo.get();
|
||||
if (!gmmResourceInfo->getResourceFlags()->Info.Linear) {
|
||||
@@ -90,8 +92,10 @@ void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitPropertie
|
||||
uint32_t mipTailLod = 0;
|
||||
auto compressionDetails = 0u;
|
||||
|
||||
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails, rootDeviceEnvironment);
|
||||
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails, rootDeviceEnvironment);
|
||||
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails,
|
||||
rootDeviceEnvironment, blitProperties.srcPlane);
|
||||
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails,
|
||||
rootDeviceEnvironment, blitProperties.dstPlane);
|
||||
|
||||
blitCmd.setSourcePitch(srcRowPitch);
|
||||
blitCmd.setDestinationPitch(dstRowPitch);
|
||||
|
||||
@@ -83,6 +83,8 @@ struct BlitProperties {
|
||||
Vec3<size_t> dstSize = 0;
|
||||
Vec3<size_t> srcSize = 0;
|
||||
size_t bytesPerPixel = 1;
|
||||
GMM_YUV_PLANE_ENUM dstPlane = GMM_YUV_PLANE_ENUM::GMM_NO_PLANE;
|
||||
GMM_YUV_PLANE_ENUM srcPlane = GMM_YUV_PLANE_ENUM::GMM_NO_PLANE;
|
||||
|
||||
bool isImageOperation() const {
|
||||
return blitDirection == BlitterConstants::BlitDirection::HostPtrToImage ||
|
||||
@@ -157,7 +159,9 @@ struct BlitCommandsHelper {
|
||||
static void appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd);
|
||||
static void appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch);
|
||||
static void appendBaseAddressOffset(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd, const uint32_t originalSliceIndex, const bool isSource);
|
||||
static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType,
|
||||
uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment,
|
||||
GMM_YUV_PLANE_ENUM plane);
|
||||
static void dispatchDebugPauseCommands(LinearStream &commandStream, uint64_t debugPauseStateGPUAddress, DebugPauseState confirmationTrigger,
|
||||
DebugPauseState waitCondition, const HardwareInfo &hwInfo);
|
||||
static size_t getSizeForDebugPauseCommands();
|
||||
|
||||
@@ -74,7 +74,9 @@ void BlitCommandsHelper<GfxFamily>::appendSliceOffsets(const BlitProperties &bli
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch,
|
||||
GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails,
|
||||
const RootDeviceEnvironment &rootDeviceEnvironment, GMM_YUV_PLANE_ENUM plane) {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -266,7 +266,9 @@ void BlitCommandsHelper<GfxFamily>::appendColorDepth(const BlitProperties &blitP
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch,
|
||||
GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails,
|
||||
const RootDeviceEnvironment &rootDeviceEnvironment, GMM_YUV_PLANE_ENUM plane) {
|
||||
if (allocation.getDefaultGmm()) {
|
||||
auto gmmResourceInfo = allocation.getDefaultGmm()->gmmResourceInfo.get();
|
||||
mipTailLod = gmmResourceInfo->getMipTailStartLodSurfaceState();
|
||||
@@ -285,6 +287,7 @@ void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAl
|
||||
auto gmmClientContext = rootDeviceEnvironment.getGmmClientContext();
|
||||
if (resInfo.MediaCompressed) {
|
||||
compressionDetails = gmmClientContext->getMediaSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat());
|
||||
EncodeWA<GfxFamily>::adjustCompressionFormatForPlanarImage(compressionDetails, plane);
|
||||
} else if (resInfo.RenderCompressed) {
|
||||
compressionDetails = gmmClientContext->getSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat());
|
||||
}
|
||||
@@ -306,8 +309,10 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProper
|
||||
auto srcCompressionFormat = blitCmd.getSourceCompressionFormat();
|
||||
auto dstCompressionFormat = blitCmd.getDestinationCompressionFormat();
|
||||
|
||||
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, srcTileType, srcMipTailLod, srcCompressionFormat, rootDeviceEnvironment);
|
||||
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, dstTileType, dstMipTailLod, dstCompressionFormat, rootDeviceEnvironment);
|
||||
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, srcTileType, srcMipTailLod, srcCompressionFormat,
|
||||
rootDeviceEnvironment, blitProperties.srcPlane);
|
||||
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, dstTileType, dstMipTailLod, dstCompressionFormat,
|
||||
rootDeviceEnvironment, blitProperties.dstPlane);
|
||||
|
||||
srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch);
|
||||
dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch);
|
||||
|
||||
@@ -529,7 +529,8 @@ HWTEST2_F(BlitTests, givenGen9AndGetBlitAllocationPropertiesThenCorrectValuesAre
|
||||
auto expectedMipTailLod = mipTailLod;
|
||||
auto compressionDetails = 0u;
|
||||
|
||||
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod, compressionDetails, pDevice->getRootDeviceEnvironment());
|
||||
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod, compressionDetails,
|
||||
pDevice->getRootDeviceEnvironment(), GMM_YUV_PLANE_ENUM::GMM_NO_PLANE);
|
||||
|
||||
EXPECT_EQ(expectedPitch, pitch);
|
||||
EXPECT_EQ(expectedQPitch, qPitch);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/test/common/helpers/blit_commands_helper_tests.inl"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_client_context.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -606,7 +607,8 @@ HWTEST2_F(BlitTests, givenGmmParamsWhenGetBlitAllocationPropertiesIsCalledThenCo
|
||||
uint32_t mipTailLod = 0;
|
||||
uint32_t compressionFormat = 0;
|
||||
auto rowPitch = static_cast<uint32_t>(properties.srcRowPitch);
|
||||
BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(*properties.srcAllocation, rowPitch, qPitch, tileType, mipTailLod, compressionFormat, pDevice->getRootDeviceEnvironment());
|
||||
BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(*properties.srcAllocation, rowPitch, qPitch, tileType, mipTailLod,
|
||||
compressionFormat, pDevice->getRootDeviceEnvironment(), GMM_YUV_PLANE_ENUM::GMM_NO_PLANE);
|
||||
|
||||
if (compressionExpected) {
|
||||
EXPECT_GT(compressionFormat, 0u);
|
||||
@@ -616,6 +618,60 @@ HWTEST2_F(BlitTests, givenGmmParamsWhenGetBlitAllocationPropertiesIsCalledThenCo
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlaneWhenGetBlitAllocationPropertiesIsCalledThenCompressionFormatIsProperlyAdjusted, CompressionParamsSupportedMatcher) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
|
||||
struct {
|
||||
uint8_t returnedCompressionFormat;
|
||||
uint8_t expectedCompressionFormat;
|
||||
GMM_YUV_PLANE_ENUM plane;
|
||||
} testInputs[] = {
|
||||
// regular image
|
||||
{0x0, 0x0, GMM_NO_PLANE},
|
||||
{0xF, 0xF, GMM_NO_PLANE},
|
||||
{0x10, 0x10, GMM_NO_PLANE},
|
||||
{0x1F, 0x1F, GMM_NO_PLANE},
|
||||
// luma plane
|
||||
{0x0, 0x0, GMM_PLANE_Y},
|
||||
{0xF, 0xF, GMM_PLANE_Y},
|
||||
{0x10, 0x0, GMM_PLANE_Y},
|
||||
{0x1F, 0xF, GMM_PLANE_Y},
|
||||
// chroma plane
|
||||
{0x0, 0x10, GMM_PLANE_U},
|
||||
{0x0, 0x10, GMM_PLANE_V},
|
||||
{0xF, 0x1F, GMM_PLANE_U},
|
||||
{0xF, 0x1F, GMM_PLANE_V},
|
||||
{0x10, 0x10, GMM_PLANE_U},
|
||||
{0x10, 0x10, GMM_PLANE_V},
|
||||
{0x1F, 0x1F, GMM_PLANE_U},
|
||||
{0x1F, 0x1F, GMM_PLANE_V},
|
||||
};
|
||||
|
||||
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmClientContext());
|
||||
auto &resInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get())->getResourceFlags()->Info;
|
||||
resInfo.MediaCompressed = true;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
auto gmmClientContext = static_cast<MockGmmClientContext *>(pDevice->getGmmHelper()->getClientContext());
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
uint32_t qPitch = static_cast<uint32_t>(properties.copySize.y);
|
||||
GMM_TILE_TYPE tileType = GMM_NOT_TILED;
|
||||
uint32_t mipTailLod = 0;
|
||||
uint32_t compressionFormat = 0;
|
||||
auto rowPitch = static_cast<uint32_t>(properties.srcRowPitch);
|
||||
|
||||
for (auto &testInput : testInputs) {
|
||||
gmmClientContext->compressionFormatToReturn = testInput.returnedCompressionFormat;
|
||||
BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(*properties.srcAllocation, rowPitch, qPitch, tileType, mipTailLod,
|
||||
compressionFormat, pDevice->getRootDeviceEnvironment(), testInput.plane);
|
||||
|
||||
EXPECT_EQ(testInput.expectedCompressionFormat, compressionFormat);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenA0orA1SteppingAndCpuLocalMemoryAccessWhenCallingAppendExtraMemoryPropertiesThenTargetMemoryIsSet, IsXeHpCore) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
|
||||
@@ -170,4 +170,16 @@ HWTEST_F(CommandEncoderTest, givenPlatformSupportingMiMemFenceWhenEncodingThenPr
|
||||
EXPECT_EQ(0u, size);
|
||||
EXPECT_EQ(0u, cmdStream.getUsed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandEncoderTest, whenAdjustCompressionFormatForPlanarImageThenNothingHappens, IsAtMostGen12lp) {
|
||||
for (auto plane : {GMM_NO_PLANE, GMM_PLANE_Y, GMM_PLANE_U, GMM_PLANE_V}) {
|
||||
uint32_t compressionFormat = 0u;
|
||||
EncodeWA<FamilyType>::adjustCompressionFormatForPlanarImage(compressionFormat, plane);
|
||||
EXPECT_EQ(0u, compressionFormat);
|
||||
|
||||
compressionFormat = 0xFFu;
|
||||
EncodeWA<FamilyType>::adjustCompressionFormatForPlanarImage(compressionFormat, plane);
|
||||
EXPECT_EQ(0xFFu, compressionFormat);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user