Skip to content

Conversation

@kolkov
Copy link
Contributor

@kolkov kolkov commented Jan 10, 2026

Summary

Critical fixes for Intel Vulkan driver compatibility and proper swapchain synchronization.

Added

  • VkRenderPass Support — Classic render pass for Intel (VK_KHR_dynamic_rendering broken)
  • wgpu-Style Swapchain Sync — Rotating semaphores/fences for proper frame pacing
  • Fence Status Optimization — Skip wait if already signaled
  • Device.WaitIdle()/ResetCommandPool() — Resource management methods

Fixed

  • Intel null pipeline workaround
  • goffi pointer argument passing
  • Validation layer availability check

Dependencies

  • naga v0.8.3 → v0.8.4 (SPIR-V instruction ordering fix)

Testing

  • Intel Iris Xe Graphics (Vulkan 1.4.323) — Triangle renders correctly
  • All existing tests pass
  • Linter passes

Related

  • Fixes issues with Intel Vulkan drivers
  • Part of Intel Vulkan triangle fix series

Intel Iris Xe Vulkan drivers return VK_SUCCESS but write VK_NULL_HANDLE
to pipeline output, violating Vulkan spec. Intel closed IGCIT #1309 as
"legacy support" — no fix coming.

Changes:
- Add ErrDriverBug error type for driver spec violations
- Add null checks after vkCreateGraphicsPipelines/vkCreateComputePipelines
- Return hal.ErrDriverBug instead of crashing on affected hardware

Fixes #24
- Fix goffi pointer-to-pointer calling convention in loader.go
  goffi expects args[] to contain pointers to WHERE values are stored
  For pointer args (const char*), must use &ptr not &data[0] directly

- Add WSI function loading in commands.go LoadInstance()
  Surface: vkDestroySurfaceKHR, vkGetPhysicalDeviceSurfaceSupportKHR
  Capabilities: vkGetPhysicalDeviceSurfaceCapabilities/Formats/PresentModesKHR
  Platform: vkCreateWin32SurfaceKHR
  Swapchain: vkCreate/DestroySwapchainKHR, vkGetSwapchainImagesKHR,
             vkAcquireNextImageKHR, vkQueuePresentKHR

- Add SetDeviceProcAddr() for Intel driver compatibility
  Intel Iris Xe doesn't support vkGetInstanceProcAddr(NULL, vkGetDeviceProcAddr)
  Must load with valid instance handle after vkCreateInstance

- Add enterprise-level documentation
  Package godoc with goffi calling convention examples
  Function loading hierarchy documentation
  Intel driver compatibility notes

Tested on Intel Iris Xe (12th Gen i7-1265U), Vulkan 1.4.323
Confirmed: Intel null pipeline bug detected by ErrDriverBug check

Refs: #24
Replace VK_KHR_dynamic_rendering with classic VkRenderPass approach
for Intel Iris Xe compatibility. Dynamic rendering doesn't work
properly on Intel Windows drivers.

Changes:
- Add RenderPassCache for VkRenderPass and VkFramebuffer caching
- Modify BeginRenderPass to use vkCmdBeginRenderPass
- Update pipeline creation to use compatible VkRenderPass
- Add vkFormat field to TextureView for swapchain format tracking
- Add acquire fence to swapchain synchronization (from Rust wgpu)

Clear color now works (blue background visible), triangle drawing
still needs investigation.
- Removed DEBUG printf statements from device.go and pipeline.go
- Removed temporary SPIR-V file saving
- Updated to use VkRenderPass instead of dynamic rendering
- Triangle now renders correctly on Intel Iris Xe Graphics
- Add rotating acquire semaphore pool (one per swapchain image)
- Add per-image present semaphores (indexed by image)
- Track currentAcquireSem for proper Submit/Present semaphore pairing
- Fix 'Not Responding' freeze on Windows with Intel Iris Xe

This matches the synchronization pattern used by Rust wgpu:
- Acquire semaphores rotate to avoid reuse conflicts
- Present semaphores are per-image (known after acquire)
- Post-acquire fence wait ensures image is ready (Windows/DXGI fix)
- Add acquireFences[] array (one fence per acquire semaphore)
- Wait on specific fence before reusing an acquire semaphore
- Signal fence when submission completes
- Fences start signaled so first frame doesn't block

This completes the wgpu-style synchronization model:
1. Pre-acquire fence wait (ensures semaphore is safe to reuse)
2. Post-acquire fence wait (Windows/Intel DXGI fix)
3. Rotating acquire semaphores (avoid reuse conflicts)
4. Per-image present semaphores (known after acquire)
- Add vkGetFenceStatus check before waiting on fences (wgpu-style)
- Skip fence wait if already signaled, reducing unnecessary stalls
- Add Device.WaitIdle() and Device.ResetCommandPool() methods
- Update vulkan-triangle test to periodically reset command pool
- Prevents command buffer memory exhaustion in long-running apps

Note: FIFO present mode on Intel/Windows/DXGI has known ~35-50 FPS
limitation (see wgpu issue #8310). Immediate mode achieves 1600+ FPS,
confirming rendering pipeline works correctly.
- VkRenderPass support (replaces VK_KHR_dynamic_rendering for Intel)
- wgpu-style swapchain synchronization with rotating semaphores/fences
- Fence status optimization (skip wait if already signaled)
- Device.WaitIdle() and Device.ResetCommandPool() methods
- Updated naga v0.8.3 → v0.8.4 (SPIR-V instruction ordering)
- Code quality: linter fixes, type switches, nolint directives
@kolkov kolkov merged commit 51722cf into main Jan 10, 2026
20 checks passed
@kolkov kolkov deleted the feat/intel-vulkan-fixes branch January 10, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants