From d11474beabef3f9c400c85766359156333211587 Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Tue, 16 Jan 2018 13:08:14 +0100 Subject: [PATCH] Gmm utils separation Change-Id: I9f2bdf249aa04b2ada216eee92771880202f5576 --- CMakeLists.txt | 6 +- runtime/CMakeLists.txt | 11 ++- runtime/gmm_helper/gmm_helper.cpp | 14 +-- runtime/gmm_helper/gmm_helper.h | 2 +- runtime/gmm_helper/gmm_utils.cpp | 28 ++++++ unit_tests/gmm_helper/CMakeLists.txt | 1 - .../gmm_helper/gmm_compression_tests.cpp | 99 ------------------- unit_tests/sku_info/CMakeLists.txt | 4 +- 8 files changed, 41 insertions(+), 124 deletions(-) create mode 100644 runtime/gmm_helper/gmm_utils.cpp delete mode 100644 unit_tests/gmm_helper/gmm_compression_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 281ae1789d..b7f4a1cecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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($) endif() diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 05247e482f..405bb5e11a 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -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) diff --git a/runtime/gmm_helper/gmm_helper.cpp b/runtime/gmm_helper/gmm_helper.cpp index 6f69da660f..e78abd3846 100644 --- a/runtime/gmm_helper/gmm_helper.cpp +++ b/runtime/gmm_helper/gmm_helper.cpp @@ -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 diff --git a/runtime/gmm_helper/gmm_helper.h b/runtime/gmm_helper/gmm_helper.h index bf9020f51c..5d23332d31 100644 --- a/runtime/gmm_helper/gmm_helper.h +++ b/runtime/gmm_helper/gmm_helper.h @@ -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); diff --git a/runtime/gmm_helper/gmm_utils.cpp b/runtime/gmm_helper/gmm_utils.cpp new file mode 100644 index 0000000000..e6fb4d6ea9 --- /dev/null +++ b/runtime/gmm_helper/gmm_utils.cpp @@ -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) { +} diff --git a/unit_tests/gmm_helper/CMakeLists.txt b/unit_tests/gmm_helper/CMakeLists.txt index 5862b4e339..f5c944fdbb 100644 --- a/unit_tests/gmm_helper/CMakeLists.txt +++ b/unit_tests/gmm_helper/CMakeLists.txt @@ -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 ) diff --git a/unit_tests/gmm_helper/gmm_compression_tests.cpp b/unit_tests/gmm_helper/gmm_compression_tests.cpp deleted file mode 100644 index 3edea4ad69..0000000000 --- a/unit_tests/gmm_helper/gmm_compression_tests.cpp +++ /dev/null @@ -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); -} diff --git a/unit_tests/sku_info/CMakeLists.txt b/unit_tests/sku_info/CMakeLists.txt index b7c413f9b1..03e78ab112 100644 --- a/unit_tests/sku_info/CMakeLists.txt +++ b/unit_tests/sku_info/CMakeLists.txt @@ -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()