Gmm utils separation

Change-Id: I9f2bdf249aa04b2ada216eee92771880202f5576
This commit is contained in:
Dunajski, Bartosz
2018-01-16 13:08:14 +01:00
parent be6f211910
commit d11474beab
8 changed files with 41 additions and 124 deletions

View File

@@ -479,11 +479,11 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
endif()
# Project-wide include paths
set(SKU_INFO_SRCS_DIR_SUFFIX "/")
set(BRANCH_DIR_SUFFIX "/")
include_directories(${IGDRCL_SOURCE_DIR})
include_directories(${IGDRCL_BUILD_DIR})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${SKU_INFO_SRCS_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/instrumentation${SKU_INFO_SRCS_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${BRANCH_DIR_SUFFIX})
include_directories(${IGDRCL_SOURCE_DIR}/runtime/instrumentation${BRANCH_DIR_SUFFIX})
if(HAVE_INSTRUMENTATION)
include_directories($<TARGET_PROPERTY:instrumentation_umd,INTERFACE_INCLUDE_DIRECTORIES>)
endif()

View File

@@ -336,8 +336,8 @@ set (RUNTIME_SRCS_INDIRECT_HEAP
)
set (RUNTIME_SRCS_INSTRUMENTATION
instrumentation${SKU_INFO_SRCS_DIR_SUFFIX}/instrumentation.cpp
instrumentation${SKU_INFO_SRCS_DIR_SUFFIX}/instrumentation.h
instrumentation${BRANCH_DIR_SUFFIX}/instrumentation.cpp
instrumentation${BRANCH_DIR_SUFFIX}/instrumentation.h
)
set (RUNTIME_SRCS_KERNEL
@@ -374,6 +374,7 @@ set (RUNTIME_SRCS_GMM_HELPER
gmm_helper/gmm_helper.h
gmm_helper/gmm_lib.h
gmm_helper/resource_info.h
gmm_helper${BRANCH_DIR_SUFFIX}/gmm_utils.cpp
)
if (WIN32)
@@ -461,14 +462,14 @@ list (APPEND RUNTIME_SRCS_SCHEDULER
set (RUNTIME_SRCS_SKU_INFO
sku_info/sku_info_base.h
sku_info/operations/sku_info_transfer.h
sku_info/definitions${SKU_INFO_SRCS_DIR_SUFFIX}/sku_info.h
sku_info/operations${SKU_INFO_SRCS_DIR_SUFFIX}/sku_info_transfer.cpp
sku_info/definitions${BRANCH_DIR_SUFFIX}/sku_info.h
sku_info/operations${BRANCH_DIR_SUFFIX}/sku_info_transfer.cpp
)
if (WIN32)
list (APPEND RUNTIME_SRCS_SKU_INFO
sku_info/operations/sku_info_receiver.h
sku_info/operations${SKU_INFO_SRCS_DIR_SUFFIX}/sku_info_receiver.cpp
sku_info/operations${BRANCH_DIR_SUFFIX}/sku_info_receiver.cpp
)
endif(WIN32)

View File

@@ -176,14 +176,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) {
this->resourceParams.Flags.Info.AllowVirtualPadding = true;
}
if (hwInfo.capabilityTable.ftrCompression && imgInfo.preferRenderCompression && auxFormatSupported(this->resourceParams.Format)) {
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;
}
applyAuxFlags(imgInfo, hwInfo);
this->gmmResourceInfo.reset(GmmResourceInfo::create(&this->resourceParams));
@@ -392,9 +385,4 @@ uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t heig
return this->gmmResourceInfo->cpuBlt(&gmmResourceCopyBLT);
}
bool Gmm::auxFormatSupported(GMM_RESOURCE_FORMAT &gmmFormat) {
const auto &formatInfo = pGmmGlobalContext->GetPlatformInfo().FormatTable[gmmFormat];
return !!formatInfo.AuxL1eFormat;
}
} // namespace OCLRT

View File

@@ -82,7 +82,7 @@ class Gmm {
uint32_t getRenderHAlignment();
uint32_t getRenderVAlignment();
static uint32_t getRenderAlignment(uint32_t alignment);
bool auxFormatSupported(GMM_RESOURCE_FORMAT &gmmFormat);
void applyAuxFlags(ImageInfo &imgInfo, const HardwareInfo &hwInfo);
uint32_t queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType);

View File

@@ -0,0 +1,28 @@
/*
* 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 "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/surface_formats.h"
void OCLRT::Gmm::applyAuxFlags(ImageInfo &imgInfo, const HardwareInfo &hwInfo) {
}

View File

@@ -21,6 +21,5 @@
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
)

View File

@@ -1,99 +0,0 @@
/*
* 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;
setupImgInfo();
}
void setupImgInfo() {
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imgDesc.image_width = 2;
imgDesc.image_height = 2;
imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
imgInfo.preferRenderCompression = true;
}
HardwareInfo localPlatformDevice = {};
cl_image_desc imgDesc = {};
ImageInfo imgInfo = {};
};
TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrEnabledWhenQueryingThenSetAppropriateFlags) {
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) {
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) {
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);
}
TEST_F(GmmCompressionTests, givenSupportedAuxL1FormatWhenQueryingThenAllow) {
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
auto resourceFormat = queryGmm->gmmResourceInfo->getResourceFormat();
EXPECT_TRUE(queryGmm->auxFormatSupported(resourceFormat));
EXPECT_TRUE(queryGmm->isRenderCompressed);
}
TEST_F(GmmCompressionTests, givenNotSupportedAuxL1FormatWhenQueryingThenDisallow) {
imgInfo.surfaceFormat = &readOnlyDepthSurfaceFormats[2];
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
auto resourceFormat = queryGmm->gmmResourceInfo->getResourceFormat();
EXPECT_FALSE(queryGmm->auxFormatSupported(resourceFormat));
EXPECT_FALSE(queryGmm->isRenderCompressed);
}

View File

@@ -21,12 +21,12 @@
set(IGDRCL_SRCS_tests_sku_info
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/sku_info_base_reference.h"
"${CMAKE_CURRENT_SOURCE_DIR}${SKU_INFO_SRCS_DIR_SUFFIX}/sku_info_transfer_tests.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/sku_info_transfer_tests.cpp"
)
if (WIN32)
list (APPEND IGDRCL_SRCS_tests_sku_info
"${CMAKE_CURRENT_SOURCE_DIR}${SKU_INFO_SRCS_DIR_SUFFIX}/sku_info_receiver_tests.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/sku_info_receiver_tests.cpp"
)
endif()