This directory contains examples demonstrating Geyser's GPU texture sharing capabilities.
The examples are organized by functionality and complexity:
vulkan_to_vulkan.rs: Demonstrates Vulkan texture sharing between two contextsmetal_to_metal.rs: Demonstrates Metal texture sharing using IOSurface (macOS only)bevy_integration.rs: Shows conceptual integration with Bevy game engine
vulkan_to_metal.rs: Cross-API sharing between Vulkan and Metal
- Rust stable or beta toolchain
- GPU with appropriate driver support
- Vulkan SDK installed
- Compatible GPU with Vulkan support
- Vulkan development packages:
# Ubuntu/Debian sudo apt install vulkan-tools libvulkan-dev # Fedora sudo dnf install vulkan-tools vulkan-loader-devel
- Xcode Command Line Tools
- Metal is included with macOS
# On Windows or Linux
cargo run --example vulkan_to_vulkan --features vulkanThis example:
- Creates two Vulkan contexts
- Creates a shareable texture in Context 1
- Exports the texture handle
- Imports the handle in Context 2
- Demonstrates proper cleanup
Expected Output:
=== Geyser Vulkan to Vulkan Texture Sharing Example ===
Creating Vulkan Context 1...
✓ Context 1 created
App 1: Creating shareable texture...
✓ Texture created
- Width: 1024
- Height: 768
- Format: Rgba8Unorm
...
# On macOS
cargo run --example metal_to_metal --features metalThis example:
- Creates two Metal contexts
- Creates a shareable texture with IOSurface backing
- Exports the IOSurface ID
- Imports the texture in another context via IOSurface lookup
- Demonstrates proper resource management
Expected Output:
=== Geyser Metal to Metal Texture Sharing Example ===
Creating Metal Context 1...
✓ Context 1 created
App 1: Creating shareable texture...
✓ Texture created
...
# Windows/Linux with Vulkan
cargo run --example bevy_integration --features vulkan
# macOS with Metal
cargo run --example bevy_integration --features metalThis example:
- Initializes a Geyser texture manager
- Creates a shareable texture
- Sets up a Bevy window and renderer
- Displays an animated pattern updated from the Geyser texture
- Demonstrates the integration pattern (currently using CPU copies)
Expected Output:
- A window displaying an animated RGB gradient pattern
- Console output showing initialization steps
Note: This Phase 1 example uses CPU-side copies to transfer data. True zero-copy integration requires deeper WGPU/Bevy integration (Phase 2/3 goal).
- Examples use
VK_KHR_external_memory_win32for Vulkan external memory - Requires Vulkan SDK to be properly installed
- May need to enable Vulkan validation layers for debugging
- Examples use
VK_KHR_external_memory_fdfor Vulkan external memory - File descriptor-based sharing
- Ensure your GPU drivers support external memory extensions
- Metal examples use IOSurface for cross-process sharing
- IOSurface IDs can be passed between processes
- Vulkan support via MoltenVK (not yet implemented for cross-API sharing)
- ✅ Windows external memory (VK_KHR_external_memory_win32)
- ✅ Linux external memory (VK_KHR_external_memory_fd)
- ✅ Texture export/import with proper extension loading
- ✅ Semaphore synchronization (Windows HANDLE / Linux FD)
- ✅ Fence synchronization (Windows HANDLE / Linux FD)
- ✅ Resource lifetime management
- ✅ IOSurface-backed texture sharing (macOS/iOS)
- ✅ Texture export/import via IOSurface IDs
- ✅ MTLSharedEvent synchronization
- ✅ All 21 common texture formats
- ✅ Proper storage mode configuration
- ✅ 9 unit tests for common types
- ✅ Unit tests for Vulkan synchronization primitives
- ✅ Unit tests for Metal handles and formats
- ✅ Integration test framework
- Bevy Integration: Currently uses CPU-side copies, not true zero-copy
- Cross-Process Examples: Examples simulate cross-process by using multiple contexts
- WebGPU Backend: Not yet implemented
- Real cross-process IPC examples
- Cross-API sharing (Vulkan ↔ Metal on macOS)
- Timeline semaphores for advanced sync
- Performance benchmarks
- WebGPU backend integration
- Zero-copy Bevy integration
- Multi-GPU scenarios
- Compressed texture format support
- Windows: Ensure Vulkan SDK is installed and in PATH
- Linux: Install vulkan-loader package
- Check that your GPU supports Vulkan
- Ensure you're running on macOS 10.13 or later
- Check that Metal is supported on your Mac
- Check that you have proper windowing support (X11/Wayland on Linux)
- On Windows, ensure you have up-to-date graphics drivers
- Bevy has many features; ensure you're not running into dependency conflicts
- Try
cargo cleanand rebuild
Each example follows a similar pattern:
// 1. Create graphics API context (Vulkan/Metal)
let manager = create_manager()?;
// 2. Create a shareable texture
let texture_desc = TextureDescriptor { /* ... */ };
let texture = manager.create_shareable_texture(&texture_desc)?;
// 3. Export the texture handle
let handle = manager.export_texture(texture.as_ref())?;
// 4. In another context/process, import the texture
let imported = manager.import_texture(handle, &texture_desc)?;
// 5. Use the imported texture
// ...
// 6. Clean up
manager.release_texture_handle(handle)?;When adding new examples:
- Follow the existing naming convention
- Include comprehensive comments
- Add platform-specific
#[cfg]guards - Update this README with usage instructions
- Test on all supported platforms if possible
To extend these examples:
- Implement real external memory export/import in Vulkan backend
- Create multi-process examples using IPC for handle passing
- Add synchronization primitives
- Implement cross-API sharing examples
- Develop zero-copy Bevy integration