Repository navigation
fix(gfx/nvn): 贴图池表在途写时拷贝与同提交未写目标刷新,防采样读到哑图闪烁(#674) - #2047
Merged
Merged
Conversation
Owner
Owner
|
@judeyang 审过了,可以合,已送进合入列车。
|
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.
根因
在
0400486024DEC000(#674)中,通过贴图池表(pool_gpu)无绑定采样的渲染遍存在两处竞态导致偶发读到哑图(画面明暗闪烁):pool_ent_put()直接改写共享MTLBuffer(t->buf)里的表项;当上一提交或同提交早先编码的绘制仍在 GPU 在途读取t->buf时,CPU 将某 ID 改写成哑图或新贴图会直接撕裂在途绘制看到的句柄表;pool_tex_obj()在渲染目标尚未写入时返回哑图(pool_unwritten_target),而pool_seen_scan()原先每提交只扫一次(g_seen_sub == g_sub_serial即跳过),导致同一提交内前面遍写入该目标后,后面遍采样池表时该项仍滞留为哑图。修复
在
graphics/nvn/gfx/nvn/nvn_mtl.m中:pool_tab.bound_fence+pool_ent_put()写时拷贝(COW):pool_gpu()返回缓冲时记下bound_fence = g_fence + 1;若pool_ent_put()要覆写已有非空项且t->bound_fence > pin_done()(GPU 仍在途),先分配新共享缓冲并拷贝现表、旧缓冲走defer_obj_release()、推进g_psnap_gen,保证在途绘制读到完整快照;g_punwritten+pool_unwritten_scan():pool_tex_obj()以*left = 2区分“未写目标跳过”与预算跳过(*left = 1),一旦g_ser_gen推进(渲染遍建图/写入),下一次pool_gpu()立即回填真实贴图句柄;pool_seen_scan()同提交响应变更:g_ser_gen或nvn_dirty_now()变化时允许在同提交内复查已读位图,不再等到下一提交。验证
在
graphics/nvn/tests/t_nvn_pool_tex.m新增单测 ⑯a / ⑯b:pool_gpu()立刻换回真贴图;make native-test-nvn_pool_tex:28/28 PASS(含 ⑯a / ⑯b,Metal 4)。0400486024DEC000连续运行 11,576 帧未再复现水面/山崖明暗闪烁。