Branch
Hash :
3158d638
Author :
Date :
2025-05-06T17:08:56
WebGPU: Store the WebGPU proc table in wrappers Instead of relying on the global WebGPU functions, pass the proc table to the object wrappers. Bug: angleproject:342213844 Change-Id: I79a5e819ffac5b366fed0a159a6cef116b5e82b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6514676 Reviewed-by: Liza Burakova <liza@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Matthew Denton <mpdenton@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 62 63 64 65 66 67 68 69 70 71 72 73 74
//
// 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.
//
// WindowSurfaceWgpuX11.cpp:
// Defines the class interface for WindowSurfaceWgpuX11, implementing WindowSurfaceWgpu.
//
#include "libANGLE/renderer/wgpu/linux/x11/WindowSurfaceWgpuX11.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/wgpu/DisplayWgpu.h"
#include "libANGLE/renderer/wgpu/wgpu_utils.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
namespace rx
{
WindowSurfaceWgpuX11::WindowSurfaceWgpuX11(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window)
: WindowSurfaceWgpu(surfaceState, window)
{}
angle::Result WindowSurfaceWgpuX11::createWgpuSurface(const egl::Display *display,
webgpu::SurfaceHandle *outSurface)
{
DisplayWgpu *displayWgpu = webgpu::GetImpl(display);
const DawnProcTable *wgpu = displayWgpu->getProcs();
EGLNativeWindowType window = getNativeWindow();
webgpu::InstanceHandle instance = displayWgpu->getInstance();
WGPUSurfaceSourceXlibWindow x11Desc = WGPU_SURFACE_SOURCE_XLIB_WINDOW_INIT;
x11Desc.display = reinterpret_cast<Display *>(display->getNativeDisplayId());
x11Desc.window = window;
WGPUSurfaceDescriptor surfaceDesc = WGPU_SURFACE_DESCRIPTOR_INIT;
surfaceDesc.nextInChain = &x11Desc.chain;
webgpu::SurfaceHandle surface = webgpu::SurfaceHandle::Acquire(
wgpu, wgpu->instanceCreateSurface(instance.get(), &surfaceDesc));
*outSurface = surface;
return angle::Result::Continue;
}
angle::Result WindowSurfaceWgpuX11::getCurrentWindowSize(const egl::Display *display,
gl::Extents *outSize)
{
Window root;
int x, y;
unsigned int width, height, border, depth;
if (XGetGeometry(reinterpret_cast<Display *>(display->getNativeDisplayId()), getNativeWindow(),
&root, &x, &y, &width, &height, &border, &depth) == 0)
{
ERR() << "Failed to get X11 window geometry.";
return angle::Result::Stop;
}
*outSize = gl::Extents(width, height, 1);
return angle::Result::Continue;
}
WindowSurfaceWgpu *CreateWgpuWindowSurface(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window)
{
return new WindowSurfaceWgpuX11(surfaceState, window);
}
} // namespace rx