Hash :
00845fd6
Author :
Date :
2025-05-06T14:13:18
WebGPU: Do not reuse windows with multiple surfaces Multiple Dawn backends do not handle re-creating a surface for a native window. Instead of working around this by caching in the display, rework our test runner to recreate the OS window and surface instead of just the surface. Release all resources in DisplayWgpu::Terminate. Otherwise they wont be deleted until the display is reinitialized or the test executable terminates. Bug: angleproject:342213844 Change-Id: Ic31264a5e646a54c988ef47ca664d8575fda94eb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6515886 Reviewed-by: Liza Burakova <liza@chromium.org> Reviewed-by: Matthew Denton <mpdenton@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
//
// Copyright 2024 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// WindowSurfaceVkWin32.cpp:
// Defines the class interface for WindowSurfaceWgpuWin32, implementing WindowSurfaceWgpu.
//
#include "libANGLE/renderer/wgpu/win32/WindowSurfaceWgpuWin32.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/wgpu/DisplayWgpu.h"
#include "libANGLE/renderer/wgpu/wgpu_utils.h"
namespace rx
{
WindowSurfaceWgpuWin32::WindowSurfaceWgpuWin32(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window)
: WindowSurfaceWgpu(surfaceState, window)
{}
angle::Result WindowSurfaceWgpuWin32::createWgpuSurface(const egl::Display *display,
wgpu::Surface *outSurface)
{
DisplayWgpu *displayWgpu = webgpu::GetImpl(display);
wgpu::Instance instance = displayWgpu->getInstance();
wgpu::SurfaceDescriptorFromWindowsHWND hwndDesc;
hwndDesc.hinstance = GetModuleHandle(nullptr);
hwndDesc.hwnd = getNativeWindow();
wgpu::SurfaceDescriptor surfaceDesc;
surfaceDesc.nextInChain = &hwndDesc;
wgpu::Surface surface = instance.CreateSurface(&surfaceDesc);
*outSurface = surface;
return angle::Result::Continue;
}
angle::Result WindowSurfaceWgpuWin32::getCurrentWindowSize(const egl::Display *display,
gl::Extents *outSize)
{
RECT rect;
if (!GetClientRect(getNativeWindow(), &rect))
{
// TODO: generate a proper error + msg
return angle::Result::Stop;
}
*outSize = gl::Extents(rect.right - rect.left, rect.bottom - rect.top, 1);
return angle::Result::Continue;
}
WindowSurfaceWgpu *CreateWgpuWindowSurface(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window)
{
return new WindowSurfaceWgpuWin32(surfaceState, window);
}
} // namespace rx