[PR #2405] d3d12: check sparse buffer memory_types before sharing the tile arena #2405

Open
opened 2026-11-26 22:31:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2405
Author: @pepefroge
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/intel-sparse-buffer-heap


📝 Commits (1)

  • f0b86e1 d3d12: check sparse buffer memory_types before sharing the tile arena

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 runtime/shims/d3d12_vulkan_device.cpp (+2 -2)

📄 Description

Summary

Fixes D3D12→Vulkan sparse buffer tile mappings failing with ID3D12CommandQueue::UpdateTileMappings: invalid mapping or sparse residency unavailable on Intel Arc (reported in #725).

Root Cause

  • DeviceState::tiles_share_arena() (runtime/shims/d3d12_vulkan_device.cpp:3536) only checks whether arena.memory_type overlaps the device-init probe sparse_buffer_memory_types.
  • On Intel Arc Windows Vulkan drivers (32.0.101.9150), an actual reserved buffer's requirements.memoryTypeBits can exclude arena.memory_type (e.g., requiring non-ReBAR DEVICE_LOCAL memory rather than the arena's DEVICE_LOCAL | HOST_VISIBLE type).
  • Heap::tiles() (line 9625) still took the arena fast-path, causing VulkanQueue::bind_tiles() (runtime/src/vulkan_backend.h:4164) to reject the binding (!(resource->memory_types & (1u << page.heap->memory_type))).
  • Additionally, Heap::tiles() (line 9636) previously overwrote the caller's memory_types with sparse_buffer_memory_types unconditionally instead of intersecting when overlapping.

Changes

  • Guard the arena fast-path in Heap::tiles() (runtime/shims/d3d12_vulkan_device.cpp:9625) with (memory_types & (1u << device_.arena.memory_type)).
  • Narrow memory_types via &= (line 9636) only when it overlaps device_.sparse_buffer_memory_types, preserving the caller's memoryTypeBits otherwise.

Verification (Intel Arc Pro B60, BMG-G21, Driver 32.0.101.9150)

  • Before: d3d12_buffer_tiles_test failed UpdateTileMappings on every mapped buffer tile (0/12 tiles).
  • After (f0b86e1):
    Vulkan replay: 12 full tiles matched across aliased, skipped, unmapped, reused and remapped ranges
    A rejected update left all tile mappings intact
    
    (Note: the subsequent native D3D12 comparison pass in d3d12_buffer_tiles_test still hits Intel's native D3D12 driver CopyTiles behavior noted in #725, while the Vulkan replay side now passes 12/12 tiles).

Tested on Intel Arc Pro B60 (0xe211, Windows 11, driver 32.0.101.9150); root-cause trace assisted locally via Hermes + Qwen 3.8 27B.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2405 **Author:** [@pepefroge](https://github.com/pepefroge) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/intel-sparse-buffer-heap` --- ### 📝 Commits (1) - [`f0b86e1`](https://github.com/ubiquitarianism/leonida/commit/f0b86e19380c8af09569161e1a0bc0243125a738) d3d12: check sparse buffer memory_types before sharing the tile arena ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+2 -2) </details> ### 📄 Description ### Summary Fixes D3D12→Vulkan sparse buffer tile mappings failing with `ID3D12CommandQueue::UpdateTileMappings: invalid mapping or sparse residency unavailable` on Intel Arc (reported in #725). ### Root Cause - `DeviceState::tiles_share_arena()` (`runtime/shims/d3d12_vulkan_device.cpp:3536`) only checks whether `arena.memory_type` overlaps the device-init probe `sparse_buffer_memory_types`. - On Intel Arc Windows Vulkan drivers (`32.0.101.9150`), an actual reserved buffer's `requirements.memoryTypeBits` can exclude `arena.memory_type` (e.g., requiring non-ReBAR `DEVICE_LOCAL` memory rather than the arena's `DEVICE_LOCAL | HOST_VISIBLE` type). - `Heap::tiles()` (`line 9625`) still took the arena fast-path, causing `VulkanQueue::bind_tiles()` (`runtime/src/vulkan_backend.h:4164`) to reject the binding (`!(resource->memory_types & (1u << page.heap->memory_type))`). - Additionally, `Heap::tiles()` (`line 9636`) previously overwrote the caller's `memory_types` with `sparse_buffer_memory_types` unconditionally instead of intersecting when overlapping. ### Changes - Guard the arena fast-path in `Heap::tiles()` (`runtime/shims/d3d12_vulkan_device.cpp:9625`) with `(memory_types & (1u << device_.arena.memory_type))`. - Narrow `memory_types` via `&=` (`line 9636`) only when it overlaps `device_.sparse_buffer_memory_types`, preserving the caller's `memoryTypeBits` otherwise. ### Verification (Intel Arc Pro B60, BMG-G21, Driver `32.0.101.9150`) - Before: `d3d12_buffer_tiles_test` failed `UpdateTileMappings` on every mapped buffer tile (`0/12` tiles). - After (`f0b86e1`): ```text Vulkan replay: 12 full tiles matched across aliased, skipped, unmapped, reused and remapped ranges A rejected update left all tile mappings intact ``` *(Note: the subsequent native D3D12 comparison pass in `d3d12_buffer_tiles_test` still hits Intel's native D3D12 driver `CopyTiles` behavior noted in #725, while the Vulkan replay side now passes 12/12 tiles).* --- *Tested on Intel Arc Pro B60 (`0xe211`, Windows 11, driver `32.0.101.9150`); root-cause trace assisted locally via Hermes + Qwen 3.8 27B.* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2405
No description provided.