@@ -111,30 +111,24 @@ struct ExtFuncsPerContextT {
111
111
};
112
112
113
113
namespace detail {
114
- #define _EXT_FUNCTION_INTEL (t_pfx ) \
115
- template <> \
116
- std::pair<t_pfx##INTEL_fn &, bool &> get<t_pfx##Name, t_pfx##INTEL_fn>( \
117
- ExtFuncsPerContextT & Funcs) { \
118
- using FPtrT = t_pfx##INTEL_fn; \
119
- std::pair<FPtrT &, bool &> Ret{Funcs.t_pfx ##Func, \
120
- Funcs.t_pfx ##Initialized}; \
121
- return Ret; \
122
- }
123
114
124
- #define _EXT_FUNCTION (t_pfx ) \
115
+ #define _EXT_FUNCTION_COMMON (t_pfx, t_pfx_suff ) \
125
116
template <> \
126
- std::pair<t_pfx ##_fn &, bool &> get<t_pfx##Name, t_pfx ##_fn>( \
117
+ std::pair<t_pfx_suff ##_fn &, bool &> get<t_pfx##Name, t_pfx_suff ##_fn>( \
127
118
ExtFuncsPerContextT & Funcs) { \
128
- using FPtrT = t_pfx ##_fn; \
119
+ using FPtrT = t_pfx_suff ##_fn; \
129
120
std::pair<FPtrT &, bool &> Ret{Funcs.t_pfx ##Func, \
130
121
Funcs.t_pfx ##Initialized}; \
131
122
return Ret; \
132
123
}
124
+ #define _EXT_FUNCTION_INTEL (t_pfx ) _EXT_FUNCTION_COMMON(t_pfx, t_pfx##INTEL)
125
+ #define _EXT_FUNCTION (t_pfx ) _EXT_FUNCTION_COMMON(t_pfx, t_pfx)
133
126
134
127
#include " ext_functions.inc"
135
128
136
129
#undef _EXT_FUNCTION
137
130
#undef _EXT_FUNCTION_INTEL
131
+ #undef _EXT_FUNCTION_COMMON
138
132
} // namespace detail
139
133
140
134
struct ExtFuncsCachesT {
@@ -196,15 +190,16 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) {
196
190
T FuncPtr =
197
191
(T)clGetExtensionFunctionAddressForPlatform (curPlatform, FuncName);
198
192
193
+ // We're about to store the cached value. Mark this cache entry initialized.
194
+ FuncInitialized.second = true ;
195
+
199
196
if (!FuncPtr) {
200
197
// Cache that the extension is not available
201
198
FuncInitialized.first = nullptr ;
202
- FuncInitialized.second = true ;
203
199
return PI_INVALID_VALUE;
204
200
}
205
201
206
202
FuncInitialized.first = FuncPtr;
207
- FuncInitialized.second = true ;
208
203
*fptr = FuncPtr;
209
204
210
205
return cast<pi_result>(ret_err);
0 commit comments