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

@@ -63,27 +63,24 @@ public:
const GLsizei h = static_cast<GLsizei>(height_);
glViewport(0, 0, w, h);
const FramePattern p = frame_pattern(frame, width_);
// Animated background (whole framebuffer).
glDisable(GL_SCISSOR_TEST);
glClearColor(static_cast<float>((frame * 2) % 256) / 255.0f, static_cast<float>((frame * 3) % 256) / 255.0f,
static_cast<float>((frame * 5) % 256) / 255.0f, 1.0f);
glClearColor(p.bg_r / 255.0f, p.bg_g / 255.0f, p.bg_b / 255.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_SCISSOR_TEST);
// Moving vertical bar (full height).
const std::uint32_t span = width_ > 24 ? width_ - 24 : 1;
const GLint bx = static_cast<GLint>((frame * 4) % span);
glScissor(bx, 0, 24, h);
glScissor(static_cast<GLint>(p.bar_x), 0, static_cast<GLsizei>(kBarWidth), h);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Frame-counter block at the GL top-left (y = h - block) so it lands top-left after the
// capture's vertical flip.
std::uint8_t r = 0, g = 0, b = 0;
frame_to_rgb(frame, r, g, b);
glScissor(0, h - static_cast<GLint>(kFrameBlock), static_cast<GLsizei>(kFrameBlock),
static_cast<GLsizei>(kFrameBlock));
glClearColor(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
glClearColor(p.code_r / 255.0f, p.code_g / 255.0f, p.code_b / 255.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);