From 779f2620877cf86093c2f0b7281c1cc9833a85eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sat, 19 Sep 2026 10:56:44 +0200 Subject: [PATCH] Add exact-device Linux external factory --- ...nux-exact-device-factory-child-issue-28.md | 54 +++++ .../linux-external-image-interop-28.md | 62 ++++-- .../CMakeLists.txt | 2 + .../graphics/dawn_linux_external_provider.h | 210 +++++++++++++++++- ...linux_external_provider_contract_tests.cpp | 29 +++ src/WebScene.Sdk/cmake/LinuxSDK.cmake | 2 + .../cmake/WebSceneLinuxConfig.cmake | 3 +- src/WebScene.Sdk/cmake/WebSceneLinuxSDK.cmake | 2 + 8 files changed, 341 insertions(+), 23 deletions(-) create mode 100644 docs/validation/linux-exact-device-factory-child-issue-28.md diff --git a/docs/validation/linux-exact-device-factory-child-issue-28.md b/docs/validation/linux-exact-device-factory-child-issue-28.md new file mode 100644 index 000000000..9785fb91a --- /dev/null +++ b/docs/validation/linux-exact-device-factory-child-issue-28.md @@ -0,0 +1,54 @@ +# Child issue scope draft: connect AppScene to the exact Dawn Vulkan device + +Parent: WebScene #28. + +## Problem + +WebScene now accepts an atomic `dawn_linux_external_device_factory` result and +owns external Vulkan allocations through +`owned_dawn_linux_external_allocation`. The pinned public Dawn revision still +does not expose its `VkDevice`, `VkPhysicalDevice`, `VkQueue` or queue family, +and it cannot wrap a host-created `VkDevice`. AppScene cannot implement the +factory correctly by matching only the adapter UUID or Vulkan instance. + +## Focused implementation + +- Add one supported, pinned Dawn SDK hook that returns the exact Vulkan + device/physical-device/queue tuple and queue family for a created + `WGPUDevice`, with lifetime and device-loss rules. Do not include Dawn private + headers in AppScene. +- Create the Dawn instance, adapter and device plus the AppScene allocator as + one factory result. Publish one shared lifetime object containing the public + adapter/device tokens, Vulkan device/driver UUIDs, Dawn queue family and the + native tuple's opaque identities and owner. +- Allocate one single-sample BGRA/RGBA Vulkan image with a negotiated external + opaque-FD or single-FD DMA-BUF route on that exact device. Own the + `VkImage`/`VkDeviceMemory`, exported memory FD and retained create-info chain, + then adopt them through `owned_dawn_linux_external_allocation`. +- Feed the returned WebScene texture through the existing BeginAccess, + rendering and EndAccess path. Preserve initialized contents, layouts, queue + ownership and exported fence ordering domains. +- Return an explicit unsupported/error status for every missing capability or + identity mismatch. Do not create an ordinary Dawn texture, CPU bitmap upload + or readback fallback. + +## Acceptance + +- The allocator's `WGPUDevice`, native lifetime, UUIDs and Dawn queue family + match the factory device exactly; copied/foreign identities are rejected. +- Vulkan external-image format and handle queries admit the selected format, + usage, tiling/modifier, dedicated-allocation and synchronization combination. +- A rendered hardware pixel pattern survives Dawn EndAccess and AppScene GPU + import with the recorded layout and queue-family transition. +- Invalid UUID, queue family, modifier and fence imports fail without publishing + a frame or leaking Vulkan objects/FDs. +- Resize, device loss and teardown keep FD and GPU residency bounded; ordinary + frames show no CPU readback/upload. + +## Evidence required before closing + +Record exact WebScene/AppScene/Dawn revisions, physical adapter and driver, +device/driver UUIDs, queue families, Vulkan external-memory/semaphore capability +queries, rendered pixels, negative cases, a 30-minute FD/residency plateau and +an installed-SDK consumer run. Software Vulkan coverage is separate and does +not satisfy the physical-hardware gate. diff --git a/docs/validation/linux-external-image-interop-28.md b/docs/validation/linux-external-image-interop-28.md index ecf43d36f..67a066238 100644 --- a/docs/validation/linux-external-image-interop-28.md +++ b/docs/validation/linux-external-image-interop-28.md @@ -69,14 +69,34 @@ provider seam around the pinned public Dawn ABI: and RAII closes every already-exported FD. The installed Dawn C ABI exposes only Vulkan `driverVersion` in -`AdapterPropertiesVk`. It exposes no `VkDevice`, `VkPhysicalDevice`, queue -family or device/driver UUID. Consequently WebScene cannot construct or -independently verify a Vulkan allocator from this SDK surface. Capability -inspection returns `native_device_provider_required` even when all import -features exist. The host that creates Dawn's native Vulkan device must install -an allocator bound to that exact device token and populate the UUID, create -info, modifier and queue-family fields. Without it, acquisition continues to -return `WEBSCENE_GPU_LINUX_SHARED_UNSUPPORTED_PROVIDER_V3`. +`AdapterPropertiesVk`. The pinned `dawn/native/VulkanBackend.h` adds only +`GetInstance` and `GetInstanceProcAddr`; it exposes no `VkDevice`, +`VkPhysicalDevice`, `VkQueue`, queue family or device/driver UUID, and Dawn's +adapter creates its own `VkDevice` rather than wrapping one supplied by a host. +The implementations that expose these objects live under Dawn's private +`src/dawn/native/vulkan` tree and are not an SDK contract. WebScene therefore +does not infer device identity from the Vulkan instance, adapter properties or +matching UUIDs. + +The SDK now exposes `dawn_linux_external_device_factory`. An AppScene host with +an exact-device Dawn integration creates the WebGPU instance/adapter/device and +native allocator atomically, and returns one +`dawn_linux_external_device_lifetime` shared by the allocator and every +allocation. That lifetime carries the exact public `WGPUAdapter`/`WGPUDevice` tokens, +opaque identities for the native device/physical-device/queue, device/driver +UUIDs, Dawn queue family and a host-owned lifetime anchor for that tuple. +Provider creation rejects a copied lifetime object, mismatched device token, +UUID or queue family. + +`owned_dawn_linux_external_allocation` is the concrete handoff boundary. It +retains the exact device lifetime, the host's `VkImage`/`VkDeviceMemory` owner, +the retained opaque-FD `VkImageCreateInfo` graph when applicable, and owned +memory/wait FDs. It rewrites exported snapshots to borrow only those owned FDs +and restricts the pinned Dawn DMA-BUF route to its supported single-FD plane +model. Provider member order destroys `SharedTextureMemory` before releasing +the native allocation and exact device. A factory-backed provider can therefore +advance past `native_device_provider_required`; an absent or invalid host +factory still fails closed. ANGLE Vulkan/GL interop remains independently unimplemented. No GL/EGL route is advertised by this contract. @@ -85,8 +105,10 @@ advertised by this contract. - C11 ABI size/offset contracts cover all exported views. - The provider contract covers exact Dawn-device binding, binary/timeline fence - rules, layout ownership rotation, metadata, memory/layout/queue validation, - producer readiness, timeline rules, FD duplication, closure and rollback. + rules, shared exact-device lifetime identity, UUID/queue-family admission, + concrete native-allocation/FD ownership, layout ownership rotation, metadata, + memory/layout/queue validation, producer readiness, timeline rules, FD + duplication, closure and rollback. - Dense Linux linking exports all `webscene_gpu_linux_*_v3` symbols through the existing version script; macOS export lists include the additive symbols for stable cross-platform loading and return unsupported outside Linux. @@ -103,11 +125,15 @@ FD/residency plateau, and proof of zero CPU readback/upload in ordinary frames. ## Remaining concrete blocker -Implement the host-side Vulkan allocation object behind -`dawn_linux_external_allocator`. This requires either a Dawn SDK addition that -exposes a supported native Vulkan device/physical-device/queue identity, or -device creation owned by a Linux host component that can bind those native -handles and the public `WGPUDevice` token atomically. Then negotiate hardware -support per format, modifier, handle type and synchronization route and run the -authored contract on a real Vulkan device. Unsupported routes remain explicit -and cannot fall back to CPU presentation under the GPU-image capability. +Implement `dawn_linux_external_device_factory` in AppScene against a supported +exact-device Dawn integration. The current pinned public Dawn library cannot do +this by itself, so the host needs a narrowly supported Dawn SDK hook (or an +equivalent host-owned Dawn build) that returns the exact native device, +physical-device, queue and queue family for the created `WGPUDevice`. The host +then allocates/exports opaque-FD or DMA-BUF storage on those handles, adopts it +through `owned_dawn_linux_external_allocation`, and negotiates hardware support +per format, modifier, handle type and synchronization route. Real Linux Vulkan +hardware/driver execution is still required for pixels, negative identity and +layout cases, device loss, FD/residency plateau and zero-readback evidence. +Unsupported routes remain explicit and cannot fall back to CPU presentation +under the GPU-image capability. diff --git a/experiments/WebScene.NativeEngine.Probe/CMakeLists.txt b/experiments/WebScene.NativeEngine.Probe/CMakeLists.txt index e4716d840..2ee514058 100644 --- a/experiments/WebScene.NativeEngine.Probe/CMakeLists.txt +++ b/experiments/WebScene.NativeEngine.Probe/CMakeLists.txt @@ -379,6 +379,8 @@ if(WEBSCENE_NATIVE_ENGINE_ENABLE_GRAPHICS) add_executable(webscene_graphics_dawn_linux_external_provider_contract_tests tests/graphics_dawn_linux_external_provider_contract_tests.cpp) target_compile_features(webscene_graphics_dawn_linux_external_provider_contract_tests PRIVATE cxx_std_20) + target_compile_definitions(webscene_graphics_dawn_linux_external_provider_contract_tests PRIVATE + WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION=1) target_include_directories(webscene_graphics_dawn_linux_external_provider_contract_tests PRIVATE native) target_link_libraries(webscene_graphics_dawn_linux_external_provider_contract_tests PRIVATE dawn::webgpu_dawn) diff --git a/experiments/WebScene.NativeEngine.Probe/native/graphics/dawn_linux_external_provider.h b/experiments/WebScene.NativeEngine.Probe/native/graphics/dawn_linux_external_provider.h index a1419d1fe..803f161b3 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/graphics/dawn_linux_external_provider.h +++ b/experiments/WebScene.NativeEngine.Probe/native/graphics/dawn_linux_external_provider.h @@ -1,8 +1,12 @@ #pragma once #include "dawn_shared_image.h" #include "linux_external_image.h" +#include namespace webscene::graphics { +#ifndef WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION +#define WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION 1U +#endif // The WebGPU C ABI bundled with WebScene exposes Vulkan shared-memory import, // but deliberately does not expose Dawn's VkDevice/VkPhysicalDevice. A native // allocator therefore has to be installed by the code which created the exact @@ -23,7 +27,51 @@ enum class dawn_linux_external_status : uint32_t { end_failed, uninitialized_handoff, unsupported_fence, - fence_export_failed + fence_export_failed, + invalid_device_factory +}; + +struct dawn_linux_external_device_lifetime { + WGPUAdapter dawn_adapter_token{}; + WGPUDevice dawn_device_token{}; + // Opaque borrowed identities for the exact Vulkan tuple. They are never + // called or cast by WebScene; native_owner controls their typed lifetime. + const void* vk_physical_device{}; + const void* vk_device{}; + const void* vk_queue{}; + std::array device_uuid{}; + std::array driver_uuid{}; + uint32_t dawn_queue_family{UINT32_MAX}; + // Host-defined owner for the exact native device/physical-device/queue + // tuple. It must outlive every allocation made from those Vulkan handles. + std::shared_ptr native_owner; +}; + +struct dawn_linux_external_allocator; + +// Atomic result of host-owned Dawn/Vulkan device creation. The pinned public +// Dawn API cannot build this object: it exposes VkInstance but no supported +// VkDevice, VkPhysicalDevice or VkQueue accessor and cannot wrap a host VkDevice. +// AppScene (or another native host with an exact-device integration) creates +// the Dawn device and allocator together and publishes one shared lifetime. +struct dawn_linux_external_device { + wgpu::Instance instance; + wgpu::Adapter adapter; + wgpu::Device device; + std::shared_ptr lifetime; + std::shared_ptr allocator; +}; + +struct dawn_linux_external_device_request { + std::span required_features; + bool force_fallback_adapter{}; +}; + +struct dawn_linux_external_device_factory { + virtual ~dawn_linux_external_device_factory()=default; + virtual dawn_linux_external_status create( + const dawn_linux_external_device_request&, + std::shared_ptr&)=0; }; struct dawn_linux_external_capabilities { @@ -71,6 +119,10 @@ inline dawn_linux_external_status inspect_dawn_linux_external_capabilities( struct dawn_linux_external_allocation : linux_external_image_provider { // Must be the same public handle used when the native allocator was bound. virtual WGPUDevice dawn_device_token() const noexcept=0; + // Retaining the exact shared object is part of allocation ownership. A + // token/UUID copy alone cannot keep the native Vulkan device alive. + virtual std::shared_ptr + device_lifetime() const noexcept=0; // Required only for opaque-FD. It points to a VkImageCreateInfo retained by // this allocation through ImportSharedTextureMemory. virtual const void* vk_image_create_info() const noexcept=0; @@ -84,11 +136,132 @@ struct dawn_linux_external_allocator { // Capture device.Get() when the allocator is installed next to Dawn device // creation. Ordinary Dawn textures are never accepted as external storage. virtual WGPUDevice dawn_device_token() const noexcept=0; + virtual std::shared_ptr + device_lifetime() const noexcept=0; virtual dawn_linux_external_status allocate(const image_metadata&, wgpu::TextureFormat,wgpu::TextureUsage, std::shared_ptr&)=0; }; +inline bool same_dawn_linux_external_identity( + const std::shared_ptr& expected, + const std::shared_ptr& actual) noexcept { + return expected&&expected==actual&&expected->native_owner&& + expected->dawn_adapter_token&&expected->dawn_device_token&& + expected->dawn_adapter_token==actual->dawn_adapter_token&& + expected->dawn_device_token==actual->dawn_device_token&& + expected->vk_physical_device&&expected->vk_device&&expected->vk_queue&& + nonzero_uuid(expected->device_uuid)&&nonzero_uuid(expected->driver_uuid)&& + expected->dawn_queue_family!=UINT32_MAX; +} + +inline bool dawn_linux_snapshot_matches_device( + const linux_external_image_snapshot& snapshot, + const dawn_linux_external_device_lifetime& device) noexcept { + if(snapshot.device_uuid!=device.device_uuid||snapshot.driver_uuid!=device.driver_uuid) + return false; + if(snapshot.queue_sharing==linux_queue_sharing::exclusive) + return snapshot.consumer_queue_family==device.dawn_queue_family; + if(snapshot.queue_sharing!=linux_queue_sharing::concurrent)return false; + for(uint32_t index=0;indexdevice_lifetime())&& + value.adapter.Get()==value.lifetime->dawn_adapter_token&& + valid_dawn_linux_external_binding(value.device.Get(), + value.lifetime->dawn_device_token,value.allocator->dawn_device_token()); +} + +#if defined(__linux__) +// Concrete ownership boundary returned by an exact-device Vulkan allocator. +// native_allocation_owner owns the VkImage/VkDeviceMemory (and any allocator +// state); this object owns the exported memory/wait FDs. SharedTextureMemory is +// destroyed before the provider releases this allocation. +class owned_dawn_linux_external_allocation final : public dawn_linux_external_allocation { + std::shared_ptr device_; + std::shared_ptr native_allocation_owner_; + std::shared_ptr vk_image_create_info_; + owned_posix_fd memory_fd_; + std::vector wait_fds_; + linux_external_image_snapshot snapshot_; + uint64_t first_fence_ordering_domain_{}; + bool opaque_fences_are_timeline_{}; +public: + WGPUDevice dawn_device_token() const noexcept override { + return device_?device_->dawn_device_token:nullptr; + } + std::shared_ptr + device_lifetime() const noexcept override {return device_;} + const void* vk_image_create_info() const noexcept override { + return vk_image_create_info_.get(); + } + uint64_t fence_ordering_domain(size_t index,wgpu::SharedFenceType) const noexcept override { + if(index>UINT64_MAX-first_fence_ordering_domain_)return 0; + return first_fence_ordering_domain_+index; + } + bool fence_is_timeline(size_t,wgpu::SharedFenceType type) const noexcept override { + return type==wgpu::SharedFenceType::VkSemaphoreOpaqueFD&&opaque_fences_are_timeline_; + } + bool export_image(const image_metadata& expected, + linux_external_image_snapshot& result) const override { + if(!same_image_metadata(expected,snapshot_.metadata))return false; + result=snapshot_;return true; + } + + static dawn_linux_external_status adopt( + std::shared_ptr device, + linux_external_image_snapshot snapshot,owned_posix_fd memory_fd, + std::vector wait_fds, + std::shared_ptr native_allocation_owner, + std::shared_ptr vk_image_create_info, + uint64_t first_fence_ordering_domain,bool opaque_fences_are_timeline, + std::shared_ptr& result) { + result.reset(); + if(!same_dawn_linux_external_identity(device,device)||!memory_fd||!native_allocation_owner|| + !first_fence_ordering_domain||snapshot.planes.empty()|| + snapshot.waits.size()!=wait_fds.size()) + return dawn_linux_external_status::invalid_allocation; + if(snapshot.memory_handle==linux_memory_handle::opaque_fd) { + if(snapshot.planes.size()!=1||!vk_image_create_info) + return dawn_linux_external_status::invalid_allocation; + } else if(snapshot.memory_handle==linux_memory_handle::dma_buf) { + // The pinned Dawn import supports multiple plane layouts only when + // every plane names the same DMA-BUF FD. + if(snapshot.planes.size()>3||vk_image_create_info) + return dawn_linux_external_status::invalid_allocation; + } else return dawn_linux_external_status::invalid_allocation; + for(auto& plane:snapshot.planes)plane.borrowed_fd=memory_fd.get(); + for(size_t index=0;index(); + owned->device_=std::move(device); + owned->native_allocation_owner_=std::move(native_allocation_owner); + owned->vk_image_create_info_=std::move(vk_image_create_info); + owned->memory_fd_=std::move(memory_fd); + owned->wait_fds_=std::move(wait_fds); + owned->snapshot_=std::move(snapshot); + owned->first_fence_ordering_domain_=first_fence_ordering_domain; + owned->opaque_fences_are_timeline_=opaque_fences_are_timeline; + result=std::move(owned); + return dawn_linux_external_status::success; + } +}; +#endif + inline bool valid_dawn_linux_external_binding(WGPUDevice expected, WGPUDevice allocator,WGPUDevice allocation) noexcept { return expected&&expected==allocator&&expected==allocation; @@ -133,6 +306,8 @@ inline bool same_dawn_linux_external_allocation(const linux_external_image_snaps // Call all methods on the Dawn device owner thread. export_image starts // succeeding only after a fully initialized EndAccess handoff has been encoded. class dawn_linux_external_provider final : public linux_external_image_provider { + std::shared_ptr exact_device_; + std::shared_ptr device_lifetime_; wgpu::Device device_; std::shared_ptr allocation_; std::shared_ptr shared_; @@ -243,15 +418,24 @@ class dawn_linux_external_provider final : public linux_external_image_provider dawn_linux_external_capabilities capabilities; const auto support=inspect_dawn_linux_external_capabilities(adapter,device,capabilities); if(support!=dawn_linux_external_status::native_device_provider_required)return support; + const auto lifetime=allocator.device_lifetime(); + if(!same_dawn_linux_external_identity(lifetime,lifetime)|| + adapter.Get()!=lifetime->dawn_adapter_token|| + !valid_dawn_linux_external_binding(device.Get(), + lifetime->dawn_device_token,allocator.dawn_device_token())) + return dawn_linux_external_status::device_mismatch; std::shared_ptr allocation; auto status=allocator.allocate(metadata,format,usage,allocation); if(status!=dawn_linux_external_status::success)return status; - if(!allocation||!valid_dawn_linux_external_binding(device.Get(), - allocator.dawn_device_token(),allocation->dawn_device_token())) + if(!allocation||!same_dawn_linux_external_identity( + lifetime,allocation->device_lifetime())|| + !valid_dawn_linux_external_binding(device.Get(), + allocator.dawn_device_token(),allocation->dawn_device_token())) return dawn_linux_external_status::device_mismatch; linux_external_image_snapshot snapshot; if(!allocation->export_image(metadata,snapshot)|| !valid_linux_external_snapshot(snapshot,metadata)|| + !dawn_linux_snapshot_matches_device(snapshot,*lifetime)|| !capabilities.has_memory(snapshot.memory_handle)|| (snapshot.dedicated_allocation&&!capabilities.dedicated_allocation)) return dawn_linux_external_status::invalid_allocation; @@ -283,12 +467,30 @@ class dawn_linux_external_provider final : public linux_external_image_provider if(!shared)return dawn_linux_external_status::import_failed; auto created=std::shared_ptr( new dawn_linux_external_provider); - created->device_=device;created->allocation_=std::move(allocation); + created->device_lifetime_=lifetime;created->device_=device; + created->allocation_=std::move(allocation); created->shared_=std::move(shared);created->published_=std::move(snapshot); result=std::move(created); return dawn_linux_external_status::success; } + static dawn_linux_external_status create(dawn_linux_external_device_factory& factory, + const dawn_linux_external_device_request& request,const image_metadata& metadata, + wgpu::TextureFormat format,wgpu::TextureUsage usage, + std::shared_ptr& result) { + result.reset(); + std::shared_ptr exact; + const auto status=factory.create(request,exact); + if(status!=dawn_linux_external_status::success)return status; + if(!exact||!valid_dawn_linux_external_device(*exact)) + return dawn_linux_external_status::invalid_device_factory; + auto provider_status=create(exact->adapter,exact->device,*exact->allocator, + metadata,format,usage,result); + if(provider_status==dawn_linux_external_status::success) + result->exact_device_=std::move(exact); + return provider_status; + } + dawn_linux_external_status begin_access() { if(active_||complete_)return dawn_linux_external_status::begin_failed; linux_external_image_snapshot source; diff --git a/experiments/WebScene.NativeEngine.Probe/tests/graphics_dawn_linux_external_provider_contract_tests.cpp b/experiments/WebScene.NativeEngine.Probe/tests/graphics_dawn_linux_external_provider_contract_tests.cpp index d86a22395..58777e04b 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/graphics_dawn_linux_external_provider_contract_tests.cpp +++ b/experiments/WebScene.NativeEngine.Probe/tests/graphics_dawn_linux_external_provider_contract_tests.cpp @@ -6,6 +6,7 @@ namespace { void require(bool value){if(!value)throw std::runtime_error("Dawn Linux external provider contract failed");} } int main(){ + static_assert(WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION==1); auto* first=reinterpret_cast(uintptr_t{1}); auto* second=reinterpret_cast(uintptr_t{2}); require(valid_dawn_linux_external_binding(first,first,first)); @@ -13,6 +14,34 @@ int main(){ require(!valid_dawn_linux_external_binding(first,second,first)); require(!valid_dawn_linux_external_binding(first,first,second)); + auto native_owner=std::make_shared(42); + auto device=std::make_shared(); + device->dawn_adapter_token=reinterpret_cast(uintptr_t{6}); + device->dawn_device_token=first; + device->vk_physical_device=reinterpret_cast(uintptr_t{3}); + device->vk_device=reinterpret_cast(uintptr_t{4}); + device->vk_queue=reinterpret_cast(uintptr_t{5}); + device->device_uuid[0]=1; + device->driver_uuid[0]=2;device->dawn_queue_family=4; + device->native_owner=native_owner; + require(same_dawn_linux_external_identity(device,device)); + auto copied=std::make_shared(*device); + require(!same_dawn_linux_external_identity(device,copied)); + + linux_external_image_snapshot exact; + exact.device_uuid=device->device_uuid;exact.driver_uuid=device->driver_uuid; + exact.queue_sharing=linux_queue_sharing::exclusive; + exact.consumer_queue_family=device->dawn_queue_family; + require(dawn_linux_snapshot_matches_device(exact,*device)); + exact.consumer_queue_family=5; + require(!dawn_linux_snapshot_matches_device(exact,*device)); + exact.queue_sharing=linux_queue_sharing::concurrent; + exact.vk_queue_family_index_count=2; + exact.vk_queue_family_indices={3,4,0,0}; + require(dawn_linux_snapshot_matches_device(exact,*device)); + exact.vk_queue_family_indices={3,5,0,0}; + require(!dawn_linux_snapshot_matches_device(exact,*device)); + require(valid_dawn_linux_fence_handoff(linux_sync_handle::sync_fd,false,1,7)); require(!valid_dawn_linux_fence_handoff(linux_sync_handle::sync_fd,true,1,7)); require(!valid_dawn_linux_fence_handoff(linux_sync_handle::sync_fd,false,2,7)); diff --git a/src/WebScene.Sdk/cmake/LinuxSDK.cmake b/src/WebScene.Sdk/cmake/LinuxSDK.cmake index 5eb4e5cf5..7a8fb056a 100644 --- a/src/WebScene.Sdk/cmake/LinuxSDK.cmake +++ b/src/WebScene.Sdk/cmake/LinuxSDK.cmake @@ -35,6 +35,8 @@ if(WEBSCENE_SDK_ENABLE_WEBGPU) include("${WEBSCENE_ROOT}/eng/graphics/GraphicsDependencies.cmake") add_library(webscene_sdk_webgpu INTERFACE) target_include_directories(webscene_sdk_webgpu INTERFACE "${WEBSCENE_ROOT}/experiments/WebScene.NativeEngine.Probe/native/graphics") + target_compile_definitions(webscene_sdk_webgpu INTERFACE + WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION=1) target_link_libraries(webscene_sdk_webgpu INTERFACE webscene_core dawn::webgpu_dawn) add_library(WebScene::WebGPU ALIAS webscene_sdk_webgpu) install(DIRECTORY "${WEBSCENE_GRAPHICS_SDK_ROOT}/dawn/include/" DESTINATION include) diff --git a/src/WebScene.Sdk/cmake/WebSceneLinuxConfig.cmake b/src/WebScene.Sdk/cmake/WebSceneLinuxConfig.cmake index 039d266c0..69538a36f 100644 --- a/src/WebScene.Sdk/cmake/WebSceneLinuxConfig.cmake +++ b/src/WebScene.Sdk/cmake/WebSceneLinuxConfig.cmake @@ -40,7 +40,8 @@ if(NOT TARGET WebScene::Core) add_library(WebScene::WebGPU INTERFACE IMPORTED GLOBAL) set_target_properties(WebScene::WebGPU PROPERTIES INTERFACE_LINK_LIBRARIES "WebScene::Core;WebScene::_Dawn;Threads::Threads;${CMAKE_DL_LIBS}" - INTERFACE_INCLUDE_DIRECTORIES "${WebScene_SDK_ROOT}/include/graphics") + INTERFACE_INCLUDE_DIRECTORIES "${WebScene_SDK_ROOT}/include/graphics" + INTERFACE_COMPILE_DEFINITIONS "WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION=1") endif() add_executable(WebScene::Compiler IMPORTED GLOBAL) set_property(TARGET WebScene::Compiler PROPERTY IMPORTED_LOCATION "${WebScene_SDK_ROOT}/bin/webscene-uic") diff --git a/src/WebScene.Sdk/cmake/WebSceneLinuxSDK.cmake b/src/WebScene.Sdk/cmake/WebSceneLinuxSDK.cmake index b010a4837..8db9812f1 100644 --- a/src/WebScene.Sdk/cmake/WebSceneLinuxSDK.cmake +++ b/src/WebScene.Sdk/cmake/WebSceneLinuxSDK.cmake @@ -40,6 +40,8 @@ if(WEBSCENE_SDK_WEBGPU) include("${WEBSCENE_ROOT}/eng/graphics/GraphicsDependencies.cmake") add_library(webscene_sdk_webgpu INTERFACE) target_include_directories(webscene_sdk_webgpu INTERFACE "${WEBSCENE_ROOT}/experiments/WebScene.NativeEngine.Probe/native/graphics") + target_compile_definitions(webscene_sdk_webgpu INTERFACE + WEBSCENE_DAWN_LINUX_EXTERNAL_FACTORY_VERSION=1) target_link_libraries(webscene_sdk_webgpu INTERFACE webscene_core dawn::webgpu_dawn Threads::Threads) add_library(WebScene::WebGPU ALIAS webscene_sdk_webgpu) install(DIRECTORY "${WEBSCENE_GRAPHICS_SDK_ROOT}/dawn/include/" DESTINATION include)