diff --git a/runtime/test/xbox_present_test.cpp b/runtime/test/xbox_present_test.cpp index c463ef35f8..a84ca11551 100644 --- a/runtime/test/xbox_present_test.cpp +++ b/runtime/test/xbox_present_test.cpp @@ -793,12 +793,33 @@ int main() { return true; }; // One PresentX of `count` planes, a fresh token for all; the swapchain frame is read back into `frame`. + // Fails for three different reasons, and "false" alone does not say which: the frame token, the call's + // HRESULT, or the read-back. Name the step, so a failing EXPECT above points at one of three places. const auto present_planes = [&](rt::d3d12::XboxPresentPlaneParameters* planes_, UINT count_, HRESULT want = S_OK) { clock.advance_us(4 * period); - if (!next_token(token)) return false; + if (!next_token(token)) { + std::printf("present_planes: no frame token left\n"); + return false; + } for (UINT i = 0; i < count_; ++i) planes_[i].Token = token; - if (xbox.PresentX(count_, planes_, nullptr) != want) return false; - return want != S_OK || grab(frame); + const HRESULT got = xbox.PresentX(count_, planes_, nullptr); + if (got != want) { + std::printf("present_planes: PresentX returned 0x%08lX, wanted 0x%08lX (count %u)\n", + static_cast(got), static_cast(want), static_cast(count_)); + return false; + } + if (want != S_OK) return true; + if (!grab(frame)) { + // The layer may skip a present (nothing shown) and still report success - that is its contract - + // and the following present shows the frame. Retry once instead of calling that a failure. + if (xbox.PresentX(count_, planes_, nullptr) == want && grab(frame)) { + std::printf("present_planes: the first present was skipped, the next one captured\n"); + return true; + } + std::printf("present_planes: read-back failed\n"); + return false; + } + return true; }; const auto parameters = [&](Source& s, const XboxViewRect* place, int filter, int color_space = 0, UINT flags = 0, const D3D12_RECT* rect = nullptr) {