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:
@@ -81,23 +81,17 @@ public:
|
||||
|
||||
void render_and_present(std::uint32_t frame) override
|
||||
{
|
||||
// Animated background: each channel sweeps at a different rate -> constant motion.
|
||||
const float bg[4] = {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};
|
||||
const FramePattern p = frame_pattern(frame, width_);
|
||||
|
||||
const float bg[4] = {p.bg_r / 255.0f, p.bg_g / 255.0f, p.bg_b / 255.0f, 1.0f};
|
||||
ctx_->ClearRenderTargetView(rtv_.Get(), bg);
|
||||
|
||||
// Moving vertical bar (obvious motion; a dropped frame makes it jump).
|
||||
const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
const LONG span = width_ > 24 ? static_cast<LONG>(width_ - 24) : 1;
|
||||
const LONG bx = static_cast<LONG>((frame * 4) % static_cast<std::uint32_t>(span));
|
||||
const D3D11_RECT bar = {bx, 0, bx + 24, static_cast<LONG>(height_)};
|
||||
const LONG bx = static_cast<LONG>(p.bar_x);
|
||||
const D3D11_RECT bar = {bx, 0, bx + static_cast<LONG>(kBarWidth), static_cast<LONG>(height_)};
|
||||
ctx_->ClearView(rtv_.Get(), white, &bar, 1);
|
||||
|
||||
// Frame-counter block (top-left): RGB encodes the exact frame number for the test.
|
||||
std::uint8_t r = 0, g = 0, b = 0;
|
||||
frame_to_rgb(frame, r, g, b);
|
||||
const float code[4] = {r / 255.0f, g / 255.0f, b / 255.0f, 1.0f};
|
||||
const float code[4] = {p.code_r / 255.0f, p.code_g / 255.0f, p.code_b / 255.0f, 1.0f};
|
||||
const D3D11_RECT block = {0, 0, static_cast<LONG>(kFrameBlock), static_cast<LONG>(kFrameBlock)};
|
||||
ctx_->ClearView(rtv_.Get(), code, &block, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user