From 6908f1b8afdfdbbf86bcd15dbe9b083fa453e36a Mon Sep 17 00:00:00 2001 From: Syed Idris Shah Date: Mon, 14 Apr 2025 11:35:34 -0400 Subject: [PATCH] Move adapter and device creation to the begining --- filament/backend/src/webgpu/WebGPUDriver.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/filament/backend/src/webgpu/WebGPUDriver.cpp b/filament/backend/src/webgpu/WebGPUDriver.cpp index dafab4571b..0e1c09c3a1 100644 --- a/filament/backend/src/webgpu/WebGPUDriver.cpp +++ b/filament/backend/src/webgpu/WebGPUDriver.cpp @@ -228,6 +228,14 @@ WebGPUDriver::WebGPUDriver(WebGPUPlatform& platform, const Platform::DriverConfi driverConfig.disableHeapHandleTags) { #if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM) printInstanceDetails(mPlatform.getInstance()); +#endif + mAdapter = mPlatform.requestAdapter(nullptr); +#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM) + printAdapterDetails(mAdapter); +#endif + mDevice = mPlatform.requestDevice(mAdapter); +#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM) + printDeviceDetails(mDevice); #endif } @@ -430,14 +438,7 @@ void WebGPUDriver::createSwapChainR(Handle sch, void* nativeWindow, mNativeWindow = nativeWindow; assert_invariant(!mSwapChain); wgpu::Surface surface = mPlatform.createSurface(nativeWindow, flags); - mAdapter = mPlatform.requestAdapter(surface); -#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM) - printAdapterDetails(mAdapter); -#endif - mDevice = mPlatform.requestDevice(mAdapter); -#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM) - printDeviceDetails(mDevice); -#endif + mQueue = mDevice.GetQueue(); wgpu::Extent2D surfaceSize = mPlatform.getSurfaceExtent(mNativeWindow); mSwapChain = constructHandle(sch, std::move(surface), surfaceSize, mAdapter,