Skip to content

Commit 3d7c1a8

Browse files
committed
Fix: SetMaxCPU to alter cpuFlags per-env-instance value not a common singleton member. mentioned in #440
- env->GetCPUFlags works per environment, not per loaded DLL's flags - make SetMaxCPU set distinct flag per ScriptEnvironment
1 parent cf3c8c5 commit 3d7c1a8

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

avs_core/core/avisynth.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,8 @@ class ScriptEnvironment {
10731073

10741074
CacheMode cacheMode;
10751075

1076+
int cpuFlags;
1077+
10761078
void InitMT();
10771079
};
10781080

@@ -2438,10 +2440,12 @@ ScriptEnvironment::ScriptEnvironment()
24382440
cacheMode(CACHE_DEFAULT)
24392441
{
24402442
#ifdef XP_TLS
2441-
if(dwTlsIndex == 0)
2442-
throw("ScriptEnvironment: TlsAlloc failed on DLL load");
2443+
if(dwTlsIndex == 0)
2444+
throw("ScriptEnvironment: TlsAlloc failed on DLL load");
24432445
#endif
24442446

2447+
cpuFlags = ::GetCPUFlags();
2448+
24452449
try {
24462450
#ifdef AVS_WINDOWS
24472451
// Make sure COM is initialised
@@ -2952,7 +2956,7 @@ void ScriptEnvironment::SetMaxCPU(const char* features)
29522956
}
29532957
}
29542958

2955-
::SetMaxCPU(cpu_flags);
2959+
cpuFlags = cpu_flags;
29562960
}
29572961

29582962
ClipDataStore* ScriptEnvironment::ClipData(IClip *clip)
@@ -3199,7 +3203,7 @@ void ScriptEnvironment::CheckVersion(int version) {
31993203
ThrowError("Plugin was designed for a later version of Avisynth (%d)", version);
32003204
}
32013205

3202-
int ScriptEnvironment::GetCPUFlags() { return ::GetCPUFlags(); }
3206+
int ScriptEnvironment::GetCPUFlags() { return cpuFlags; }
32033207

32043208
void ScriptEnvironment::AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data) {
32053209
this->AddFunction(name, params, apply, user_data, NULL);

avs_core/core/cpuid.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,3 @@ int GetCPUFlags() {
185185
return _CPUFlags::getInstance().GetCPUFlags();
186186
}
187187

188-
void SetMaxCPU(int new_flags) {
189-
_CPUFlags::getInstance().SetCPUFlags(new_flags);
190-
}

avs_core/include/avs/cpuid.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ enum {
7575

7676
#ifdef BUILDING_AVSCORE
7777
int GetCPUFlags();
78-
void SetMaxCPU(int new_flags);
7978
#endif
8079

8180
#endif // AVSCORE_CPUID_H

0 commit comments

Comments
 (0)