Skip to content

Commit 5b61c8a

Browse files
drprajapgfxbot
authored andcommitted
Use DLL interfaces for ULT
Adding two Exported APIs in DLL - GmmInit and GmmDestroy. GmmInit initializes singleton global context and ClientContext. This avoid the need for clients to fill up function table. Change-Id: I3bab29d2c10fd4d06cf78e1f33c9479d536477da Signed-off-by: drprajap <[email protected]>
1 parent 96c72ed commit 5b61c8a

12 files changed

+255
-137
lines changed

Source/GmmLib/GlobalInfo/GmmClientContext.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@ GMM_PLATFORM_INFO &GMM_STDCALL GmmLib::GmmClientContext::GetPlatformInfo()
189189
return pGmmGlobalContext->GetPlatformInfo();
190190
}
191191

192+
/////////////////////////////////////////////////////////////////////////////////////
193+
/// Member function of ClientContext class for getting Alignment info
194+
///
195+
/// @return void
196+
//////////////////////////////////////////////////////////////////////////////////
197+
void GMM_STDCALL GmmLib::GmmClientContext::GetExtendedTextureAlign(uint32_t Mode, ALIGNMENT &UnitAlign)
198+
{
199+
ALIGNMENT AlignInfo;
200+
pGmmGlobalContext->GetPlatformInfoObj()->ApplyExtendedTexAlign(Mode, AlignInfo);
201+
UnitAlign = AlignInfo;
202+
}
203+
192204
/////////////////////////////////////////////////////////////////////////////////////
193205
/// Member function of ClientContext class for returning whether the given Resource
194206
/// format is Planar

Source/GmmLib/GlobalInfo/GmmLibDllMain.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,47 @@ extern "C" GMM_LIB_API GMM_STATUS GMM_STDCALL OpenGmm(GmmExportEntries *pm_GmmFu
8484
return Status;
8585
}
8686

87+
/////////////////////////////////////////////////////////////////////////////////////
88+
/// First Call to GMM Lib DLL/so to initialize singleton global context
89+
/// and create client context
90+
///
91+
/////////////////////////////////////////////////////////////////////////////////////
92+
#ifdef _WIN32
93+
extern "C" GMM_LIB_API GMM_CLIENT_CONTEXT *GMM_STDCALL GmmInit(const PLATFORM Platform,
94+
const SKU_FEATURE_TABLE *pSkuTable,
95+
const WA_TABLE * pWaTable,
96+
const GT_SYSTEM_INFO * pGtSysInfo,
97+
GMM_CLIENT ClientType)
98+
#else
99+
extern "C" GMM_LIB_API GMM_CLIENT_CONTEXT *GMM_STDCALL GmmInit(const PLATFORM Platform,
100+
const void * pSkuTable,
101+
const void * pWaTable,
102+
const void * pGtSysInfo,
103+
GMM_CLIENT ClientType)
87104
#endif
105+
{
106+
GMM_STATUS Status = GMM_SUCCESS;
107+
GMM_CLIENT_CONTEXT *pClientContext = NULL;
108+
109+
110+
Status = GmmCreateSingletonContext(Platform, pSkuTable, pWaTable, pGtSysInfo);
111+
112+
if(Status == GMM_SUCCESS)
113+
{
114+
pClientContext = GmmCreateClientContext(ClientType);
115+
}
116+
117+
return pClientContext;
118+
}
119+
120+
121+
/////////////////////////////////////////////////////////////////////////////////////
122+
/// Destroys singleton global context and client context
123+
///
124+
/////////////////////////////////////////////////////////////////////////////////////
125+
extern "C" GMM_LIB_API void GMM_STDCALL GmmDestroy(GMM_CLIENT_CONTEXT *pGmmClientContext)
126+
{
127+
GmmDestroySingletonContext();
128+
GmmDeleteClientContext(pGmmClientContext);
129+
}
130+
#endif // GMM_LIB_DLL

Source/GmmLib/ULT/CMakeLists.txt

Lines changed: 72 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
set (EXE_NAME GMMULT)
2222

2323
set(GMMULT_HEADERS
24-
GmmCachePolicyULT.h
25-
GmmCommonULT.h
26-
GmmGen10CachePolicyULT.h
27-
GmmGen10ResourceULT.h
28-
GmmGen11CachePolicyULT.h
29-
GmmGen9CachePolicyULT.h
30-
GmmGen9ResourceULT.h
31-
GmmResourceULT.h
32-
stdafx.h
33-
targetver.h
34-
)
24+
GmmCachePolicyULT.h
25+
GmmCommonULT.h
26+
GmmGen10CachePolicyULT.h
27+
GmmGen10ResourceULT.h
28+
GmmGen11CachePolicyULT.h
29+
GmmGen9CachePolicyULT.h
30+
GmmGen9ResourceULT.h
31+
GmmResourceULT.h
32+
stdafx.h
33+
targetver.h
34+
)
3535

3636
set(GMMULT_SOURCES
3737
GmmCachePolicyULT.cpp
@@ -48,36 +48,36 @@ set(GMMULT_SOURCES
4848
)
4949

5050
source_group("Source Files\\Cache Policy" FILES
51-
GmmCachePolicyULT.cpp
52-
GmmGen9CachePolicyULT.cpp
53-
GmmGen10CachePolicyULT.cpp
54-
GmmGen11CachePolicyULT.cpp
55-
)
51+
GmmCachePolicyULT.cpp
52+
GmmGen9CachePolicyULT.cpp
53+
GmmGen10CachePolicyULT.cpp
54+
GmmGen11CachePolicyULT.cpp
55+
)
5656

5757
source_group("Source Files\\Resource" FILES
58-
GmmGen10ResourceULT.cpp
59-
GmmGen9ResourceULT.cpp
60-
GmmResourceCpuBltULT.cpp
61-
GmmResourceULT.cpp
62-
)
58+
GmmGen10ResourceULT.cpp
59+
GmmGen9ResourceULT.cpp
60+
GmmResourceCpuBltULT.cpp
61+
GmmResourceULT.cpp
62+
)
6363

6464
source_group("Header Files\\Cache Policy" FILES
65-
GmmCachePolicyULT.h
66-
GmmGen10CachePolicyULT.h
67-
GmmGen11CachePolicyULT.h
68-
GmmGen9CachePolicyULT.h
69-
)
65+
GmmCachePolicyULT.h
66+
GmmGen10CachePolicyULT.h
67+
GmmGen11CachePolicyULT.h
68+
GmmGen9CachePolicyULT.h
69+
)
7070

7171
source_group("Header Files\\Resource" FILES
72-
GmmGen10ResourceULT.h
73-
GmmGen9ResourceULT.h
74-
GmmResourceULT.h
75-
)
72+
GmmGen10ResourceULT.h
73+
GmmGen9ResourceULT.h
74+
GmmResourceULT.h
75+
)
7676

7777
source_group("gtest" FILES
78-
googletest/gtest/gtest.h
79-
googletest/src/gtest-all.cc
80-
)
78+
googletest/gtest/gtest.h
79+
googletest/src/gtest-all.cc
80+
)
8181

8282
include_directories(BEFORE ./)
8383

@@ -90,37 +90,62 @@ include_directories(
9090
${BS_DIR_INC}
9191
${BS_DIR_GMMLIB}/inc
9292
${BS_DIR_INC}/common
93-
)
93+
)
9494

9595
if(MSVC)
96+
9697
include_directories(
97-
${BS_DIR_D3D11}/Imola
98+
${BS_DIR_D3D11}/Imola
9899
)
99100
endif()
100101

102+
macro(GmmLibULTSetTargetConfig ultTarget)
103+
if (TARGET ${ultTarget})
104+
set_property(TARGET ${ultTarget} APPEND PROPERTY COMPILE_DEFINITIONS
105+
$<$<CONFIG:Release>: _RELEASE>
106+
$<$<CONFIG:ReleaseInternal>: _RELEASE_INTERNAL>
107+
$<$<CONFIG:Debug>: _DEBUG>
108+
)
109+
endif()
110+
111+
endmacro()
112+
101113
add_executable(${EXE_NAME} ${GMMULT_HEADERS} ${GMMULT_SOURCES})
102114

115+
GmmLibULTSetTargetConfig(${EXE_NAME})
116+
117+
103118
if(MSVC)
104119
bs_set_wdk(${EXE_NAME})
105-
endif()
106120

107-
set_property(TARGET ${EXE_NAME} APPEND PROPERTY COMPILE_DEFINITIONS __GMM GMM_EXCITE)
121+
set_property(TARGET ${EXE_NAME} APPEND PROPERTY COMPILE_DEFINITIONS __GMM GMM_LIB_DLL GMM_ULT __UMD)
108122

109-
target_link_libraries(${EXE_NAME}
110-
igfx_gmmumd_excite
123+
add_dependencies(${EXE_NAME}
124+
igfx_gmmumd_dll
111125
)
112126

113-
if(MSVC)
114127
target_link_libraries( ${EXE_NAME}
115-
advapi32.lib
116-
dxgi.lib
117-
gdi32.lib
118-
opengl32.lib
119-
user32.lib
120-
)
128+
advapi32.lib
129+
dxgi.lib
130+
gdi32.lib
131+
opengl32.lib
132+
user32.lib
133+
)
121134
else()
135+
set_property(TARGET ${EXE_NAME} APPEND PROPERTY COMPILE_DEFINITIONS __GMM GMM_EXCITE __UMD)
136+
137+
target_link_libraries(${EXE_NAME}
138+
igfx_gmmumd_excite
139+
)
140+
141+
# if(NOT TARGET igfx_gmmumd_dll)
142+
# add_subdirectory("${BS_DIR_GMMLIB}" "${CMAKE_BINARY_DIR}/gmmlib/ult")
143+
# endif()
144+
# target_link_libraries(${EXE_NAME} igfx_gmmumd_dll)
145+
122146
target_link_libraries(${EXE_NAME}
123-
pthread
147+
pthread
148+
dl
124149
)
125150
endif()
126151

@@ -133,5 +158,3 @@ add_custom_command(
133158
COMMAND ${EXE_NAME} --gtest_filter=CTest*
134159
)
135160

136-
137-

Source/GmmLib/ULT/GmmCachePolicyULT.cpp

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ OTHER DEALINGS IN THE SOFTWARE.
2222

2323
#include "GmmCachePolicyULT.h"
2424

25-
extern GMM_GLOBAL_CONTEXT *pGmmGlobalContext;
2625
using namespace std;
2726

2827
/////////////////////////////////////////////////////////////////////////////////////
@@ -35,6 +34,12 @@ void CTestCachePolicy::SetUpTestCase()
3534
{
3635
GfxPlatform.eProductFamily = IGFX_BROADWELL;
3736
GfxPlatform.eRenderCoreFamily = IGFX_GEN8_CORE;
37+
AllocateAdapterInfo();
38+
39+
pGfxAdapterInfo->SystemInfo.L3CacheSizeInKb = 768;
40+
pGfxAdapterInfo->SystemInfo.LLCCacheSizeInKb = 2 * 1024; //2 MB
41+
pGfxAdapterInfo->SystemInfo.EdramSizeInKb = 64 * 1024; //64 MB
42+
const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrEDram = 1;
3843

3944
CommonULT::SetUpTestCase();
4045

@@ -55,21 +60,12 @@ void CTestCachePolicy::TearDownTestCase()
5560

5661
void CTestCachePolicy::CheckL3CachePolicy()
5762
{
58-
ASSERT_TRUE(pGmmGlobalContext);
59-
6063
const uint32_t TargetCache_L3_LLC_ELLC = 0x3;
6164

62-
63-
// Setup SKU/WA flags
64-
pGmmGlobalContext->GetGtSysInfo()->L3CacheSizeInKb = 768; //768 KB
65-
66-
// Re-init cache policy based on above info
67-
pGmmGlobalContext->GetCachePolicyObj()->InitCachePolicy();
68-
6965
// Check Usage MOCS index against MOCS settings
7066
for(uint32_t Usage = GMM_RESOURCE_USAGE_UNKNOWN; Usage < GMM_RESOURCE_USAGE_MAX; Usage++)
7167
{
72-
GMM_CACHE_POLICY_ELEMENT ClientRequest = pGmmGlobalContext->GetCachePolicyElement((GMM_RESOURCE_USAGE_TYPE)Usage);
68+
GMM_CACHE_POLICY_ELEMENT ClientRequest = pGmmULTClientContext->GetCachePolicyElement((GMM_RESOURCE_USAGE_TYPE)Usage);
7369
MEMORY_OBJECT_CONTROL_STATE Mocs = ClientRequest.MemoryObjectOverride;
7470

7571
// Not check WT/WB/UC since that doesn't really matter for L3
@@ -89,8 +85,6 @@ TEST_F(CTestCachePolicy, TestL3CachePolicy)
8985

9086
void CTestCachePolicy::CheckLlcEdramCachePolicy()
9187
{
92-
ASSERT_TRUE(pGmmGlobalContext);
93-
9488
const uint32_t TargetCache_ELLC = 0;
9589
const uint32_t TargetCache_LLC = 1;
9690
const uint32_t TargetCache_LLC_ELLC = 2;
@@ -100,26 +94,17 @@ void CTestCachePolicy::CheckLlcEdramCachePolicy()
10094
const uint32_t CC_CACHED_WT = 0x2;
10195
const uint32_t CC_CACHED_WB = 0x3;
10296

103-
// Setup SKU/WA flags
104-
pGmmGlobalContext->GetGtSysInfo()->LLCCacheSizeInKb = 2 * 1024; //2 MB
105-
pGmmGlobalContext->GetGtSysInfo()->EdramSizeInKb = 64 * 1024; //64 MB
106-
const_cast<SKU_FEATURE_TABLE &>(pGmmGlobalContext->GetSkuTable()).FtrEDram = 1;
107-
108-
// Re-init cache policy with above info
109-
pGmmGlobalContext->GetCachePolicyObj()->InitCachePolicy();
110-
11197
// Check Usage MOCS index against MOCS settings
11298
for(uint32_t Usage = GMM_RESOURCE_USAGE_UNKNOWN; Usage < GMM_RESOURCE_USAGE_MAX; Usage++)
11399
{
114-
GMM_CACHE_POLICY_ELEMENT ClientRequest = pGmmGlobalContext->GetCachePolicyElement((GMM_RESOURCE_USAGE_TYPE)Usage);
100+
GMM_CACHE_POLICY_ELEMENT ClientRequest = pGmmULTClientContext->GetCachePolicyElement((GMM_RESOURCE_USAGE_TYPE)Usage);
115101
MEMORY_OBJECT_CONTROL_STATE Mocs = ClientRequest.MemoryObjectOverride;
116102

117103
// Check for age
118104
EXPECT_EQ(ClientRequest.AGE, Mocs.Gen8.Age) << "Usage# " << Usage << ": Incorrect AGE settings";
119105

120106
if(ClientRequest.L3)
121107
{
122-
// Already tested in another test
123108
continue;
124109
}
125110

0 commit comments

Comments
 (0)