@@ -33,101 +33,106 @@ int32_t GmmLib::GmmCachePolicyCommon::RefCount = 0;
33
33
// OverrideCachePolicy can take over a minute to compile when optimizations
34
34
// are enabled. As this is only needed during init time for non-Release builds,
35
35
// we can selectively disable optimizations for this function and improve build times
36
- #if ( _DEBUG || _RELEASE_INTERNAL )
36
+ #if (_DEBUG || _RELEASE_INTERNAL)
37
37
#pragma optimize("", off)
38
38
void GmmLib::GmmCachePolicyCommon::OverrideCachePolicy ()
39
39
{
40
40
uint32_t UsageCount = 0 ;
41
41
42
- int32_t DefaultEnable = 0 , DefaultLLC = 0 , DefaultELLC = 0 , DefaultL3 = 0 ;
43
- int32_t DefaultAge = 0 , DefaultWT = 0 , DefaultAOM = 0 , DefaultLeCC_SCC = 0 ;
44
- int32_t DefaultL3_SCC = 0 , DefaultSCF = 0 , DefaultHDCL1 = 0 , DefaultSSO = 0 ;
45
- int32_t DefaultCoS = 0 , DefaultL3Eviction = 0 ;
42
+ int32_t DefaultEnable = 0 , DefaultLLC = 0 , DefaultELLC = 0 , DefaultL3 = 0 ;
43
+ int32_t DefaultAge = 0 , DefaultWT = 0 , DefaultAOM = 0 , DefaultLeCC_SCC = 0 ;
44
+ int32_t DefaultL3_SCC = 0 , DefaultSCF = 0 , DefaultHDCL1 = 0 , DefaultSSO = 0 ;
45
+ int32_t DefaultCoS = 0 , DefaultL3Eviction = 0 ;
46
46
47
47
// Variables used in the REG_OVERRIDE macro block
48
- int32_t Enable = 0 , LLC = -1 , ELLC = -1 , L3 = -1 , Age = -1 , WT = -1 , AOM = -1 , LeCC_SCC = -1 , L3_SCC = -1 , SCF = -1 , SSO = -1 , CoS = -1 , HDCL1 = -1 , L3Eviction = -1 ;
48
+ int32_t Enable = 0 , LLC = -1 , ELLC = -1 , L3 = -1 , Age = -1 , WT = -1 , AOM = -1 , LeCC_SCC = -1 , L3_SCC = -1 , SCF = -1 , SSO = -1 , CoS = -1 , HDCL1 = -1 , L3Eviction = -1 ;
49
49
50
- #define READ_DEFAULT_OVERRIDE (CacheParam ) \
51
- { \
52
- if (REGISTRY_OVERRIDE_READ (OverrideDefaults ,CacheParam) == false ) \
53
- { \
54
- CacheParam = -1 ; \
55
- } \
56
- Default##CacheParam = CacheParam; \
50
+ #define READ_DEFAULT_OVERRIDE (CacheParam ) \
51
+ \
52
+ { \
53
+ if (REGISTRY_OVERRIDE_READ (OverrideDefaults, CacheParam) == false ) \
54
+ { \
55
+ CacheParam = -1 ; \
56
+ } \
57
+ Default##CacheParam = CacheParam; \
58
+ \
57
59
}
58
60
59
- #define OVERRIDE_DEFAULT (Usage ) \
60
- { \
61
- if (DefaultEnable) \
62
- { \
63
- if (DefaultLLC != -1 ) \
64
- { \
65
- pCachePolicy[Usage].LLC = DefaultLLC; \
66
- } \
67
- if (DefaultELLC != -1 ) \
68
- { \
69
- pCachePolicy[Usage].ELLC = DefaultELLC; \
70
- } \
71
- if (DefaultL3 != -1 ) \
72
- { \
73
- pCachePolicy[Usage].L3 = DefaultL3; \
74
- } \
75
- if (DefaultAge != -1 ) \
76
- { \
77
- pCachePolicy[Usage].AGE = DefaultAge; \
78
- } \
79
- if (DefaultWT != -1 ) \
80
- { \
81
- pCachePolicy[Usage].WT = DefaultWT; \
82
- } \
83
- if (DefaultAOM != -1 ) \
84
- { \
85
- pCachePolicy[Usage].AOM = DefaultAOM; \
86
- } \
87
- if (DefaultLeCC_SCC != -1 ) \
88
- { \
89
- pCachePolicy[Usage].LeCC_SCC = DefaultLeCC_SCC; \
90
- } \
91
- if (DefaultL3_SCC != -1 ) \
92
- { \
93
- pCachePolicy[Usage].L3_SCC = DefaultL3_SCC; \
94
- } \
95
- if (DefaultSCF != -1 ) \
96
- { \
97
- pCachePolicy[Usage].SCF = DefaultSCF; \
98
- } \
99
- if (DefaultSSO != -1 ) \
100
- { \
101
- pCachePolicy[Usage].SSO = DefaultSSO; \
102
- } \
103
- if (DefaultCoS != -1 ) \
104
- { \
105
- pCachePolicy[Usage].CoS = DefaultCoS; \
106
- } \
107
- if (DefaultHDCL1 != -1 ) \
108
- { \
109
- pCachePolicy[Usage].HDCL1 = DefaultHDCL1; \
110
- } \
111
- if (DefaultL3Eviction != -1 ) \
112
- { \
113
- pCachePolicy[Usage].L3Eviction = DefaultL3Eviction; \
114
- } \
115
- } \
61
+ #define OVERRIDE_DEFAULT (Usage ) \
62
+ \
63
+ { \
64
+ if (DefaultEnable) \
65
+ { \
66
+ if (DefaultLLC != -1 ) \
67
+ { \
68
+ pCachePolicy[Usage].LLC = DefaultLLC; \
69
+ } \
70
+ if (DefaultELLC != -1 ) \
71
+ { \
72
+ pCachePolicy[Usage].ELLC = DefaultELLC; \
73
+ } \
74
+ if (DefaultL3 != -1 ) \
75
+ { \
76
+ pCachePolicy[Usage].L3 = DefaultL3; \
77
+ } \
78
+ if (DefaultAge != -1 ) \
79
+ { \
80
+ pCachePolicy[Usage].AGE = DefaultAge; \
81
+ } \
82
+ if (DefaultWT != -1 ) \
83
+ { \
84
+ pCachePolicy[Usage].WT = DefaultWT; \
85
+ } \
86
+ if (DefaultAOM != -1 ) \
87
+ { \
88
+ pCachePolicy[Usage].AOM = DefaultAOM; \
89
+ } \
90
+ if (DefaultLeCC_SCC != -1 ) \
91
+ { \
92
+ pCachePolicy[Usage].LeCC_SCC = DefaultLeCC_SCC; \
93
+ } \
94
+ if (DefaultL3_SCC != -1 ) \
95
+ { \
96
+ pCachePolicy[Usage].L3_SCC = DefaultL3_SCC; \
97
+ } \
98
+ if (DefaultSCF != -1 ) \
99
+ { \
100
+ pCachePolicy[Usage].SCF = DefaultSCF; \
101
+ } \
102
+ if (DefaultSSO != -1 ) \
103
+ { \
104
+ pCachePolicy[Usage].SSO = DefaultSSO; \
105
+ } \
106
+ if (DefaultCoS != -1 ) \
107
+ { \
108
+ pCachePolicy[Usage].CoS = DefaultCoS; \
109
+ } \
110
+ if (DefaultHDCL1 != -1 ) \
111
+ { \
112
+ pCachePolicy[Usage].HDCL1 = DefaultHDCL1; \
113
+ } \
114
+ if (DefaultL3Eviction != -1 ) \
115
+ { \
116
+ pCachePolicy[Usage].L3Eviction = DefaultL3Eviction; \
117
+ } \
118
+ } \
119
+ \
116
120
}
117
121
118
122
#ifdef __GMM_KMD__
119
123
uint32_t GenerateKeys = 0 ;
120
124
REGISTRY_OVERRIDE_READ (, GenerateKeys);
121
125
#endif
122
- REGISTRY_OVERRIDE_READ (OverrideDefaults, Enable); DefaultEnable = Enable;
126
+ REGISTRY_OVERRIDE_READ (OverrideDefaults, Enable);
127
+ DefaultEnable = Enable;
123
128
124
129
#ifdef __GMM_KMD__
125
130
__GMM_ASSERT (!(DefaultEnable && GenerateKeys));
126
131
// Disable DefaultEnable if GenerateKeys is enabled
127
132
DefaultEnable = GenerateKeys ? 0 : DefaultEnable;
128
133
#endif
129
134
130
- if (DefaultEnable)
135
+ if (DefaultEnable)
131
136
{
132
137
READ_DEFAULT_OVERRIDE (LLC);
133
138
READ_DEFAULT_OVERRIDE (ELLC);
@@ -144,23 +149,26 @@ void GmmLib::GmmCachePolicyCommon::OverrideCachePolicy()
144
149
READ_DEFAULT_OVERRIDE (L3Eviction);
145
150
}
146
151
147
- OVERRIDE_DEFAULT (GMM_RESOURCE_USAGE_UNKNOWN); REG_OVERRIDE (GMM_RESOURCE_USAGE_UNKNOWN);
152
+ OVERRIDE_DEFAULT (GMM_RESOURCE_USAGE_UNKNOWN);
153
+ REG_OVERRIDE (GMM_RESOURCE_USAGE_UNKNOWN);
148
154
149
155
150
- #define DEFINE_RESOURCE_USAGE (Usage ) OVERRIDE_DEFAULT(Usage); REG_OVERRIDE(Usage);
151
- #include " GmmCachePolicyResourceUsageDefinitions.h"
152
- #undef DEFINE_RESOURCE_USAGE
153
- #undef OVERRIDE_DEFAULT
154
- #undef READ_DEFAULT_OVERRIDE
155
- __GMM_ASSERT (UsageCount == GMM_RESOURCE_USAGE_MAX);
156
+ #define DEFINE_RESOURCE_USAGE (Usage ) \
157
+ OVERRIDE_DEFAULT (Usage); \
158
+ REG_OVERRIDE (Usage);
159
+ #include " GmmCachePolicyResourceUsageDefinitions.h"
160
+ #undef DEFINE_RESOURCE_USAGE
161
+ #undef OVERRIDE_DEFAULT
162
+ #undef READ_DEFAULT_OVERRIDE
163
+ __GMM_ASSERT (UsageCount == GMM_RESOURCE_USAGE_MAX);
156
164
157
- #ifdef __GMM_KMD__
158
- if (GenerateKeys)
159
- {
160
- GenerateKeys = 0 ;
161
- REGISTRY_OVERRIDE_WRITE (, GenerateKeys, GenerateKeys);
162
- }
163
- #endif
165
+ #ifdef __GMM_KMD__
166
+ if (GenerateKeys)
167
+ {
168
+ GenerateKeys = 0 ;
169
+ REGISTRY_OVERRIDE_WRITE (, GenerateKeys, GenerateKeys);
170
+ }
171
+ #endif
164
172
}
165
173
#pragma optimize("", on)
166
174
#endif
@@ -186,11 +194,11 @@ GmmLib::GmmCachePolicyCommon::GmmCachePolicyCommon(GMM_CACHE_POLICY_ELEMENT *pCa
186
194
GMM_GFX_MEMORY_TYPE GmmLib::GmmCachePolicyCommon::GetWantedMemoryType (GMM_CACHE_POLICY_ELEMENT CachePolicy)
187
195
{
188
196
GMM_GFX_MEMORY_TYPE WantedMemoryType = GMM_GFX_UC_WITH_FENCE;
189
- if (CachePolicy.WT )
197
+ if (CachePolicy.WT )
190
198
{
191
199
WantedMemoryType = GMM_GFX_WT;
192
200
}
193
- else if (!(CachePolicy.LLC || CachePolicy.ELLC ))
201
+ else if (!(CachePolicy.LLC || CachePolicy.ELLC ))
194
202
{
195
203
WantedMemoryType = GMM_GFX_UC_WITH_FENCE;
196
204
}
@@ -214,7 +222,7 @@ MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmLib::GmmCachePolicyCommon::CachePolic
214
222
{
215
223
MEMORY_OBJECT_CONTROL_STATE MOCS = pGmmGlobalContext->GetCachePolicyElement (GMM_RESOURCE_USAGE_UNKNOWN).MemoryObjectOverride ;
216
224
217
- if (pResInfo)
225
+ if (pResInfo)
218
226
{
219
227
MOCS = pResInfo->GetMOCS ();
220
228
}
@@ -241,16 +249,16 @@ MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmLib::GmmCachePolicyCommon::CachePolic
241
249
242
250
// Prevent wrong Usage for XAdapter resources. UMD does not call GetMemoryObject on shader resources but,
243
251
// when they add it someone could call it without knowing the restriction.
244
- if (pResInfo &&
245
- pResInfo->GetResFlags ().Info .XAdapter &&
246
- Usage != GMM_RESOURCE_USAGE_XADAPTER_SHARED_RESOURCE)
252
+ if (pResInfo &&
253
+ pResInfo->GetResFlags ().Info .XAdapter &&
254
+ Usage != GMM_RESOURCE_USAGE_XADAPTER_SHARED_RESOURCE)
247
255
{
248
256
__GMM_ASSERT (false );
249
257
}
250
258
251
- if (!pResInfo ||
252
- (CachePolicy[Usage].Override & CachePolicy[pResInfo->GetCachePolicyUsage ()].IDCode ) ||
253
- (CachePolicy[Usage].Override == ALWAYS_OVERRIDE))
259
+ if (!pResInfo ||
260
+ (CachePolicy[Usage].Override & CachePolicy[pResInfo->GetCachePolicyUsage ()].IDCode ) ||
261
+ (CachePolicy[Usage].Override == ALWAYS_OVERRIDE))
254
262
{
255
263
return CachePolicy[Usage].MemoryObjectOverride ;
256
264
}
0 commit comments