Make post_process_write() take a mutable reference, fixing ordering footgun - #25258
Make post_process_write() take a mutable reference, fixing ordering footgun#25258coreh wants to merge 4 commits into
post_process_write() take a mutable reference, fixing ordering footgun#25258Conversation
|
Does this kill parallelism? |
| let (dlss, dlss_context, resolution_override, temporal_jitter, view_target, prepass_textures) = | ||
| view.into_inner(); | ||
| let ( | ||
| dlss, | ||
| dlss_context, | ||
| resolution_override, | ||
| temporal_jitter, | ||
| mut view_target, | ||
| prepass_textures, | ||
| ) = view.into_inner(); |
There was a problem hiding this comment.
Mechanical edit, haven't been able to verify this yet since I don't have an NVidia card easily avaibale for testing
I'm not entirely sure. I think most of the things this affects were already “supposed” to run sequentially to produce correct results anyway, or were coincidentally/transitively made sequential, so if they were underspecified, the performance/parallelism gain was already due to a bug. The various shadow pass systems all take What is the ideal way to benchmark/visualize this? |
|
Not sure what scene I would suggest (maybe beyv_city? something complex enough to have significant command encoding costs), but use trace_tracy to view parallelism. Also, great to see you contributing again! |
|
Disagree with the solution. It's odd to make methods that don't need mutable reference become mutable, as it may lead to unnecessary restrictions, e.g. order independent post processes should be able to run in parallel. |
|
Hmm... I agree the My hunch is that two systems having concurrent write ability to this is pretty much always unsound Edit: oops, accidentally the wrong button |
While experimenting with a custom lens flare post-processing effect, I hit erratic behavior related to system order, that turned out to be a previously reported interior mutability footgun (#24839):
post_process_write()doesn't require a mutable ref, so it allows multiple systems to concurrently hold write access to the same view target, unless you carefully specify ordering.Previously this wasn't really an issue because of the render graph, but #22144 made it easy to hit by accident if you forget to add the relevant
.before()/.after(). (And you get no ambiguity warnings because the systems don't share mutable access)Objective
Fixes #24839. An alternative approach to #24961 (but we probably still want to make the system order explicit in the example)
Solution
post_process_write()mutablemsaa_writebackand various shadow passes toPrepassAntiAliasingSystemsset, as proposed here by @IceSentry, flagged systems in the set as ambiguous with each otherTesting
mainto avoid regressions, and verified the HDR post processing issue is no more.