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:
@@ -75,23 +75,18 @@ public:
|
||||
|
||||
void render_and_present(std::uint32_t frame) override
|
||||
{
|
||||
const D3DCOLOR bg = opaque(static_cast<std::uint8_t>((frame * 2) % 256),
|
||||
static_cast<std::uint8_t>((frame * 3) % 256),
|
||||
static_cast<std::uint8_t>((frame * 5) % 256));
|
||||
dev_->Clear(0, nullptr, D3DCLEAR_TARGET, bg, 1.0f, 0);
|
||||
const FramePattern p = frame_pattern(frame, width_);
|
||||
dev_->Clear(0, nullptr, D3DCLEAR_TARGET, opaque(p.bg_r, p.bg_g, p.bg_b), 1.0f, 0);
|
||||
|
||||
ComPtr<IDirect3DSurface9> back;
|
||||
if (SUCCEEDED(dev_->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, back.GetAddressOf())))
|
||||
{
|
||||
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));
|
||||
RECT bar = {bx, 0, bx + 24, static_cast<LONG>(height_)}; // moving vertical bar
|
||||
const LONG bx = static_cast<LONG>(p.bar_x);
|
||||
RECT bar = {bx, 0, bx + static_cast<LONG>(kBarWidth), static_cast<LONG>(height_)}; // moving vertical bar
|
||||
dev_->ColorFill(back.Get(), &bar, opaque(255, 255, 255));
|
||||
|
||||
std::uint8_t r = 0, g = 0, b = 0;
|
||||
frame_to_rgb(frame, r, g, b);
|
||||
RECT block = {0, 0, static_cast<LONG>(kFrameBlock), static_cast<LONG>(kFrameBlock)};
|
||||
dev_->ColorFill(back.Get(), &block, opaque(r, g, b)); // top-left frame-counter block
|
||||
dev_->ColorFill(back.Get(), &block, opaque(p.code_r, p.code_g, p.code_b)); // top-left frame block
|
||||
}
|
||||
|
||||
dev_->Present(nullptr, nullptr, nullptr, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user