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:
@@ -115,23 +115,17 @@ public:
|
||||
|
||||
transition(targets_[idx].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||
|
||||
// Animated background (full RT clear).
|
||||
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};
|
||||
list_->ClearRenderTargetView(rtv_handles_[idx], bg, 0, nullptr);
|
||||
|
||||
// Moving vertical bar.
|
||||
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 D3D12_RECT bar = {bx, 0, bx + 24, static_cast<LONG>(height_)};
|
||||
const LONG bx = static_cast<LONG>(p.bar_x);
|
||||
const D3D12_RECT bar = {bx, 0, bx + static_cast<LONG>(kBarWidth), static_cast<LONG>(height_)};
|
||||
list_->ClearRenderTargetView(rtv_handles_[idx], white, 1, &bar);
|
||||
|
||||
// Frame-counter block (top-left).
|
||||
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 D3D12_RECT block = {0, 0, static_cast<LONG>(kFrameBlock), static_cast<LONG>(kFrameBlock)};
|
||||
list_->ClearRenderTargetView(rtv_handles_[idx], code, 1, &block);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user