diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md deleted file mode 100644 index 0c7fb80..0000000 --- a/.github/CHANGELOG.md +++ /dev/null @@ -1,35 +0,0 @@ -# v1.0.1 - 墨拡散 for YMM4 - -墨拡散エフェクトプラグインの改善リリースです。 -浸透計算のメモリアクセスを削減し、にじみの形と描画結果を一切変えずに、構造の再計算とフレームの描画を高速化しました。 -出力は前バージョンと全画素で一致します。 - ---- - -## 改善 - -### 1. 到達範囲外セルの読み書きの省略 - -浸透格子のうち、到達距離の外側にあり、かつ墨だまりを持たないセルの毎ステップの読み書きを省略しました。このセルは前バージョンでも、分布関数、水の密度、顔料、速度のすべてが常に0のまま、毎ステップ読み書きされていました。 - -- 初期化の段階で交互読み書きの両面のバッファーをゼロ化し、以後は供給・流走・顔料の各シェーダーが対象セルを早期リターンで読み飛ばします。 -- 供給シェーダーの9方向の分布関数の読み取りと、流走シェーダーの9方向の書き込みが、対象セルで毎ステップ不要になります。 -- 到達範囲外の阻害係数は毎ステップの書き込みから初期化時の1回の書き込みへ移しました。値は変わりません。 -- 到達範囲外でも墨だまりを持つセルは、供給と隣接セルへの流出が起きるため、前バージョンの経路をそのまま維持します。 - -対象セルの全状態が恒等的に0であることは初期化とゼロの伝播から厳密に成り立つため、読み飛ばしても結果は変わりません。 - -### 2. 性能 - -1280×720の素材、到達距離160画素での実測値です(Releaseビルド、3回測定の範囲)。にじみの形と描画画素数はすべての条件で前バージョンと一致します。 - -| 項目 | v1.0.0 | v1.0.1 | -|---|---:|---:| -| 標準のフル再計算 | 36〜46ms | 26〜33ms | -| 高品質のフル再計算 | 89〜91ms | 56〜59ms | -| 最高品質のフル再計算 | 155〜168ms | 91〜107ms | -| キャッシュ後のフレーム | 4.2〜5.6ms | 3.4〜4.7ms | - -### 3. 等価性の検証 - -検証ハーネスの`--golden`引数で、品質2種、シード、部分拡散、平滑、枝分かれ、高粘度、短距離の8条件の出力全画素のSHA-256を変更の前後で比較し、すべて一致することを確認しました。あわせてxUnitのテスト45件の全件成功と、ビルドの警告0を確認しています。 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f0490f..64cfba4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,31 +14,20 @@ jobs: steps: - name: ソースコードのチェックアウト - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: submodules: recursive + fetch-depth: 0 - - name: .NET SDKのセットアップ - uses: actions/setup-dotnet@v4 + - name: .NET SDK のセットアップ + uses: actions/setup-dotnet@v6 with: dotnet-version: '10.0.x' - - name: fxc.exeの検索 - id: fxc - shell: pwsh - run: | - $fxc = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin" -Recurse -Filter "fxc.exe" | - Where-Object { $_.FullName -like "*x64*" } | - Sort-Object FullName -Descending | - Select-Object -First 1 - if (-not $fxc) { - Write-Error "fxc.exeが見つかりませんでした。" - exit 1 - } - Write-Host "fxc.exeの場所: $($fxc.FullName)" - echo "FXC_PATH=$($fxc.FullName)" >> $env:GITHUB_OUTPUT + - name: MSBuild のセットアップ + uses: microsoft/setup-msbuild@v3 - - name: YMM4最新リリースの取得と解凍 + - name: YMM4 最新リリースの取得と解凍 id: ymm4 shell: pwsh run: | @@ -48,20 +37,12 @@ jobs: if (-not $asset) { $asset = $release.assets | Where-Object { $_.name -like "*.zip" } | Select-Object -First 1 } - if (-not $asset) { - Write-Error "YMM4のリリースにZIPファイルが見つかりませんでした。" - exit 1 - } Write-Host "ダウンロード対象: $($asset.name)" Invoke-WebRequest -Uri $asset.browser_download_url -OutFile "ymm4.zip" Expand-Archive -Path "ymm4.zip" -DestinationPath "ymm4_extracted" -Force $ymm4Dir = (Get-ChildItem -Path "ymm4_extracted" -Recurse -Filter "YukkuriMovieMaker.dll" | Select-Object -First 1).DirectoryName - if (-not $ymm4Dir) { - Write-Error "YukkuriMovieMaker.dllが見つかりませんでした。" - exit 1 - } - Write-Host "YMM4 DLLディレクトリ: $ymm4Dir" + Write-Host "YMM4 DLL ディレクトリ: $ymm4Dir" echo "YMM4_DIR=$ymm4Dir\" >> $env:GITHUB_OUTPUT - name: タグ名からバージョンを取得 @@ -70,17 +51,47 @@ jobs: run: | $tag = "${{ github.ref_name }}" echo "TAG=$tag" >> $env:GITHUB_OUTPUT + echo "VERSION=$($tag.TrimStart('v'))" >> $env:GITHUB_OUTPUT - - name: resxファイルの生成 + - name: バージョン記載の照合 shell: pwsh run: | - $proj = "InkDispersion/InkDispersion.csproj" - dotnet build "$proj" ` - -c Release ` - -p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" ` - -p:FxcPath="${{ steps.fxc.outputs.FXC_PATH }}" ` - -p:Platform=x64 ` - -p:SkipPluginDeploy=true + $tag = "${{ steps.version.outputs.TAG }}" + $version = "${{ steps.version.outputs.VERSION }}" + $problems = @() + + $csprojPath = "InkDispersion/InkDispersion.csproj" + $csproj = Get-Content $csprojPath -Raw + if (-not $csproj.Contains("$version")) { + $current = if ($csproj -match '([^<]*)') { $Matches[1] } else { "記載なし" } + $problems += "$csprojPath の が $current です。$version にしてください。" + } + + $readmePath = ".github/Plugin_Readme.txt" + $readme = Get-Content $readmePath -Raw + if (-not $readme.Contains(" 墨拡散 for YMM4 $tag")) { + $current = if ($readme -match '(?m)^ 墨拡散 for YMM4 (\S+)') { $Matches[1] } else { "記載なし" } + $problems += "$readmePath の見出しが $current です。$tag にしてください。" + } + + if ($problems.Count -eq 0) { + Write-Host "バージョン記載は $tag と一致しています" + exit 0 + } + + foreach ($problem in $problems) { + Write-Host "::error::$problem" + } + Write-Host "::error::リリースの対象は $tag が指すコミットです。タグを付けた後で main へ訂正を積んでも、その訂正はリリースに入りません。タグを削除し、記載を直したコミットを積んでから付け直してください。" + exit 1 + + - name: シェーダーのビルド + shell: pwsh + run: | + msbuild InkDispersion.Shader/InkDispersion.Shader.vcxproj ` + /p:Configuration=Release ` + /p:Platform=Win32 ` + /nologo - name: プロジェクトのビルド shell: pwsh @@ -89,7 +100,6 @@ jobs: dotnet build "$proj" ` -c Release ` -p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" ` - -p:FxcPath="${{ steps.fxc.outputs.FXC_PATH }}" ` -p:Platform=x64 ` -p:SkipPluginDeploy=true @@ -99,7 +109,6 @@ jobs: dotnet build InkDispersion.Tests/InkDispersion.Tests.csproj ` -c Release ` -p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" ` - -p:FxcPath="${{ steps.fxc.outputs.FXC_PATH }}" ` -p:Platform=x64 ` -p:SkipPluginDeploy=true ` -maxcpucount:1 @@ -118,15 +127,20 @@ jobs: id: package shell: pwsh run: | - $version = "${{ steps.version.outputs.TAG }}" - $outDir = "InkDispersion/bin/x64/Release/net10.0-windows10.0.19041.0" + $version = "${{ steps.version.outputs.TAG }}" + $outDir = "InkDispersion/bin/x64/Release/net10.0-windows10.0.19041.0" $stageRoot = "stage/InkDispersion" - $pkgName = "InkDispersion_$version.ymme" + $pkgName = "InkDispersion_$version.ymme" New-Item -ItemType Directory -Path $stageRoot -Force | Out-Null New-Item -ItemType Directory -Path "$stageRoot/LICENSE" -Force | Out-Null - Copy-Item "$outDir/plugin/InkDispersion.dll" "$stageRoot/" + $dll = "$outDir/plugin/InkDispersion.dll" + if (-not (Test-Path $dll)) { + Write-Error "ビルド結果に InkDispersion.dll が見つかりませんでした: $dll" + exit 1 + } + Copy-Item $dll "$stageRoot/" foreach ($lang in @("ar-sa", "en-us", "es-es", "id-id", "ko-kr", "zh-cn", "zh-tw")) { $src = "$outDir/$lang" @@ -136,17 +150,230 @@ jobs: } } - Copy-Item ".github/LICENSE/*.txt" "$stageRoot/LICENSE/" + Copy-Item ".github/LICENSE/*.txt" "$stageRoot/LICENSE/" Copy-Item ".github/Plugin_Readme.txt" "$stageRoot/Readme.txt" + $readme = Get-Content "$stageRoot/Readme.txt" -Raw + if (-not $readme.Contains(" 墨拡散 for YMM4 $version")) { + Write-Error "同梱する Readme.txt の見出しが $version と一致しません" + exit 1 + } + Compress-Archive -Path "stage/*" -DestinationPath $pkgName -CompressionLevel Optimal echo "PKG_NAME=$pkgName" >> $env:GITHUB_OUTPUT - - name: GitHubリリースの作成 - uses: softprops/action-gh-release@v2 + - name: 変更履歴の作成 + id: changelog + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.version.outputs.TAG }} + REPOSITORY: ${{ github.repository }} + SERVER_URL: ${{ github.server_url }} + PACKAGE: ${{ steps.package.outputs.PKG_NAME }} + run: | + $tag = $env:TAG + $repository = $env:REPOSITORY + $server = $env:SERVER_URL + $code = [char]0x60 + $fence = [string]::new($code, 3) + $unit = [char]0x1f + + $previous = "" + $candidates = @(git tag --list "v*" --merged $tag --sort=-creatordate | Where-Object { $_ -ne $tag }) + if ($candidates.Count -gt 0) { + $previous = $candidates[0] + } + Write-Host "直前のタグ: $previous" + + $range = if ($previous) { "$previous..$tag" } else { $tag } + $log = @(git log "--format=%H%x1f%s%x1f%an%x1f%ad" --date=short $range) + + $commits = @() + foreach ($line in $log) { + if (-not $line) { continue } + $fields = $line -split $unit + if ($fields.Count -lt 4) { continue } + $commits += [pscustomobject]@{ + Sha = $fields[0] + Subject = $fields[1] + Name = $fields[2] + Date = $fields[3] + Login = "" + Avatar = "" + } + } + Write-Host "コミット数: $($commits.Count)" + + $pending = [System.Collections.Generic.HashSet[string]]::new() + foreach ($commit in $commits) { + [void]$pending.Add($commit.Sha) + } + + $accounts = @{} + $page = 1 + while ($pending.Count -gt 0 -and $page -le 20) { + $rows = @() + try { + $rows = @(gh api "repos/$repository/commits?sha=$tag&per_page=100&page=$page" --jq '.[] | [.sha, (.author.login // ""), (.author.avatar_url // "")] | @tsv') + } + catch { + Write-Host "コミットの作者を取得できませんでした: $($_.Exception.Message)" + break + } + if ($LASTEXITCODE -ne 0 -or $rows.Count -eq 0) { break } + + foreach ($row in $rows) { + $fields = $row -split "`t" + if ($fields.Count -lt 3) { continue } + if ($pending.Remove($fields[0])) { + $accounts[$fields[0]] = @{ Login = $fields[1]; Avatar = $fields[2] } + } + } + + if ($rows.Count -lt 100) { break } + $page++ + } + + foreach ($commit in $commits) { + if ($accounts.ContainsKey($commit.Sha)) { + $commit.Login = $accounts[$commit.Sha].Login + $commit.Avatar = $accounts[$commit.Sha].Avatar + } + } + + $emptyTree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904" + $base = if ($previous) { $previous } else { $emptyTree } + $shortstat = (@(git diff --shortstat $base $tag) -join " ") + $changedFiles = 0 + $insertions = 0 + $deletions = 0 + if ($shortstat -match "(\d+) file") { $changedFiles = [int]$Matches[1] } + if ($shortstat -match "(\d+) insertion") { $insertions = [int]$Matches[1] } + if ($shortstat -match "(\d+) deletion") { $deletions = [int]$Matches[1] } + $diffStat = @(git diff --stat $base $tag) + $tagDate = (git log -1 "--format=%ad" --date=short $tag) + + $contributors = @($commits | + Group-Object -Property { if ($_.Login) { $_.Login } else { $_.Name } } | + Sort-Object -Property Count -Descending) + + function Get-Icon($avatar, $login, $size) { + if (-not $avatar) { return "" } + $sized = if ($avatar.Contains("?")) { "$avatar&s=$($size * 2)" } else { "$avatar" + "?s=$($size * 2)" } + return " " + } + + $package = Get-Item $env:PACKAGE + $size = [math]::Round($package.Length / 1MB, 2) + + $body = [System.Collections.Generic.List[string]]::new() + $body.Add("## 概要") + $body.Add("") + $body.Add("| 項目 | 内容 |") + $body.Add("|---|---|") + $body.Add("| タグ | [$tag]($server/$repository/tree/$tag) |") + $body.Add("| 公開日 | $tagDate |") + if ($previous) { + $body.Add("| 直前のリリース | [$previous]($server/$repository/releases/tag/$previous) |") + } + $body.Add("| コミット数 | $($commits.Count) |") + $body.Add("| 貢献者 | $($contributors.Count) 名 |") + $body.Add("| 変更されたファイル | $changedFiles |") + $body.Add("| 追加された行 | $insertions |") + $body.Add("| 削除された行 | $deletions |") + + $body.Add("") + $body.Add("## ダウンロード") + $body.Add("") + $body.Add("| ファイル | サイズ |") + $body.Add("|---|---|") + $body.Add("| $($package.Name) | $size MB |") + + $body.Add("") + $body.Add("## 貢献者") + $body.Add("") + $body.Add("| 貢献者 | コミット数 |") + $body.Add("|---|---|") + foreach ($contributor in $contributors) { + $first = $contributor.Group[0] + if ($first.Login) { + $name = (Get-Icon $first.Avatar $first.Login 40) + "[@$($first.Login)]($server/$($first.Login))" + } + else { + $name = $first.Name + } + $body.Add("| $name | $($contributor.Count) |") + } + + $body.Add("") + $body.Add("## 変更履歴") + $body.Add("") + $body.Add("| コミット | 内容 | 貢献者 | 日付 |") + $body.Add("|---|---|---|---|") + $maximumCommits = 300 + $listed = 0 + foreach ($commit in $commits) { + if ($listed -ge $maximumCommits) { break } + $short = $commit.Sha.Substring(0, 7) + $subject = $commit.Subject -replace '\|', '\|' + if ($commit.Login) { + $author = (Get-Icon $commit.Avatar $commit.Login 20) + "[@$($commit.Login)]($server/$($commit.Login))" + } + else { + $author = $commit.Name + } + $body.Add("| [$code$short$code]($server/$repository/commit/$($commit.Sha)) | $subject | $author | $($commit.Date) |") + $listed++ + } + if ($commits.Count -gt $maximumCommits) { + $body.Add("") + $body.Add("残り $($commits.Count - $maximumCommits) 件のコミットは省略しました。") + } + + if ($diffStat.Count -gt 0) { + $body.Add("") + $body.Add("## 変更されたファイル") + $body.Add("") + $body.Add("
") + $body.Add("差分の統計") + $body.Add("") + $body.Add($fence) + $maximumStatLines = 200 + $shown = 0 + foreach ($line in $diffStat) { + if ($shown -ge $maximumStatLines) { break } + $body.Add($line) + $shown++ + } + if ($diffStat.Count -gt $maximumStatLines) { + $body.Add("... 残り $($diffStat.Count - $maximumStatLines) 行は省略しました。") + } + $body.Add($fence) + $body.Add("") + $body.Add("
") + } + + if ($previous) { + $body.Add("") + $body.Add("## 全ての変更") + $body.Add("") + $body.Add("$server/$repository/compare/$previous...$tag") + } + + $path = "release-body.md" + Set-Content -Path $path -Value ($body -join "`n") -Encoding utf8NoBOM + if (-not (Test-Path $path)) { + throw "変更履歴を作成できませんでした。" + } + Write-Host "変更履歴の行数: $($body.Count)" + $global:LASTEXITCODE = 0 + + - name: GitHub リリースの作成 + uses: softprops/action-gh-release@v3 with: name: ${{ steps.version.outputs.TAG }} - body_path: .github/CHANGELOG.md + body_path: release-body.md files: ${{ steps.package.outputs.PKG_NAME }} draft: false prerelease: false