Give the mock-game backends one source of truth for the test pattern

The animated pattern math (background sweep, moving 24px bar, frame-
counter block) was copy-pasted across all five clear-based backends
(dx9/dx10/dx11/dx12/gl). The backends MUST render an identical image --
the capture test decodes the same frame-counter block from each -- so a
drift between copies would be a silent test hazard.

Factor it into one frame_pattern() helper (plus kBarWidth) in
render_backend.hpp; each backend now consumes the computed bg/bar_x/code
values with its own API's clear/fill. mock_game_test still decodes every
backend correctly.
This commit is contained in:
2026-07-12 09:35:45 +02:00
parent 1eee482165
commit 9a736cf477
6 changed files with 53 additions and 51 deletions

View File

@@ -69,23 +69,19 @@ public:
void render_and_present(std::uint32_t frame) override
{
const std::uint32_t bg = pack(static_cast<std::uint8_t>((frame * 2) % 256),
static_cast<std::uint8_t>((frame * 3) % 256),
static_cast<std::uint8_t>((frame * 5) % 256));
const FramePattern p = frame_pattern(frame, width_);
const std::uint32_t bg = pack(p.bg_r, p.bg_g, p.bg_b);
const std::uint32_t whitepx = pack(255, 255, 255);
std::uint8_t fr = 0, fg = 0, fb = 0;
frame_to_rgb(frame, fr, fg, fb);
const std::uint32_t code = pack(fr, fg, fb);
const std::uint32_t code = pack(p.code_r, p.code_g, p.code_b);
const std::uint32_t span = width_ > 24 ? width_ - 24 : 1;
const std::uint32_t bx = (frame * 4) % span; // moving vertical bar
const std::uint32_t bx = p.bar_x; // moving vertical bar
for (std::uint32_t y = 0; y < height_; ++y)
{
std::uint32_t* row = px_.data() + static_cast<std::size_t>(y) * width_;
for (std::uint32_t x = 0; x < width_; ++x)
{
std::uint32_t c = bg;
if (x >= bx && x < bx + 24)
if (x >= bx && x < bx + kBarWidth)
{
c = whitepx;
}