HSVフィルタをアプリ層GPUシェーダへ移行(コア無改変で60fps維持)#14
Merged
Merged
Conversation
The NP2kai HSV-smooth video filter ran per emulated frame on the CPU. Under
the catch-up / No-Wait frame scheduler it was applied to every generated
frame (up to 16x), and even a single full-screen pass was ~27ms on a Ryzen 5
2600 — collapsing HSV-on frame rates to single digits on Windows and under
No-Wait on macOS.
Reimplement the filter as a GPU fragment-shader pass (blit_hsv.fs.{hlsl,metal,
glsl}), selected at draw time via ui.display_hsv. The NP2kai core video filter
is left disabled and the core source is unmodified, keeping upstream merges
clean. HSV-on now holds a solid 60fps.
Also:
- frame(): only the last emulated frame of each host tick is drawn, so the
expensive draw pass runs once per presented frame instead of once per
emulated frame (the intermediate frames are never displayed).
- FPS readout: average presented frames over a ~0.5s window instead of an
instantaneous 1/dt sample, which beat against the ~60Hz draw gate into
misleading 3-digit spikes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
NP2kai コアの HSV-smooth ビデオフィルタは CPU でエミュフレームごとに実行されていた。catch-up / No-Wait スケジューラ下では生成フレーム全て(最大16x)に適用され、単一の全画面パスでも Ryzen 5 2600 で約27ms かかるため、HSV ON 時のフレームレートが Windows で一桁、macOS の No-Wait で一桁まで落ちていた。
このフィルタを GPU フラグメントシェーダのパスとして再実装し、
ui.display_hsvで描画時に切り替える。NP2kai コアのフィルタは無効化し、コアのソースは無改変(upstream マージを楽に保つ)。HSV ON でも 60fps を完全維持できるようになった。変更点
src/platform/shaders/blit_hsv.fs.{hlsl,metal,glsl}を追加。最終フレームバッファに対し 3x3 近傍を HSV 空間で許容差(dH=30, dS=30, dV=90)平滑化(VideoFilter_HSVSmooth相当, weight type 0 を移植)。platform.os.shader_fs_hsv_sourceを3OSで公開し、main.zigで2つ目のパイプラインpipeline_hsvを切替。1/Δt(〜60Hzの描画ゲートとビートして三桁に暴れる)を約0.5秒ウィンドウの平均に変更し、信頼できる表示に。補足
usa_setup_video_filter/usa_set_video_filter)は無害なため残置。テスト
zig build -Doptimize=ReleaseFast通過zig build test通過既知の残課題(別件)
frame_scheduler.zigへのヒステリシス追加で対応可能。本PRのスコープ外。🤖 Generated with Claude Code