This document outlines the concrete steps to complete Phase 2 of the Geyser project, focusing on making the texture sharing functionality fully operational with real external memory implementation and cross-process capabilities.
- ✅ Core architecture and trait system
- ✅ Vulkan backend structure (placeholder external memory)
- ✅ Metal backend with IOSurface
- ✅ 26 texture formats supported
- ✅ Synchronization primitive types defined
- ✅ Comprehensive examples (3 functional)
- ✅ Integration test suite
- ✅ 1,500+ lines of documentation
- Real External Memory - Implement actual Vulkan external memory export/import
- Synchronization - Add working sync primitives
- Cross-Process - Real IPC-based texture sharing
- Testing - Validate on actual hardware
- Performance - Benchmarks and optimization
File: src/vulkan/mod.rs
Priority: 🔴 HIGHEST
Estimated Time: 3-5 days
What to Implement:
// In VulkanTextureShareManager
#[cfg(target_os = "windows")]
fn export_external_memory_win32(&self, memory: vk::DeviceMemory) -> Result<u64> {
use ash::extensions::khr::ExternalMemoryWin32;
let ext = ExternalMemoryWin32::new(&self.instance, &self.device);
let handle_info = vk::MemoryGetWin32HandleInfoKHR::builder()
.memory(memory)
.handle_type(vk::ExternalMemoryHandleTypeFlags::OPAQUE_WIN32);
let handle = unsafe {
ext.get_memory_win32_handle_khr(&handle_info)?
};
Ok(handle as u64)
}
#[cfg(target_os = "windows")]
fn import_external_memory_win32(&self, handle: u64, size: u64) -> Result<vk::DeviceMemory> {
let import_info = vk::ImportMemoryWin32HandleInfoKHR::builder()
.handle_type(vk::ExternalMemoryHandleTypeFlags::OPAQUE_WIN32)
.handle(handle as *mut std::ffi::c_void);
let alloc_info = vk::MemoryAllocateInfo::builder()
.allocation_size(size)
.memory_type_index(/* determine from requirements */)
.push_next(&mut import_info);
unsafe { self.device.allocate_memory(&alloc_info, None) }
}Steps:
- Add
VK_KHR_external_memory_win32extension loading - Modify
create_shareable_textureto useExportMemoryAllocateInfo - Implement
export_external_memory_win32 - Implement
import_external_memory_win32 - Update
export_textureto call new function - Update
import_textureto call new function - Test on Windows with Vulkan SDK
Validation:
- Create texture in process A
- Export handle
- Import handle in process A (different manager)
- Verify texture properties match
File: src/vulkan/mod.rs
Priority: 🟡 HIGH
Estimated Time: 3-5 days
Similar to Windows, but using:
VK_KHR_external_memory_fd- File descriptors instead of Win32 handles
get_memory_fd_khrandImportMemoryFdInfoKHR
File: tests/external_memory_tests.rs
Priority: 🟡 HIGH
Estimated Time: 2 days
Create tests that verify:
- Real handle export/import
- Memory dedications
- Handle validity
- Cross-manager sharing
File: src/vulkan/mod.rs
Priority: 🟡 MEDIUM-HIGH
Estimated Time: 3-4 days
API Addition:
impl VulkanTextureShareManager {
pub fn create_shared_semaphore(&self) -> Result<vk::Semaphore>;
pub fn export_semaphore(&self, semaphore: vk::Semaphore) -> Result<VulkanSemaphoreHandle>;
pub fn import_semaphore(&self, handle: VulkanSemaphoreHandle) -> Result<vk::Semaphore>;
}Extensions:
VK_KHR_external_semaphoreVK_KHR_external_semaphore_win32/_fd
File: src/metal/mod.rs
Priority: 🟡 MEDIUM
Estimated Time: 2-3 days
impl MetalTextureShareManager {
pub fn create_shared_event(&self) -> Result<metal::SharedEvent>;
pub fn export_event(&self, event: &metal::SharedEvent) -> Result<MetalEventHandle>;
pub fn import_event(&self, handle: MetalEventHandle) -> Result<metal::SharedEvent>;
}File: src/lib.rs
Priority: 🟡 MEDIUM
Estimated Time: 2 days
Extend TextureShareManager trait:
pub trait TextureShareManager {
// ... existing methods
fn wait_for_texture(&self, texture: &dyn SharedTexture, timeout_ns: u64) -> Result<()>;
fn signal_texture_ready(&self, texture: &dyn SharedTexture) -> Result<()>;
}File: examples/shared/ipc.rs
Priority: 🟡 MEDIUM
Estimated Time: 3-4 days
Implement:
- Named pipe communication (Windows)
- Unix domain sockets (Linux/macOS)
- Handle serialization/deserialization
- Simple protocol for handle passing
pub struct TextureHandleMessage {
pub handle_data: Vec<u8>,
pub width: u32,
pub height: u32,
pub format: TextureFormat,
}
pub fn send_handle(handle: &ApiTextureHandle) -> Result<()>;
pub fn receive_handle() -> Result<(ApiTextureHandle, TextureDescriptor)>;File: examples/producer.rs
Priority: 🟡 MEDIUM
Estimated Time: 2 days
Creates texture, exports, sends handle via IPC:
fn main() -> Result<()> {
let manager = create_manager()?;
let texture = manager.create_shareable_texture(&desc)?;
let handle = manager.export_texture(texture.as_ref())?;
ipc::send_handle(&handle)?;
// Keep texture alive
std::thread::park();
}File: examples/consumer.rs
Priority: 🟡 MEDIUM
Estimated Time: 2 days
Receives handle, imports texture, uses it:
fn main() -> Result<()> {
let (handle, desc) = ipc::receive_handle()?;
let manager = create_manager()?;
let texture = manager.import_texture(handle, &desc)?;
// Use texture for rendering
render_with_texture(texture)?;
}File: benches/texture_ops.rs
Priority: 🟢 MEDIUM
Estimated Time: 2-3 days
Measure:
- Texture creation time
- Export latency
- Import latency
- Cross-process roundtrip
- Memory overhead
Files: Various
Priority: 🟢 MEDIUM
Estimated Time: 2-3 days
Update:
PHASE2_SUMMARY.mdwith resultsREADME.mdwith real capabilities- Examples README with new binaries
- Architecture docs with sync primitives
File: .github/workflows/ci.yml
Priority: 🟢 LOW
Estimated Time: 1 day
Add:
- Cross-process test job
- Benchmark tracking
- Multiple OS testing
- Handle Lifetime: Win32 HANDLEs need explicit closing via
CloseHandle - Security: Handles may need security descriptors for cross-process
- Duplication: May need
DuplicateHandlefor handle passing
- File Descriptors: Need proper
dup/closehandling - DMA-BUF: Consider using DMA-BUF instead of opaque FDs
- Permissions: File descriptor passing requires proper socket permissions
- IOSurface: Already working, just needs sync
- MoltenVK: Cross-API requires MoltenVK awareness
- ✅ Real external memory working on Windows
- ✅ Real external memory working on Linux
- ✅ Synchronization primitives functional
- ✅ Producer/consumer example works cross-process
- ✅ Tests passing on Windows + Linux
- ✅ Benchmarks show acceptable performance
- ✅ Documentation updated
Impact: HIGH
Mitigation: May need manual vk::DeviceMemory allocation for exported textures
Impact: MEDIUM
Mitigation: Test on actual hardware early, maintain platform-specific code paths
Impact: MEDIUM
Mitigation: Early benchmarking, profiling, optimization iteration
Impact: LOW-MEDIUM
Mitigation: Handle validation, timeout mechanisms, proper cleanup
- Sprint 1 (Core): 2-3 weeks
- Sprint 2 (Sync): 2-3 weeks
- Sprint 3 (Cross-Process): 2-3 weeks
- Sprint 4 (Polish): 1-2 weeks
Total: 7-11 weeks (part-time development)
- Start Task 1.1: Windows external memory
- Set up Vulkan SDK with external memory extensions
- Create simple test case for export/import
- Complete Windows implementation
- Test on actual Windows hardware
- Start Linux implementation
Real external memory working on Windows + Linux with tests passing
Document Version: 1.0
Last Updated: 2025-10-23
Status: 🟢 Active Development