Created
May 9, 2018 13:20
-
-
Save deathponta/163ee4dec041dbb9085b421670b5ac50 to your computer and use it in GitHub Desktop.
UE4 の シェーダーコンパイル時に0コアを使用しないようにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 現在実行されているプロセスのCPUの関係設定を行います。 | |
# プロセス名を入力すると、そのプロセスは0コアを使用しなくなります。 | |
# 関係設定を変更したいプロセス名を入力 | |
$pName = "ShaderCompileWorker"; | |
# PCの論理コア数 | |
$coreCnt = (Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors; | |
#---------------------------------------- | |
# CPUコア数により、ビットマスクの値を変更 | |
$bitMask = 254; # デフォでは8コアに対応 | |
# ビットマスクで使用するCPUにチェックを入れるイメージ | |
# 11111110 = 254 | |
# CPU0[] CPU1[x] CPU2[x] CPU3[x] CPU4[x] CPU5[x] CPU6[x] CPU7[x] | |
switch( $coreCnt ){ | |
2{$bitMask = 2} | |
4{$bitMask = 14} | |
8{$bitMask = 254} | |
16{$bitMask = 65534} | |
default{ echo "このCPU はサポートしていません"} | |
} | |
#---------------------------------------- | |
#---------------------------------------- | |
# プロセスの取得~関係設定変更まで | |
try{ | |
# プロセス取得 | |
$processs = get-process $pName; | |
# 配列の場合のみForEach処理を。それ以外外はプロパティに直接アクセス。 | |
if( $processs -is [Object[]] ){ | |
$processs|ForEach-Object -Process{$_.ProcessorAffinity=$bitMask}; | |
}else{ | |
$processs.ProcessorAffinity=$bitMask; | |
} | |
}catch{ | |
echo ($pName + " プロセスが起動してないお"); | |
} | |
#---------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment