Fix CaptureAndReplaySurfaceTests reusing one HWND for two swapchains

TestSurface and MultiFrame configured both the capture and replay
surfaces on the same GLFW window. DXGI allows only one flip-model
swapchain per HWND, so configuring the replay surface failed and
force-lost the inner D3D12 device.

The D3D12 debug layer reports it as:
  DXGI ERROR: IDXGIFactory::CreateSwapChain: Only one flip model swap
  chain can be associate with an HWND at a time.

Fix: give each replay surface its own window via a CreateReplayWindow()
helper, matching what the replay-checking harness already does.

Bug: 465183957

Change-Id: Ib3fc05ffa3ea9f740dd3a28185cba09d75756294
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/317855
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
diff --git a/src/dawn/tests/end2end/CaptureAndReplayTests.cpp b/src/dawn/tests/end2end/CaptureAndReplayTests.cpp
index d5977d1..689d5d1 100644
--- a/src/dawn/tests/end2end/CaptureAndReplayTests.cpp
+++ b/src/dawn/tests/end2end/CaptureAndReplayTests.cpp
@@ -2781,9 +2781,22 @@
         CaptureAndReplayTests::TearDown();
 
         mWindow.reset();
+        mReplayWindow.reset();
         glfwTerminate();
     }
+
+    // Creates a window for a replay surface. DXGI only allows one flip-model swapchain per HWND at
+    // a time, so the replay surface cannot reuse the same window as the capture surface while the
+    // latter is still configured. The window is owned by the fixture so it outlives the surface.
+    GLFWwindow* CreateReplayWindow() {
+        glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+        mReplayWindow.reset(
+            glfwCreateWindow(1, 1, "CaptureAndReplaySurfaceTests replay", nullptr, nullptr));
+        return mReplayWindow.get();
+    }
+
     std::unique_ptr<GLFWwindow, GLFWindowDestroyer> mWindow;
+    std::unique_ptr<GLFWwindow, GLFWindowDestroyer> mReplayWindow;
 };
 
 TEST_P(CaptureAndReplaySurfaceTests, TestSurface) {
@@ -2821,7 +2834,8 @@
     EXPECT_EQ(surfaceInfos[0].width, 1u);
     EXPECT_EQ(surfaceInfos[0].height, 1u);
 
-    wgpu::Surface replaySurface = wgpu::glfw::CreateSurfaceForWindow(instance, mWindow.get());
+    wgpu::Surface replaySurface =
+        wgpu::glfw::CreateSurfaceForWindow(instance, CreateReplayWindow());
 
     recorder->SetSurfaces({replaySurface});
 
@@ -2872,7 +2886,8 @@
     // --- replay ---
     recorder->EndCapture();
 
-    wgpu::Surface replaySurface = wgpu::glfw::CreateSurfaceForWindow(instance, mWindow.get());
+    wgpu::Surface replaySurface =
+        wgpu::glfw::CreateSurfaceForWindow(instance, CreateReplayWindow());
 
     recorder->SetSurfaces({replaySurface});
     auto replay = recorder->CreateReplay(device);