mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
preferRenderCompression flag for GMM resources creation
Change-Id: I718fa21d0feb825e0a3215408c78fa49d094a15f
This commit is contained in:
committed by
sys_ocldev
parent
b0c07bf27f
commit
c939419ccc
@@ -118,15 +118,13 @@ Gmm *Gmm::create(GMM_RESOURCE_INFO *inputGmm) {
|
||||
return gmm;
|
||||
}
|
||||
|
||||
Gmm *Gmm::queryImgParams(ImageInfo &imgInfo,
|
||||
GFXCORE_FAMILY gfxFamily) {
|
||||
Gmm *Gmm::createGmmAndQueryImgParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) {
|
||||
Gmm *gmm = new Gmm();
|
||||
gmm->queryImageParams(imgInfo, gfxFamily);
|
||||
gmm->queryImageParams(imgInfo, hwInfo);
|
||||
return gmm;
|
||||
}
|
||||
|
||||
void Gmm::queryImageParams(ImageInfo &imgInfo,
|
||||
GFXCORE_FAMILY gfxFamily) {
|
||||
void Gmm::queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) {
|
||||
uint32_t imageWidth = static_cast<uint32_t>(imgInfo.imgDesc->image_width);
|
||||
uint32_t imageHeight = 1;
|
||||
uint32_t imageDepth = 1;
|
||||
@@ -178,6 +176,15 @@ void Gmm::queryImageParams(ImageInfo &imgInfo,
|
||||
this->resourceParams.Flags.Info.AllowVirtualPadding = true;
|
||||
}
|
||||
|
||||
if (hwInfo.capabilityTable.ftrCompression && imgInfo.preferRenderCompression) {
|
||||
this->resourceParams.Flags.Info.Linear = 0;
|
||||
this->resourceParams.Flags.Info.TiledY = 1;
|
||||
this->resourceParams.Flags.Info.RenderCompressed = 1;
|
||||
this->resourceParams.Flags.Gpu.CCS = 1;
|
||||
this->resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
||||
this->isRenderCompressed = true;
|
||||
}
|
||||
|
||||
this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams));
|
||||
|
||||
imgInfo.size = this->gmmResourceInfo->getSizeAllocation();
|
||||
@@ -229,7 +236,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo,
|
||||
imgInfo.yOffsetForUVPlane = reqOffsetInfo.Lock.Offset / reqOffsetInfo.Lock.Pitch;
|
||||
}
|
||||
|
||||
imgInfo.qPitch = queryQPitch(gfxFamily, this->resourceParams.Type);
|
||||
imgInfo.qPitch = queryQPitch(hwInfo.pPlatform->eRenderCoreFamily, this->resourceParams.Type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ void GMMPrintMessage(uint32_t debugLevel, const char *debugMessageFmt, ...);
|
||||
}
|
||||
|
||||
namespace OCLRT {
|
||||
struct HardwareInfo;
|
||||
struct FeatureTable;
|
||||
struct WorkaroundTable;
|
||||
struct ImageInfo;
|
||||
@@ -63,9 +64,9 @@ class Gmm {
|
||||
|
||||
static uint32_t getMOCS(uint32_t type);
|
||||
|
||||
void queryImageParams(ImageInfo &imgInfo, GFXCORE_FAMILY gfxFamily);
|
||||
void queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo);
|
||||
|
||||
static Gmm *queryImgParams(ImageInfo &imgInfo, GFXCORE_FAMILY gfxFamily);
|
||||
static Gmm *createGmmAndQueryImgParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo);
|
||||
|
||||
static void queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc);
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ struct ImageInfo {
|
||||
uint32_t yOffsetForUVPlane;
|
||||
GMM_YUV_PLANE_ENUM plane;
|
||||
int mipLevel;
|
||||
bool preferRenderCompression;
|
||||
};
|
||||
|
||||
struct McsSurfaceInfo {
|
||||
|
||||
@@ -194,7 +194,7 @@ Image *Image::create(Context *context,
|
||||
if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) {
|
||||
// Retrieve sizes from GMM and apply virtual padding if buffer storage is not big enough
|
||||
auto queryGmmImgInfo(imgInfo);
|
||||
std::unique_ptr<Gmm> gmm(Gmm::queryImgParams(queryGmmImgInfo, hwInfo.pPlatform->eRenderCoreFamily));
|
||||
std::unique_ptr<Gmm> gmm(Gmm::createGmmAndQueryImgParams(queryGmmImgInfo, hwInfo));
|
||||
auto gmmAllocationSize = gmm->gmmResourceInfo->getSizeAllocation();
|
||||
if (gmmAllocationSize > memory->getUnderlyingBufferSize()) {
|
||||
memory = memoryManager->createGraphicsAllocationWithPadding(memory, gmmAllocationSize);
|
||||
@@ -205,11 +205,11 @@ Image *Image::create(Context *context,
|
||||
else if (parentImage != nullptr) {
|
||||
DEBUG_BREAK_IF(!IsNV12Image(&parentImage->getImageFormat()));
|
||||
memory = parentImage->getGraphicsAllocation();
|
||||
memory->gmm->queryImageParams(imgInfo, hwInfo.pPlatform->eRenderCoreFamily);
|
||||
memory->gmm->queryImageParams(imgInfo, hwInfo);
|
||||
isTilingAllowed = parentImage->allowTiling();
|
||||
} else {
|
||||
gmm = new Gmm();
|
||||
gmm->queryImageParams(imgInfo, hwInfo.pPlatform->eRenderCoreFamily);
|
||||
gmm->queryImageParams(imgInfo, hwInfo);
|
||||
if (flags & CL_MEM_USE_HOST_PTR) {
|
||||
errcodeRet = CL_INVALID_HOST_PTR;
|
||||
if (hostPtr) {
|
||||
@@ -668,7 +668,7 @@ cl_int Image::getImageParams(Context *context,
|
||||
|
||||
Gmm *gmm = nullptr;
|
||||
gmm = new Gmm();
|
||||
gmm->queryImageParams(imgInfo, hwInfo.pPlatform->eRenderCoreFamily);
|
||||
gmm->queryImageParams(imgInfo, hwInfo);
|
||||
delete gmm;
|
||||
|
||||
*imageRowPitch = imgInfo.rowPitch;
|
||||
|
||||
@@ -99,7 +99,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
imgDesc.image_width /= 2;
|
||||
imgDesc.image_height /= 2;
|
||||
}
|
||||
Gmm *gmm = Gmm::queryImgParams(imgInfo, context->getDevice(0)->getRenderCoreFamily());
|
||||
Gmm *gmm = Gmm::createGmmAndQueryImgParams(imgInfo, context->getDevice(0)->getHardwareInfo());
|
||||
imgDesc.image_row_pitch = imgInfo.rowPitch;
|
||||
imgDesc.image_slice_pitch = imgInfo.slicePitch;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
|
||||
|
||||
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false, true);
|
||||
|
||||
Gmm *gmm = Gmm::queryImgParams(imgInfo, hwInfo.pPlatform->eRenderCoreFamily);
|
||||
Gmm *gmm = Gmm::createGmmAndQueryImgParams(imgInfo, hwInfo);
|
||||
DEBUG_BREAK_IF(alloc->gmm != nullptr);
|
||||
alloc->gmm = gmm;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ add_subdirectory(gen_common)
|
||||
if(GTPIN_HEADERS_DIR)
|
||||
add_subdirectory(gtpin)
|
||||
endif(GTPIN_HEADERS_DIR)
|
||||
add_subdirectory(gmm_helper)
|
||||
add_subdirectory(helpers)
|
||||
add_subdirectory(indirect_heap)
|
||||
add_subdirectory(instrumentation)
|
||||
@@ -108,6 +109,7 @@ set(IGDRCL_SRCS_tests
|
||||
${IGDRCL_SRCS_tests_execution_model}
|
||||
${IGDRCL_SRCS_tests_fixtures}
|
||||
${IGDRCL_SRCS_tests_gen_common}
|
||||
${IGDRCL_SRCS_tests_gmm_helper}
|
||||
${IGDRCL_SRCS_tests_helpers}
|
||||
${IGDRCL_SRCS_tests_instrumentation}
|
||||
${IGDRCL_SRCS_tests_indirect_heap}
|
||||
@@ -334,6 +336,7 @@ source_group("source files\\event" FILES ${IGDRCL_SRCS_tests_event})
|
||||
source_group("source files\\execution_model" FILES ${IGDRCL_SRCS_tests_execution_model})
|
||||
source_group("source files\\fixtures" FILES ${IGDRCL_SRCS_tests_fixtures})
|
||||
source_group("source files\\gen_common" FILES ${IGDRCL_SRCS_tests_gen_common})
|
||||
source_group("source files\\gmm_helper" FILES ${IGDRCL_SRCS_tests_gmm_helper})
|
||||
source_group("source files\\helpers" FILES ${IGDRCL_SRCS_tests_helpers})
|
||||
source_group("source files\\indirect_heap" FILES ${IGDRCL_SRCS_tests_indirect_heap})
|
||||
source_group("source files\\instrumentation" FILES ${IGDRCL_SRCS_tests_instrumentation})
|
||||
|
||||
26
unit_tests/gmm_helper/CMakeLists.txt
Normal file
26
unit_tests/gmm_helper/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright (c) 2018, Intel Corporation
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
set(IGDRCL_SRCS_tests_gmm_helper
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_compression_tests.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
86
unit_tests/gmm_helper/gmm_compression_tests.cpp
Normal file
86
unit_tests/gmm_helper/gmm_compression_tests.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
|
||||
using namespace ::testing;
|
||||
using namespace OCLRT;
|
||||
|
||||
struct GmmCompressionTests : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
localPlatformDevice = **platformDevices;
|
||||
localPlatformDevice.capabilityTable.ftrCompression = true;
|
||||
}
|
||||
|
||||
void setupImgDesc() {
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgDesc.image_width = 2;
|
||||
imgDesc.image_height = 2;
|
||||
}
|
||||
|
||||
HardwareInfo localPlatformDevice = {};
|
||||
cl_image_desc imgDesc = {};
|
||||
};
|
||||
|
||||
TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrEnabledWhenQueryingThenSetAppropriateFlags) {
|
||||
setupImgDesc();
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
imgInfo.preferRenderCompression = true;
|
||||
|
||||
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
|
||||
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Info.Linear);
|
||||
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Info.TiledY);
|
||||
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(1u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_TRUE(queryGmm->isRenderCompressed);
|
||||
}
|
||||
|
||||
TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrDisabledWhenQueryingThenSetAppropriateFlags) {
|
||||
setupImgDesc();
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
imgInfo.preferRenderCompression = true;
|
||||
localPlatformDevice.capabilityTable.ftrCompression = false;
|
||||
|
||||
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
|
||||
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_FALSE(queryGmm->isRenderCompressed);
|
||||
}
|
||||
|
||||
TEST_F(GmmCompressionTests, givenPreferRenderCompressionDisabledAndCompressionFtrEnabledWhenQueryingThenSetAppropriateFlags) {
|
||||
setupImgDesc();
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
imgInfo.preferRenderCompression = false;
|
||||
|
||||
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
|
||||
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_FALSE(queryGmm->isRenderCompressed);
|
||||
}
|
||||
@@ -22,7 +22,6 @@ set(IGDRCL_SRCS_tests_memory_manager
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/address_mapper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter_mt_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_tests.cpp
|
||||
|
||||
@@ -34,14 +34,12 @@ static SurfaceFormatInfo mockSurfaceFormat;
|
||||
|
||||
class MockGmm : public Gmm {
|
||||
public:
|
||||
static std::unique_ptr<Gmm> queryImgParams(ImageInfo &imgInfo,
|
||||
GFXCORE_FAMILY family = GFXCORE_FAMILY::IGFX_UNKNOWN_CORE) {
|
||||
auto queryFamily = family;
|
||||
if (queryFamily == GFXCORE_FAMILY::IGFX_UNKNOWN_CORE) {
|
||||
const HardwareInfo *hwinfo = *platformDevices;
|
||||
queryFamily = hwinfo->pPlatform->eRenderCoreFamily;
|
||||
static std::unique_ptr<Gmm> queryImgParams(ImageInfo &imgInfo, const HardwareInfo *hwInfo = nullptr) {
|
||||
auto queryHwInfo = hwInfo;
|
||||
if (!queryHwInfo) {
|
||||
queryHwInfo = *platformDevices;
|
||||
}
|
||||
return std::unique_ptr<Gmm>(Gmm::queryImgParams(imgInfo, queryFamily));
|
||||
return std::unique_ptr<Gmm>(Gmm::createGmmAndQueryImgParams(imgInfo, *queryHwInfo));
|
||||
}
|
||||
|
||||
static ImageInfo initImgInfo(cl_image_desc &imgDesc, int mipLevel, const SurfaceFormatInfo *surfaceFormat) {
|
||||
|
||||
Reference in New Issue
Block a user