Repository navigation
Conversation
A target dump (XCL_DUMP_TARGETS) writes a picture of each target and counts the texels that are not zero. The pictures clamp: one that reads white may hold 1.5 or 40 000, and a NaN that a later pass spreads over the frame shows in no picture. For each float target read back the dump now also logs how many texels hold a NaN or an infinity, the least and the largest finite channel, each channel's mean over its finite values and the first four texels. A target of 4096 texels or fewer (a 1x1 exposure target, the small end of a bloom chain) is read whole, a larger one as the existing count samples it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
| } | ||
| } | ||
| for (i, m) in out.mean.iter_mut().enumerate() { | ||
| *m = sum[i] / finite[i].max(1) as f64; |
There was a problem hiding this comment.
When one channel has no finite samples but another does, finite[i].max(1) reports the empty channel's mean as 0.0, and the log presents it as a measured value. For example, an R32G32_FLOAT texel (1.0, NaN) is reported with means [1.0, 0.0], even though the second channel has no finite samples. Could we preserve per-channel sample counts and print n/a for empty channels, with a mixed finite/non-finite-channel test? AI-assisted review: I used an AI assistant to inspect this code and checked the finding against the implementation and existing tests.
There was a problem hiding this comment.
@gut0to thank you, that is right: a channel with no finite value was divided by 1 and logged with a mean of 0, which reads as a measurement.
Fixed in 7a19282e6: Floats::mean is Vec<Option<f64>>, a channel without a finite value has none, and the line prints n/a for it. Your case is the new test, a_channel_with_no_finite_value_has_no_mean: two R32G32_FLOAT texels (1, NaN) and (3, +inf) give mean [2.0000e0, n/a], a range of 1 to 3, one texel with a NaN and one with an infinity.
I kept one count per channel inside the function and did not add the counts to the line: n/a says what the count would, and the line is long already. Say if you would rather see them.
cargo test -p xcl --lib -- --test-threads=1 d3d12x::targets::tests: 15 passed. The description has the new head's regression run.
🤖 Generated with Claude Code
… the dump's line The census divided a channel's sum by its count of finite values or by 1, so a channel that had none was logged with a mean of 0. Such a channel has no mean now and the line says n/a for it (review of xcl-dev#3572). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Review (head 7a19282, diff read, not a merge-check):
Fine: only runs with AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
A target dump (
XCL_DUMP_TARGETS) now says what each float target it reads back holds: how many texels have a NaN or an infinity, the range and the mean of the finite ones, and the first texels. The pictures clamp, so a white one may hold 1.5 or 40,000. Nothing changes unless a target dump is asked for.What is in it
A target dump writes a picture of each target and counts the texels that are not zero. For a picture that is black or white that is not enough to tell a NaN from a level that is merely too high or too low, and the passes that matter most for that (exposure, bloom) end in targets of a few texels.
targets.rs,float_census: for R32G32B32A32_FLOAT, R16G16B16A16_FLOAT, R32G32_FLOAT, R16G16_FLOAT, R32_FLOAT, R16_FLOAT and R11G11B10_FLOAT targets, the texels with a NaN in a channel, those with an infinity, the least and the largest finite channel, each channel's mean over its finite values (n/afor a channel that has none) and the first four texels as they are. A target of 4096 texels or fewer is read whole (a 1x1 or 7x4 target is the point); a larger one every 4th texel of every 4th row, as the existing count samples.half,small_float,float_texel: the decoders (16-bit floats; the 11- and 10-bit unsigned floats of R11G11B10).log_censuslogs the line after the existing one, for a float target only:Size: 1 file, 91 lines of code and 65 of tests (comments and blank lines not counted), in two commits: the second is the review's finding (a channel with no finite value was given a mean of 0).
Tested
cargo test -p xcl --lib -- --test-threads=1 d3d12x::targets::tests: 15 passed, 0 failed, noSKIPPEDline. New:half_and_packed_floats_decode,a_float_targets_census_counts_nan_and_infinity_and_keeps_the_finite_range,a_channel_with_no_finite_value_has_no_mean,a_large_float_target_is_sampled_as_the_dumps_are.afeb3e551) with an earlier form of this change (the same counts, another wording of the line, a mean of 0 where a channel had no finite value) and D3D12.X: XCL_DUMP_WAIT_MS sets how long a dumped frame's present waits for the dump's copies #3571's, not this head.Regression run
scripts/smoke.ps1, 60 s,XCL_PREPARE=0, each built in release from a clean worktree, the crate's outputs cleaned first. No target dump is asked for in these runs.main(b2b1f109d):This PR (
7a19282e6), its second run (the first run of a new binary fills its caches and is not kept, as formain):Not tested
cargo test -p xcl --libas a whole: on this PC plainmainends the test process partway (reported on D3D12.X: the depth plane of an R24G8 buffer has a twin, drawn into the plane before its DSV is bound #3089); CI has the whole suite.AI use
Claude Code with Claude Fable 5.2 wrote the code and the tests, ran the tests and the regression runs, and wrote this description.
🤖 Generated with Claude Code