🆕 Package runtimes from the organization dependency pins [skip ci]
Read the source URLs and revisions directly from the selected runtime. Retire the six patches now in the organization forks and record the resolved URLs in the manifest and source package.
This commit is contained in:
1 parent
28457772f4
commit
4f7c54c458
11 files changed
+87
-2373
No files matched your search
@@ -128,31 +128,22 @@ jobs:
|
||||
git -C $work submodule update --init --depth 1 vendor/qemu
|
||||
if ($LASTEXITCODE) { git -C $work submodule update --init vendor/qemu }
|
||||
if ($LASTEXITCODE) { throw 'vendor/qemu submodule failed' }
|
||||
$utilRepo = Join-Path $env:RUNNER_TEMP 'reims-util'
|
||||
$utilPin = Get-Content -Raw -LiteralPath (Join-Path $work 'crates/reims-ctl/src/reims_util.rs')
|
||||
if ($utilPin -notmatch 'pub const REV: &str = "([0-9a-f]{40})"') { throw 'reims-util REV not found' }
|
||||
$utilRev = $Matches[1]
|
||||
git init -q $utilRepo
|
||||
if ($LASTEXITCODE) { throw 'reims-util init failed' }
|
||||
git -C $utilRepo fetch -q --depth 1 https://github.com/steelbrain/reims-util.git $utilRev
|
||||
if ($LASTEXITCODE) { throw 'reims-util fetch failed' }
|
||||
git -C $utilRepo checkout -q --detach FETCH_HEAD
|
||||
if ($LASTEXITCODE) { throw 'reims-util checkout failed' }
|
||||
$m2vRepo = Join-Path $env:RUNNER_TEMP 'metal2vulkan'
|
||||
$cargoToml = Get-Content -Raw -LiteralPath (Join-Path $work 'Cargo.toml')
|
||||
if ($cargoToml -match 'metal2vulkan\s*=\s*\{[^}]*rev\s*=\s*"([0-9a-f]{40})"') {
|
||||
$m2vRev = $Matches[1]
|
||||
} else {
|
||||
$lockTxt = Get-Content -Raw -LiteralPath (Join-Path $work 'Cargo.lock')
|
||||
if ($lockTxt -notmatch 'metal2vulkan\?rev=([0-9a-f]{40})') { throw 'metal2vulkan rev not found in Cargo.toml or Cargo.lock' }
|
||||
$m2vRev = $Matches[1]
|
||||
$pins = & ./packaging/windows-runtime/scripts/read-runtime-dependencies.ps1 -RuntimeRepo $work
|
||||
function Get-DependencyCheckout($pin, [string]$path) {
|
||||
git init -q $path
|
||||
if ($LASTEXITCODE) { throw "Could not initialize $path" }
|
||||
git -C $path remote add origin $pin.Url
|
||||
if ($LASTEXITCODE) { throw "Could not add origin for $path" }
|
||||
git -C $path fetch -q --depth 1 origin $pin.Rev
|
||||
if ($LASTEXITCODE) { throw "Could not fetch $($pin.Url)@$($pin.Rev)" }
|
||||
git -C $path checkout -q --detach $pin.Rev
|
||||
if ($LASTEXITCODE) { throw "Could not check out $($pin.Url)@$($pin.Rev)" }
|
||||
Write-Host "Using $($pin.Url)@$($pin.Rev)"
|
||||
}
|
||||
git init -q $m2vRepo
|
||||
if ($LASTEXITCODE) { throw 'metal2vulkan init failed' }
|
||||
git -C $m2vRepo fetch -q --depth 1 https://github.com/steelbrain/metal2vulkan.git $m2vRev
|
||||
if ($LASTEXITCODE) { throw 'metal2vulkan fetch failed' }
|
||||
git -C $m2vRepo checkout -q --detach FETCH_HEAD
|
||||
if ($LASTEXITCODE) { throw 'metal2vulkan checkout failed' }
|
||||
$utilRepo = Join-Path $env:RUNNER_TEMP 'reims-util'
|
||||
$m2vRepo = Join-Path $env:RUNNER_TEMP 'metal2vulkan'
|
||||
Get-DependencyCheckout $pins.Util $utilRepo
|
||||
Get-DependencyCheckout $pins.Metal $m2vRepo
|
||||
$short = (git -C $work rev-parse --short=7 HEAD).Trim()
|
||||
|
||||
# Applies what applies, skips what upstream already has, stops on a
|
||||
@@ -170,13 +161,17 @@ jobs:
|
||||
}
|
||||
if (-not $ok) { throw 'patch queue does not apply' }
|
||||
$cargoHome = Join-Path $env:RUNNER_TEMP 'cargo'
|
||||
$m2vFwd = $m2vRepo.Replace('\', '/')
|
||||
$cargoCfg = @"
|
||||
[patch."https://github.com/steelbrain/metal2vulkan"]
|
||||
$m2vChanges = git -C $m2vRepo status --porcelain
|
||||
if ($LASTEXITCODE) { throw 'Could not read metal2vulkan checkout status' }
|
||||
if ($m2vChanges) {
|
||||
$m2vFwd = $m2vRepo.Replace('\', '/')
|
||||
$cargoCfg = @"
|
||||
[patch."$($pins.Metal.Url)"]
|
||||
metal2vulkan = { path = "$m2vFwd/crates/metal2vulkan" }
|
||||
metal2vulkan-runtime = { path = "$m2vFwd/crates/metal2vulkan-runtime" }
|
||||
"@ -replace '(?m)^ ', ''
|
||||
[IO.File]::WriteAllText((Join-Path $cargoHome 'config.toml'), ($cargoCfg.Replace("`r`n", "`n") + "`n"), [Text.UTF8Encoding]::new($false))
|
||||
"@
|
||||
[IO.File]::WriteAllText((Join-Path $cargoHome 'config.toml'), ($cargoCfg.Replace("`r`n", "`n") + "`n"), [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
"REIMS_UTIL_DIR=$utilRepo" >> $env:GITHUB_ENV
|
||||
"METAL2VULKAN_DIR=$m2vRepo" >> $env:GITHUB_ENV
|
||||
"SHORT_COMMIT=$short" >> $env:GITHUB_ENV
|
||||
|
||||
@@ -6,25 +6,16 @@
|
||||
| :--- | :--- | :--- |
|
||||
| Reims vGPU | [`reims-go/reims-vgpu`](https://github.com/reims-go/reims-vgpu/tree/intel-vm-suspend) | GPU 挂起重放、窗口和 CLI 兼容性修复 |
|
||||
| QEMU | [`reims-go/qemu-reims-vgpu`](https://github.com/reims-go/qemu-reims-vgpu/tree/intel-vm-suspend) | Windows WHPX、文件迁移和设备状态保存恢复 |
|
||||
| metal2vulkan | [`reims-go/metal2vulkan`](https://github.com/reims-go/metal2vulkan/tree/development) | Vulkan 渲染、附件反馈和 GPU 地址重放 |
|
||||
| reims-util | [`reims-go/reims-util`](https://github.com/reims-go/reims-util/tree/development) | OpenCore 和 macOS 安装介质,包括并发离线下载 |
|
||||
|
||||
Reims vGPU 分支通过 `vendor/qemu` 固定 QEMU 提交,并在 `reims-go-runtime.json` 声明运行时能力。更新 QEMU 时先把新提交推到 QEMU fork,再更新 Reims vGPU 的子模块指针。Reims-Go 构建据此记录两个源码仓库及提交号。
|
||||
Reims vGPU 用 `vendor/qemu` 固定 QEMU 提交,用 `Cargo.toml` 和 `Cargo.lock` 固定 metal2vulkan,用 `crates/reims-ctl/src/reims_util.rs` 固定 reims-util。CI 根据这些固定值检出依赖,在运行时清单和对应源码包中记录四个组件的仓库及实际提交。
|
||||
|
||||
Alpha 编号与挂起兼容判定见 [Alpha 运行时编号与挂起兼容性规范](../versioning.md)。
|
||||
|
||||
## 构建时应用的依赖补丁
|
||||
|
||||
[`series.txt`](series.txt) 是可执行清单。依赖检出版本由 Reims vGPU 源码固定。补丁冲突会停止构建。
|
||||
|
||||
| 补丁 | 依赖 | 作用 |
|
||||
| :--- | :--- | :--- |
|
||||
| [`reims-util-parallel-offline-download.patch`](reims-util-parallel-offline-download.patch) | `steelbrain/reims-util` | 有 Apple 分块校验数据时并发下载离线安装包,按顺序验证并写入镜像。 |
|
||||
| [`metal2vulkan-snapshot-replay.patch`](metal2vulkan-snapshot-replay.patch) | `steelbrain/metal2vulkan` | 读取和恢复缓冲、纹理及事件状态,为 GPU 挂起重放提供依赖。 |
|
||||
| [`metal2vulkan-psb-address-carry.patch`](metal2vulkan-psb-address-carry.patch) | `steelbrain/metal2vulkan` | 恢复 64 位 GPU 地址时显式处理低位进位。 [组织 fork 提交](https://github.com/reims-go/metal2vulkan/commit/729d91d23bb56a99f2b5b74d3d3445c65cc1cdf1) |
|
||||
| [`metal2vulkan-dynamic-attachment-feedback.patch`](metal2vulkan-dynamic-attachment-feedback.patch) | `steelbrain/metal2vulkan` | 原生附件反馈要求设备同时报告反馈布局和动态反馈能力,其余设备通过影子纹理读取附件。 [组织 fork 提交](https://github.com/reims-go/metal2vulkan/commit/ea695f945626f15c27ac9b463ba4160c65530b43) |
|
||||
| [`metal2vulkan-static-attachment-feedback.patch`](metal2vulkan-static-attachment-feedback.patch) | `steelbrain/metal2vulkan` | 保留上述能力要求,以静态颜色附件反馈管线替代逐 draw 切换动态状态,修复桌面暗屏。 |
|
||||
| [`metal2vulkan-places-texture-pool.patch`](metal2vulkan-places-texture-pool.patch) | `steelbrain/metal2vulkan` | 将 `Places` 纹理分配与可重放缓冲区分开。挂起恢复仍可按捕获地址重建缓冲区。 |
|
||||
|
||||
构建通过 Cargo 的本地源码覆盖使用已打补丁的 `metal2vulkan`。客户端的运行时包格式见[便携运行时规范](https://github.com/Nwflower/Reims-Go/blob/main/docs/portable-runtime-spec.md)。
|
||||
[`series.txt`](series.txt) 目前为空。临时补丁按清单顺序应用,冲突会停止构建。客户端的运行时包格式见[便携运行时规范](https://github.com/Nwflower/Reims-Go/blob/main/docs/portable-runtime-spec.md)。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,590 +0,0 @@
|
||||
diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md
|
||||
index f7bc4b6c2..083011698 100644
|
||||
--- a/crates/metal2vulkan-runtime/README.md
|
||||
+++ b/crates/metal2vulkan-runtime/README.md
|
||||
@@ -4710,10 +4710,8 @@ cache is answered compile-required on both.
|
||||
from the layout the pass renders it in, the rest from home), and the rendering begins again
|
||||
with the attachment in that layout; the pass's second barrier moves the whole image home. Until then every draw of the
|
||||
pass reads the image's textures through their second elements (Set 1), a texture that reaches
|
||||
- no rendered level among them. Every render pipeline is made with the feedback loop's colour
|
||||
- flag (`VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT`), which lets a draw read an
|
||||
- attachment in the feedback layout and asks nothing of a draw that reads none, so no draw records
|
||||
- a state for the loop. Each draw that
|
||||
+ no rendered level among them. Render pipelines declare `VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT`;
|
||||
+ the encoder enables color feedback while an attachment is in the feedback layout. Each draw that
|
||||
reads an attachment through the loop, through a texture or by a fetch (below), counts in
|
||||
`Metrics::attachment_loop_reads`, its barriers in `Metrics::barriers`.
|
||||
- Through a copy, on a device without the feedback loop, and for a surface plane whose image took
|
||||
@@ -5087,9 +5085,8 @@ cache is answered compile-required on both.
|
||||
same draws into a target of render-target usage alone take the same time either way. The loop's
|
||||
flag on every render pipeline costs no time measured there (m3-max-72033) or on RADV
|
||||
(m3-max-72020).
|
||||
-- On a device that does not report `attachmentFeedbackLoopLayout` (expected of the UHD 630
|
||||
- among the lab's, Windows driver 101.2145: no public report of that card on Windows lists
|
||||
- `VK_EXT_attachment_feedback_loop_layout`), a draw reads an attachment through a copy into the image's shadow, which Metal does not make: at
|
||||
+- On a device without the feedback layout or its dynamic state, a draw reads an attachment
|
||||
+ through a copy into the image's shadow, which Metal does not make: at
|
||||
the pass's first draw that reads the image, at the first after a memory barrier after draws,
|
||||
and where a draw reads what the shadow does not hold, the rendering ended and begun again
|
||||
around the copies and their two barriers; where the draw is the pass's first and reads only
|
||||
@@ -5496,7 +5493,8 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
|
||||
| `VK_EXT_shader_stencil_export` | device, where listed | a fragment function's `[[stencil]]` output as the fragment's stencil reference (`FragStencilRefEXT`); a device without it draws the output by bits (the known gaps); RADV, ANV, lavapipe, KosmicKrisp and the UHD 630's Windows driver list it, NVIDIA's 615 and 620 drivers do not |
|
||||
| `VK_KHR_portability_enumeration` | instance, where offered | listing portability devices, each checked against the floor as any other |
|
||||
| `VK_KHR_portability_subset` | device, where listed | Vulkan requires it enabled where a device lists it; the device is asked for the portability features below |
|
||||
-| `VK_EXT_attachment_feedback_loop_layout` | device, with the feedback loop | a draw's read of an attachment of its own pass through a texture, in the feedback layout, with the colour flag every render pipeline takes (below) |
|
||||
+| `VK_EXT_attachment_feedback_loop_layout` | device, with the feedback loop | a draw's read of an attachment of its own pass through a texture in the feedback layout |
|
||||
+| `VK_EXT_attachment_feedback_loop_dynamic_state` | device, with the feedback loop | enables feedback for the color aspect while an attachment is in the feedback layout |
|
||||
| `VK_KHR_vertex_attribute_divisor` | device, where listed | a vertex layout stepped per instance at a rate above 1, through the step-rate feature below |
|
||||
| `VK_EXT_vertex_attribute_divisor` | device, where listed | the same, on a device that lists only this extension, which the KHR was promoted from with the same feature and pipeline structures |
|
||||
| `VK_EXT_external_memory_host` | device, where listed | importing host memory by its address (`Device::import_host_memory`) |
|
||||
@@ -5840,16 +5838,14 @@ second elements beside the floor's arrays: 65,536 sampled images more than the l
|
||||
`maxUpdateAfterBindDescriptorsInAllPools`); a device without them refuses such a draw
|
||||
(`Gap::Draw` of `DrawKind::AttachmentRead`), and is otherwise the same
|
||||
(`floor::Capabilities::attachment_reads`). The draw reads through the attachment feedback loop
|
||||
-where the device also lists the extension marked "with the feedback loop" above and reports the
|
||||
-feature below, which device creation then enables, and neither otherwise
|
||||
-(`floor::Capabilities::feedback_loop`). A device that reads attachments without them reads
|
||||
-through a copy of the image into its shadow (Render encoders), a known gap. AMD's Windows driver
|
||||
-is expected to take the loop, not verified in the lab (public reports of it list
|
||||
-`VK_EXT_attachment_feedback_loop_layout` from 2.0.250 on).
|
||||
+where the device lists both extensions marked "with the feedback loop" and reports both features
|
||||
+below (`floor::Capabilities::feedback_loop`). A device without these capabilities reads through
|
||||
+a copy of the image into its shadow (Render encoders), a known gap.
|
||||
|
||||
| Attachment-read feature | Structure | Used for |
|
||||
|---|---|---|
|
||||
| `attachmentFeedbackLoopLayout` | `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT` | the feedback layout and usage |
|
||||
+| `attachmentFeedbackLoopDynamicState` | `VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT` | enables feedback for the color aspect at draw time |
|
||||
|
||||
### Bound kernel buffers
|
||||
|
||||
diff --git a/crates/metal2vulkan-runtime/src/device.rs b/crates/metal2vulkan-runtime/src/device.rs
|
||||
--- a/crates/metal2vulkan-runtime/src/device.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/device.rs
|
||||
@@ -269,10 +269,8 @@
|
||||
pub(crate) ticks: Ticks,
|
||||
/// `VK_EXT_calibrated_timestamps`, the floor's: the GPU's clock read with the host's.
|
||||
pub(crate) calibrated: ash::ext::calibrated_timestamps::Device,
|
||||
- /// Device creation enabled the attachment feedback loop (`floor::Capabilities::feedback_loop`):
|
||||
- /// every render pipeline takes its colour flag, and a draw reads an attachment of its pass
|
||||
- /// with the image in the feedback layout.
|
||||
- pub(crate) feedback_loop: bool,
|
||||
+ /// Device entry points for dynamic attachment feedback (`floor::Capabilities::feedback_loop`).
|
||||
+ pub(crate) feedback_loop: Option<ash::ext::attachment_feedback_loop_dynamic_state::Device>,
|
||||
pub(crate) capture_replay: bool,
|
||||
/// `VK_EXT_device_fault`'s command, where device creation enabled it (where the device lists
|
||||
/// it): a lost device's fault report, read once, at its first loss (`crate::fault`).
|
||||
@@ -600,6 +598,7 @@
|
||||
mut robustness2,
|
||||
mut portability,
|
||||
mut feedback_loop,
|
||||
+ mut feedback_dynamic,
|
||||
mut divisor,
|
||||
mut border_swizzle,
|
||||
mut linear_attachment,
|
||||
@@ -654,7 +653,9 @@
|
||||
features = features.push_next(&mut portability);
|
||||
}
|
||||
if capabilities.feedback_loop {
|
||||
- features = features.push_next(&mut feedback_loop);
|
||||
+ features = features
|
||||
+ .push_next(&mut feedback_loop)
|
||||
+ .push_next(&mut feedback_dynamic);
|
||||
}
|
||||
if enabled(ash::khr::vertex_attribute_divisor::NAME)
|
||||
|| enabled(ash::ext::vertex_attribute_divisor::NAME)
|
||||
@@ -844,6 +845,9 @@
|
||||
alignment,
|
||||
);
|
||||
let submit_calls = Arc::new(SubmitCalls::new(counters.clone()));
|
||||
+ let feedback_loop = capabilities.feedback_loop.then(|| {
|
||||
+ ash::ext::attachment_feedback_loop_dynamic_state::Device::new(vk_instance, &device)
|
||||
+ });
|
||||
let live = instance.teardowns().live();
|
||||
let core = Arc::new(Core {
|
||||
instance,
|
||||
@@ -860,7 +864,7 @@
|
||||
counters,
|
||||
ticks,
|
||||
calibrated,
|
||||
- feedback_loop: capabilities.feedback_loop,
|
||||
+ feedback_loop,
|
||||
capture_replay: capabilities.buffer_device_address_capture_replay,
|
||||
fault,
|
||||
indirect,
|
||||
diff --git a/crates/metal2vulkan-runtime/src/floor.rs b/crates/metal2vulkan-runtime/src/floor.rs
|
||||
index 0e165934f..f598f0f93 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/floor.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/floor.rs
|
||||
@@ -134,14 +134,14 @@ const _: () = {
|
||||
assert!(offset_of!(Maintenance8Features, maintenance8) == 16);
|
||||
};
|
||||
|
||||
-/// The device extension of the attachment feedback loop (`VK_EXT_attachment_feedback_loop_layout`),
|
||||
-/// through which a draw reads, through a texture, an attachment its own pass renders (Metal's
|
||||
-/// texture read of a render target): its layout, its image usage and its pipeline flag, which every
|
||||
-/// render pipeline takes. Device creation enables it, with its feature, where the device reads
|
||||
-/// attachments (`Capabilities::attachment_reads`), lists it and reports the feature, and not
|
||||
-/// otherwise. A device that reads attachments without it reads through a copy of the image
|
||||
-/// (`Capabilities::feedback_loop`).
|
||||
-pub const ATTACHMENT_READ_EXTENSIONS: &[&CStr] = &[ash::ext::attachment_feedback_loop_layout::NAME];
|
||||
+/// The device extensions for reading an attachment of the current pass in the feedback layout,
|
||||
+/// with feedback enabled dynamically for its color aspect. Device creation enables both
|
||||
+/// extensions and both features where the device reads attachments and supports them.
|
||||
+/// Otherwise, attachment reads use the image's shadow (`Capabilities::feedback_loop`).
|
||||
+pub const ATTACHMENT_READ_EXTENSIONS: &[&CStr] = &[
|
||||
+ ash::ext::attachment_feedback_loop_layout::NAME,
|
||||
+ ash::ext::attachment_feedback_loop_dynamic_state::NAME,
|
||||
+];
|
||||
|
||||
/// The device extension of a sampler's border colour through a view's component mapping
|
||||
/// (`VK_EXT_border_color_swizzle`), after `VK_EXT_custom_border_color`, which it requires and of
|
||||
@@ -399,6 +399,8 @@ pub struct Features {
|
||||
/// `VK_EXT_attachment_feedback_loop_layout`: read where the device lists it, and enabled where
|
||||
/// the device reads attachments through the feedback loop alone.
|
||||
pub feedback_loop: vk::PhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT<'static>,
|
||||
+ /// Dynamic feedback state, queried and enabled with the feedback layout when available.
|
||||
+ pub feedback_dynamic: vk::PhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT<'static>,
|
||||
/// `VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR`, of `VK_KHR_vertex_attribute_divisor`
|
||||
/// and `VK_EXT_vertex_attribute_divisor` (the same structure): read and enabled only where the
|
||||
/// device lists one of them, and then only the step-rate feature.
|
||||
@@ -477,6 +479,9 @@ macro_rules! feature {
|
||||
(@structure feedback_loop) => {
|
||||
"VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT"
|
||||
};
|
||||
+ (@structure feedback_dynamic) => {
|
||||
+ "VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT"
|
||||
+ };
|
||||
(@structure divisor) => {
|
||||
"VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR"
|
||||
};
|
||||
@@ -715,11 +720,11 @@ pub(crate) const OPTIONAL: &[Feature] = &[
|
||||
feature!(maintenance8.maintenance8 => Maintenance8),
|
||||
];
|
||||
|
||||
-/// The feature of the attachment feedback loop ([`ATTACHMENT_READ_EXTENSIONS`]): enabled where the
|
||||
-/// device reads attachments and reports it, and not otherwise; a device that reads attachments
|
||||
-/// without it reads through a copy of the image.
|
||||
-pub(crate) const ATTACHMENT_READS: &[Feature] =
|
||||
- &[feature!(feedback_loop.attachment_feedback_loop_layout => AttachmentFeedbackLoopLayout)];
|
||||
+/// The features needed for native attachment feedback ([`ATTACHMENT_READ_EXTENSIONS`]).
|
||||
+pub(crate) const ATTACHMENT_READS: &[Feature] = &[
|
||||
+ feature!(feedback_loop.attachment_feedback_loop_layout => AttachmentFeedbackLoopLayout),
|
||||
+ feature!(feedback_dynamic.attachment_feedback_loop_dynamic_state),
|
||||
+];
|
||||
|
||||
/// The features device creation enables where the device reports them, for Metal's per-instance
|
||||
/// step at a rate above 1, which the translator builds in one form, a binding's divisor, and
|
||||
@@ -1231,6 +1236,8 @@ unsafe fn query(
|
||||
let robustness2_listed = listed(ash::ext::robustness2::NAME);
|
||||
let portability_listed = listed(ash::khr::portability_subset::NAME);
|
||||
let feedback_loop_listed = listed(ash::ext::attachment_feedback_loop_layout::NAME);
|
||||
+ let feedback_dynamic_listed =
|
||||
+ listed(ash::ext::attachment_feedback_loop_dynamic_state::NAME);
|
||||
let divisor_listed = listed(ash::khr::vertex_attribute_divisor::NAME)
|
||||
|| listed(ash::ext::vertex_attribute_divisor::NAME);
|
||||
let border_swizzle_listed = listed(ash::ext::border_color_swizzle::NAME);
|
||||
@@ -1254,6 +1261,7 @@ unsafe fn query(
|
||||
robustness2,
|
||||
portability,
|
||||
feedback_loop,
|
||||
+ feedback_dynamic,
|
||||
divisor,
|
||||
border_swizzle,
|
||||
linear_attachment,
|
||||
@@ -1292,6 +1300,9 @@ unsafe fn query(
|
||||
if feedback_loop_listed {
|
||||
features = features.push_next(&mut *feedback_loop);
|
||||
}
|
||||
+ if feedback_dynamic_listed {
|
||||
+ features = features.push_next(&mut *feedback_dynamic);
|
||||
+ }
|
||||
if divisor_listed {
|
||||
features = features.push_next(&mut *divisor);
|
||||
}
|
||||
@@ -1332,6 +1343,7 @@ unsafe fn query(
|
||||
robustness2.p_next = std::ptr::null_mut();
|
||||
portability.p_next = std::ptr::null_mut();
|
||||
feedback_loop.p_next = std::ptr::null_mut();
|
||||
+ feedback_dynamic.p_next = std::ptr::null_mut();
|
||||
divisor.p_next = std::ptr::null_mut();
|
||||
border_swizzle.p_next = std::ptr::null_mut();
|
||||
linear_attachment.p_next = std::ptr::null_mut();
|
||||
diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs
|
||||
index 8d9480c8f..89ceff148 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/render.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/render.rs
|
||||
@@ -232,12 +232,6 @@ pub(crate) struct RenderCompiled {
|
||||
stages: Vec<Module>,
|
||||
/// The fixed-function state every `VkPipeline` of the content takes.
|
||||
fixed: Fixed,
|
||||
- /// The create flags every `VkPipeline` of the content takes: the feedback loop's colour flag
|
||||
- /// where device creation enabled the attachment feedback loop (`Core::feedback_loop`), and
|
||||
- /// none otherwise. A state is made before any draw binds its textures, and which texture a
|
||||
- /// draw binds decides whether it reads an attachment of its pass, so every pipeline takes it;
|
||||
- /// a draw that reads none is valid with it.
|
||||
- pub(crate) flags: vk::PipelineCreateFlags,
|
||||
/// The content's main `VkPipeline`: the triangle class's, or a post-tessellation vertex
|
||||
/// function's patch class's, its only class, at the default [`Raster`].
|
||||
primary: Main,
|
||||
@@ -1283,10 +1277,6 @@ impl RenderCompiled {
|
||||
core: Arc::clone(core),
|
||||
stages,
|
||||
fixed: Fixed::of(&pipeline),
|
||||
- flags: match core.feedback_loop {
|
||||
- true => vk::PipelineCreateFlags::COLOR_ATTACHMENT_FEEDBACK_LOOP_EXT,
|
||||
- false => vk::PipelineCreateFlags::empty(),
|
||||
- },
|
||||
primary: Main::default(),
|
||||
named: named.map(|list| (list, Main::default())),
|
||||
later: Mutex::new(Vec::new()),
|
||||
@@ -1523,6 +1513,11 @@ impl RenderCompiled {
|
||||
.discard
|
||||
.then_some(vk::DynamicState::RASTERIZER_DISCARD_ENABLE),
|
||||
)
|
||||
+ .chain(
|
||||
+ core.feedback_loop
|
||||
+ .as_ref()
|
||||
+ .map(|_| vk::DynamicState::ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT),
|
||||
+ )
|
||||
.collect();
|
||||
let dynamic_states = vk::PipelineDynamicStateCreateInfo::default().dynamic_states(&states);
|
||||
let mut rendering = vk::PipelineRenderingCreateInfo::default()
|
||||
@@ -1530,7 +1525,6 @@ impl RenderCompiled {
|
||||
.depth_attachment_format(fixed.depth)
|
||||
.stencil_attachment_format(fixed.stencil);
|
||||
let mut info = vk::GraphicsPipelineCreateInfo::default()
|
||||
- .flags(self.flags)
|
||||
.push_next(&mut rendering)
|
||||
.stages(&stages)
|
||||
.vertex_input_state(&vertex_input)
|
||||
diff --git a/crates/metal2vulkan-runtime/src/render_encoder.rs b/crates/metal2vulkan-runtime/src/render_encoder.rs
|
||||
index 88405a427..bd43630a4 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/render_encoder.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/render_encoder.rs
|
||||
@@ -34,9 +34,8 @@
|
||||
//! attachment layout, the rest from home), and the rendering begins again with the attachment in
|
||||
//! that layout; the pass's second barrier moves the whole image home. While it is there, every
|
||||
//! draw of the pass reads the image's textures through their elements in that layout
|
||||
-//! (`crate::arrays`). Every render pipeline is made with the feedback loop's colour flag
|
||||
-//! (`VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT`), so any draw may read an
|
||||
-//! attachment in the feedback layout and a draw that reads none needs nothing set.
|
||||
+//! (`crate::arrays`). Render pipelines declare dynamic feedback state. The encoder enables
|
||||
+//! color feedback for draws while an attachment is in the feedback layout.
|
||||
//!
|
||||
//! What such a draw reads that an earlier draw of the pass rendered, Metal orders by a memory
|
||||
//! barrier between the two. A memory barrier after draws that wrote no memory, where the pass
|
||||
@@ -2742,6 +2741,14 @@ impl RenderCommandEncoder {
|
||||
core.device.cmd_set_rasterizer_discard_enable(command, true);
|
||||
}
|
||||
}
|
||||
+ if let Some(feedback) = &core.feedback_loop {
|
||||
+ let aspects = if self.moved.is_empty() {
|
||||
+ vk::ImageAspectFlags::empty()
|
||||
+ } else {
|
||||
+ vk::ImageAspectFlags::COLOR
|
||||
+ };
|
||||
+ (feedback.fp().cmd_set_attachment_feedback_loop_enable_ext)(command, aspects);
|
||||
+ }
|
||||
self.record_state(topology, restart, hidden);
|
||||
// A mode's query begins at its first draw, after what that draw ended the rendering
|
||||
// to record first: the command buffer is inside the pass's rendering, and keeps the
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/device.rs b/crates/metal2vulkan-runtime/src/tests/device.rs
|
||||
index 8d9a1eb60..4e147bdef 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/device.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/device.rs
|
||||
@@ -426,7 +426,7 @@ fn every_device_of_the_cfgs_kind_enables_the_consumers_extensions_it_offers() {
|
||||
.filter(|&name| lists(name)),
|
||||
);
|
||||
// The attachment reads' extensions, where device creation took them.
|
||||
- if device.core().feedback_loop {
|
||||
+ if device.core().feedback_loop.is_some() {
|
||||
expected.extend(floor::ATTACHMENT_READ_EXTENSIONS);
|
||||
}
|
||||
// The border swizzle's, where the device reports it from the image.
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/draw.rs b/crates/metal2vulkan-runtime/src/tests/draw.rs
|
||||
index 406179311..a7601ae11 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/draw.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/draw.rs
|
||||
@@ -2902,7 +2902,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
(device.grant_indices(IndexClass::Texture, 4096, 4))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let reads = device.core().attachment_reads;
|
||||
- let looped = device.core().feedback_loop;
|
||||
+ let looped = device.core().feedback_loop.is_some();
|
||||
let plain = state(name, &device, &plain);
|
||||
let mut buffers = Buffers::new(&device);
|
||||
// Three triangles over the whole target, their colors none, blue and green.
|
||||
@@ -3065,41 +3065,22 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
});
|
||||
}
|
||||
|
||||
- /// Where device creation enabled the attachment feedback loop, every render pipeline takes the
|
||||
- /// loop's colour flag, `VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT`: that of a
|
||||
- /// fragment function that reads no texture as much as that of one that reads its pass's
|
||||
- /// attachment through one, since a state is made before any draw binds its textures. A
|
||||
- /// device without the loop makes them with no flag. Then, through the loop, a pass draws with
|
||||
- /// both after the first reads the attachment, and the second writes it: every pixel is the
|
||||
- /// second's.
|
||||
+ /// A draw can sample its attachment with dynamic feedback enabled. The following draw can
|
||||
+ /// bind a different pipeline and write to the same attachment in the feedback layout.
|
||||
#[test]
|
||||
- fn every_device_makes_every_render_pipeline_with_the_loop_s_flag_where_it_has_the_loop() {
|
||||
- use ash::vk;
|
||||
+ fn a_draw_reads_an_attachment_with_dynamic_feedback() {
|
||||
let Some(library) = examples() else {
|
||||
return;
|
||||
};
|
||||
let plain = descriptor(&library, "colored_fragment", PixelFormat::RGBA8Unorm);
|
||||
let own = descriptor(&library, "own_pixel_fragment", PixelFormat::RGBA8Unorm);
|
||||
- each_device("loop_flags", |name, _, device| {
|
||||
- let looped = device.core().feedback_loop;
|
||||
- let want = match looped {
|
||||
- true => vk::PipelineCreateFlags::COLOR_ATTACHMENT_FEEDBACK_LOOP_EXT,
|
||||
- false => vk::PipelineCreateFlags::empty(),
|
||||
- };
|
||||
- let plain = state(name, &device, &plain);
|
||||
- let reading = state(name, &device, &own);
|
||||
- for (what, state) in [("reading no texture", &plain), ("reading one", &reading)] {
|
||||
- // Raw: ash's flag types are not `Debug` under the features the runtime takes.
|
||||
- assert_eq!(
|
||||
- state.inner.compiled.flags.as_raw(),
|
||||
- want.as_raw(),
|
||||
- "{name}: a state's pipelines {what}, the loop {looped}"
|
||||
- );
|
||||
- }
|
||||
- if !looped {
|
||||
- println!("{name}: no feedback loop; every render pipeline made with no flag");
|
||||
+ each_device("dynamic_feedback", |name, _, device| {
|
||||
+ if device.core().feedback_loop.is_none() {
|
||||
+ println!("{name}: no dynamic attachment feedback support");
|
||||
return;
|
||||
}
|
||||
+ let plain = state(name, &device, &plain);
|
||||
+ let reading = state(name, &device, &own);
|
||||
(device.grant_indices(IndexClass::Texture, 4096, 4))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let mut buffers = Buffers::new(&device);
|
||||
@@ -3147,7 +3128,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
want,
|
||||
"{name}: every pixel the second draw's blue"
|
||||
);
|
||||
- println!("{name}: every render pipeline made with the loop's colour flag");
|
||||
+ println!("{name}: the feedback layout survived a pipeline change");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3170,7 +3151,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
}
|
||||
(device.grant_indices(IndexClass::Texture, 4096, 4))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
- let looped = device.core().feedback_loop;
|
||||
+ let looped = device.core().feedback_loop.is_some();
|
||||
let plain = state(name, &device, &plain);
|
||||
let reading = state(name, &device, &own);
|
||||
let mut buffers = Buffers::new(&device);
|
||||
@@ -3258,7 +3239,7 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
println!("{name}: no attachment reads");
|
||||
return;
|
||||
}
|
||||
- let looped = device.core().feedback_loop;
|
||||
+ let looped = device.core().feedback_loop.is_some();
|
||||
let counters = device.counters();
|
||||
let before = counters.metrics();
|
||||
for (class, first) in [(IndexClass::Texture, 4096), (IndexClass::Sampler, 1)] {
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/fetch.rs b/crates/metal2vulkan-runtime/src/tests/fetch.rs
|
||||
index a77caf19d..feb279ee5 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/fetch.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/fetch.rs
|
||||
@@ -213,7 +213,7 @@ mod on_device {
|
||||
(device.grant_indices(IndexClass::Texture, 4096, DRAWS.len() as u32))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let reads = device.core().attachment_reads;
|
||||
- let looped = device.core().feedback_loop;
|
||||
+ let looped = device.core().feedback_loop.is_some();
|
||||
let state = state(name, &device, &d);
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let clear = ClearColor {
|
||||
@@ -446,7 +446,7 @@ mod on_device {
|
||||
(device.grant_indices(IndexClass::Texture, 4096, DRAWS.len() as u32))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let reads = device.core().attachment_reads;
|
||||
- let feedback = device.core().feedback_loop;
|
||||
+ let feedback = device.core().feedback_loop.is_some();
|
||||
// The feedback usage is the loop's extension's, so only a device with the loop is
|
||||
// asked it (`VUID-VkPhysicalDeviceImageFormatInfo2-usage-parameter`); the answer is
|
||||
// read only there.
|
||||
@@ -586,7 +586,7 @@ mod on_device {
|
||||
(device.grant_indices(IndexClass::Texture, 4096, count))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let reads = device.core().attachment_reads;
|
||||
- let feedback = device.core().feedback_loop;
|
||||
+ let feedback = device.core().feedback_loop.is_some();
|
||||
// The feedback usage is the loop's extension's, so only a device with the loop is
|
||||
// asked it (`VUID-VkPhysicalDeviceImageFormatInfo2-usage-parameter`); the answer is
|
||||
// read only there.
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/floor.rs b/crates/metal2vulkan-runtime/src/tests/floor.rs
|
||||
index 8e03e9515..3aa5c1d2f 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/floor.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/floor.rs
|
||||
@@ -1834,12 +1834,8 @@ fn a_run_time_texel_offset_is_the_sample_s_operand_where_maintenance8_is_reporte
|
||||
assert_eq!(answer(&device), (true, true, true, true, true));
|
||||
}
|
||||
|
||||
-/// A device reads attachments where its descriptor limits hold the sampled-texture array's second
|
||||
-/// elements: through the attachment feedback loop where it lists
|
||||
-/// `VK_EXT_attachment_feedback_loop_layout` and reports its feature, which device creation then
|
||||
-/// enables, with no other extension (its dynamic state is never enabled, listed or not), and
|
||||
-/// through a copy of the image where it does not, enabling neither. A device without the room
|
||||
-/// reads no attachment, whatever it reports.
|
||||
+/// Attachment reads require room in the descriptor arrays. Native feedback also requires
|
||||
+/// both extensions and both features; otherwise reads use the shadow.
|
||||
#[test]
|
||||
fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhere() {
|
||||
let roomy = |device: &mut Queried| {
|
||||
@@ -1875,10 +1871,15 @@ fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhe
|
||||
let mut device = at_the_floor();
|
||||
assert_eq!(answer(&device), (false, false, 0, 0), "at the floor");
|
||||
looped(&mut device);
|
||||
+ device.extensions.push(dynamic.to_owned());
|
||||
+ device
|
||||
+ .features
|
||||
+ .feedback_dynamic
|
||||
+ .attachment_feedback_loop_dynamic_state = vk::TRUE;
|
||||
assert_eq!(
|
||||
answer(&device),
|
||||
(false, false, 0, 0),
|
||||
- "no room, the loop reported"
|
||||
+ "no room, both features reported"
|
||||
);
|
||||
let mut device = at_the_floor();
|
||||
roomy(&mut device);
|
||||
@@ -1900,15 +1901,23 @@ fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhe
|
||||
looped(&mut device);
|
||||
assert_eq!(
|
||||
answer(&device),
|
||||
- (true, true, 1, 1),
|
||||
- "room and the layout extension alone: the loop"
|
||||
+ (true, false, 0, 0),
|
||||
+ "room and the layout extension alone: the copy"
|
||||
);
|
||||
device.extensions.push(dynamic.to_owned());
|
||||
- let capabilities = decide(&device).unwrap_or_else(|below| panic!("{below}"));
|
||||
- assert!(capabilities.feedback_loop);
|
||||
- assert!(
|
||||
- !capabilities.extensions.contains(&dynamic),
|
||||
- "the loop's dynamic state is never enabled"
|
||||
+ assert_eq!(
|
||||
+ answer(&device),
|
||||
+ (true, false, 0, 0),
|
||||
+ "room and both extensions but no dynamic feature: the copy"
|
||||
+ );
|
||||
+ device
|
||||
+ .features
|
||||
+ .feedback_dynamic
|
||||
+ .attachment_feedback_loop_dynamic_state = vk::TRUE;
|
||||
+ assert_eq!(
|
||||
+ answer(&device),
|
||||
+ (true, true, 2, 2),
|
||||
+ "room and both features reported: the loop"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2306,6 +2315,7 @@ fn every_device_the_loader_lists_is_above_the_floor() {
|
||||
mut robustness2,
|
||||
mut portability,
|
||||
mut feedback_loop,
|
||||
+ mut feedback_dynamic,
|
||||
mut divisor,
|
||||
mut border_swizzle,
|
||||
mut linear_attachment,
|
||||
@@ -2343,7 +2353,9 @@ fn every_device_the_loader_lists_is_above_the_floor() {
|
||||
features = features.push_next(&mut portability);
|
||||
}
|
||||
if capabilities.feedback_loop {
|
||||
- features = features.push_next(&mut feedback_loop);
|
||||
+ features = features
|
||||
+ .push_next(&mut feedback_loop)
|
||||
+ .push_next(&mut feedback_dynamic);
|
||||
}
|
||||
if enabled(ash::khr::vertex_attribute_divisor::NAME)
|
||||
|| enabled(ash::ext::vertex_attribute_divisor::NAME)
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/held_loop_reads.rs b/crates/metal2vulkan-runtime/src/tests/held_loop_reads.rs
|
||||
index 5d0d0c52d..07e8658e8 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/held_loop_reads.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/held_loop_reads.rs
|
||||
@@ -62,7 +62,7 @@ mod on_device {
|
||||
held.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
|
||||
each_device("held_loop_reads", |name, _, device| {
|
||||
let core = device.core();
|
||||
- let (reads, looped) = (core.attachment_reads, core.feedback_loop);
|
||||
+ let (reads, looped) = (core.attachment_reads, core.feedback_loop.is_some());
|
||||
println!("{name}: attachment reads {reads}, feedback loop {looped}");
|
||||
if !reads {
|
||||
println!("{name}: SKIPPED: the device reads no attachment through a texture");
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/real_size_overs.rs b/crates/metal2vulkan-runtime/src/tests/real_size_overs.rs
|
||||
index 2e130a17f..6c766acdd 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/real_size_overs.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/real_size_overs.rs
|
||||
@@ -1104,7 +1104,7 @@ declare <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float>)
|
||||
each_device("real_size_attachment_loops", |name, _, device| {
|
||||
let (reads, looped) = {
|
||||
let core = device.core();
|
||||
- (core.attachment_reads, core.feedback_loop)
|
||||
+ (core.attachment_reads, core.feedback_loop.is_some())
|
||||
};
|
||||
if !reads {
|
||||
println!("real-size: {name}: no attachment reads; the loop cells not run");
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/real_size_renders.rs b/crates/metal2vulkan-runtime/src/tests/real_size_renders.rs
|
||||
index a4027e806..2559de92c 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/real_size_renders.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/real_size_renders.rs
|
||||
@@ -1312,7 +1312,7 @@ declare { <4 x float>, i8 } @air.sample_texture_2d.v4f32(ptr addrspace(1), ptr a
|
||||
each_device("real_size_two_target_loops", |name, _, device| {
|
||||
let (reads, looped) = {
|
||||
let core = device.core();
|
||||
- (core.attachment_reads, core.feedback_loop)
|
||||
+ (core.attachment_reads, core.feedback_loop.is_some())
|
||||
};
|
||||
if !reads {
|
||||
println!("real-size: {name}: no attachment reads; the two-target cells not run");
|
||||
@@ -1802,7 +1802,7 @@ declare { <4 x float>, i8 } @air.sample_texture_2d.v4f32(ptr addrspace(1), ptr a
|
||||
each_device("real_size_screens", |name, _, device| {
|
||||
let (reads, looped) = {
|
||||
let core = device.core();
|
||||
- (core.attachment_reads, core.feedback_loop)
|
||||
+ (core.attachment_reads, core.feedback_loop.is_some())
|
||||
};
|
||||
if !reads {
|
||||
println!("real-size: {name}: no attachment reads; the screen cells not run");
|
||||
diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs
|
||||
index ef71a2753..a616a8914 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/texture.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/texture.rs
|
||||
@@ -1752,7 +1752,7 @@ impl Device {
|
||||
});
|
||||
let attachment_reads = plan.attachment_reads && !laid_over;
|
||||
// On a device without the feedback loop, a draw reads such an image through its shadow.
|
||||
- let shadowing = (attachment_reads && !core.feedback_loop).then(|| {
|
||||
+ let shadowing = (attachment_reads && core.feedback_loop.is_none()).then(|| {
|
||||
Box::new(Shadowing {
|
||||
made: (d, shape, plan.shadow()),
|
||||
shadow: Mutex::new(None),
|
||||
@@ -2729,7 +2729,7 @@ fn planned(
|
||||
// it has the attachment feedback loop, else through a copy into the image's shadow. The image
|
||||
// takes the sampled usage for it where shaders do not read the texture.
|
||||
let mut attachment_reads = plan.reads_attachments(core);
|
||||
- let looped = attachment_reads && core.feedback_loop;
|
||||
+ let looped = attachment_reads && core.feedback_loop.is_some();
|
||||
let mut image_usage = plan.usage;
|
||||
if attachment_reads {
|
||||
image_usage |= vk::ImageUsageFlags::SAMPLED;
|
||||
@@ -6525,7 +6525,7 @@ impl Device {
|
||||
Ok(crate::surface::PlanePlan {
|
||||
format: plan.format,
|
||||
usage: plan.linear_usage(),
|
||||
- looped: plan.reads_attachments(self.core()) && self.core().feedback_loop,
|
||||
+ looped: plan.reads_attachments(self.core()) && self.core().feedback_loop.is_some(),
|
||||
view_formats: plan.view_formats.clone(),
|
||||
texel,
|
||||
})
|
||||
@@ -1,159 +0,0 @@
|
||||
diff --git a/crates/metal2vulkan-runtime/src/memory.rs b/crates/metal2vulkan-runtime/src/memory.rs
|
||||
index 2864f4ba6..f574e3b30 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/memory.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/memory.rs
|
||||
@@ -648,6 +648,9 @@ struct Allocation {
|
||||
/// Its block out is a texture block ([`crate::places`]), which fills its allocation: a whole
|
||||
/// unit, or a long allocation of its own length. False once it is idle.
|
||||
texture: bool,
|
||||
+ /// Reserved for image placement when buffer address replay is enabled. This allocation
|
||||
+ /// stays in the texture pool after its last block comes back.
|
||||
+ texture_only: bool,
|
||||
/// When it became idle, in nanoseconds of [`host_time`](crate::host_time): when it was made,
|
||||
/// or when its last live block came back. The oldest idle allocation is freed first.
|
||||
idle_since: u64,
|
||||
@@ -1200,7 +1203,9 @@ impl Pool {
|
||||
return Err(Error::Quiesced);
|
||||
}
|
||||
let texture = matches!(site, Site::TextureBlock);
|
||||
- if let Some((carve, idle_since, long, ahead)) = state.fit(class, len, align, texture) {
|
||||
+ if let Some((carve, idle_since, long, ahead)) =
|
||||
+ state.fit(class, len, align, texture, core.capture_replay)
|
||||
+ {
|
||||
if ahead {
|
||||
self.counters.site_take_ahead(site, len);
|
||||
}
|
||||
@@ -1404,7 +1409,7 @@ impl Pool {
|
||||
let state = self.lock();
|
||||
let alloc = state.allocations[memory.class.index()]
|
||||
.iter()
|
||||
- .find(|a| a.memory == memory.memory)?;
|
||||
+ .find(|a| a.memory == memory.memory && !a.texture_only)?;
|
||||
|
||||
Some(BlockCaptureInfo {
|
||||
class: memory.class,
|
||||
@@ -1435,7 +1440,8 @@ impl Pool {
|
||||
let id = number(&mut state)?;
|
||||
let want_base = cap.gpu_address.saturating_sub(cap.offset);
|
||||
if let Some(alloc) = state.allocations[index].iter_mut().find(|a| {
|
||||
- a.address == want_base
|
||||
+ !a.texture_only
|
||||
+ && a.address == want_base
|
||||
&& a.opaque_buffer_address == cap.opaque_buffer_address
|
||||
&& a.opaque_memory_address == cap.opaque_memory_address
|
||||
&& a.len == cap.alloc_len
|
||||
@@ -1463,7 +1469,8 @@ impl Pool {
|
||||
// Re-check if an ahead allocation that just finished landed at the exact target VA!
|
||||
let want_base = cap.gpu_address.saturating_sub(cap.offset);
|
||||
let hit = state.allocations[index].iter_mut().find_map(|a| {
|
||||
- if a.address == want_base
|
||||
+ if !a.texture_only
|
||||
+ && a.address == want_base
|
||||
&& a.opaque_buffer_address == cap.opaque_buffer_address
|
||||
&& a.opaque_memory_address == cap.opaque_memory_address
|
||||
&& a.len == cap.alloc_len
|
||||
@@ -1705,8 +1712,12 @@ impl State {
|
||||
/// free bytes would wait until they ran low; in return a take of up to a unit, the 16 MiB
|
||||
/// ones among them, lands in memory made ahead once the block-maker thread has made it.
|
||||
fn whole(&self, class: MemoryClass) -> bool {
|
||||
- (self.allocations[class.index()].iter())
|
||||
- .any(|allocation| allocation.unit() && !allocation.retiring && allocation.live == 0)
|
||||
+ (self.allocations[class.index()].iter()).any(|allocation| {
|
||||
+ allocation.unit()
|
||||
+ && !allocation.texture_only
|
||||
+ && !allocation.retiring
|
||||
+ && allocation.live == 0
|
||||
+ })
|
||||
}
|
||||
|
||||
/// The allocation of `class` whose memory is `memory`.
|
||||
@@ -1726,9 +1737,11 @@ impl State {
|
||||
len: u64,
|
||||
align: u64,
|
||||
texture: bool,
|
||||
+ split_textures: bool,
|
||||
) -> Option<(Carve, Option<u64>, bool, bool)> {
|
||||
+ let texture_only = split_textures && texture;
|
||||
let (allocation, base) = (self.allocations[class.index()].iter_mut())
|
||||
- .filter(|allocation| allocation.serves(len))
|
||||
+ .filter(|allocation| allocation.texture_only == texture_only && allocation.serves(len))
|
||||
.find_map(|allocation| {
|
||||
let base = allocation.free.take(len, align)?;
|
||||
Some((allocation, base))
|
||||
@@ -1757,7 +1770,9 @@ impl State {
|
||||
fn aging(&self, class: MemoryClass) -> (Vec<(u64, vk::DeviceMemory)>, u64) {
|
||||
let idle = (self.allocations[class.index()].iter())
|
||||
.filter(|allocation| allocation.live == 0 && !allocation.retiring);
|
||||
- let reserve = idle.clone().rfind(|allocation| allocation.unit());
|
||||
+ let reserve = idle
|
||||
+ .clone()
|
||||
+ .rfind(|allocation| allocation.unit() && !allocation.texture_only);
|
||||
let mut weighed: Vec<(u64, vk::DeviceMemory)> = idle
|
||||
.filter(|allocation| reserve.is_none_or(|reserve| reserve.memory != allocation.memory))
|
||||
.map(|allocation| (allocation.idle_since, allocation.memory))
|
||||
@@ -2218,6 +2233,8 @@ fn make_allocation_ex(
|
||||
replay: Option<(u64, u64)>,
|
||||
) -> Result<Allocation, Error> {
|
||||
let device = &core.device;
|
||||
+ let texture_only = core.capture_replay && matches!(site, Some(Site::TextureBlock));
|
||||
+ let capture_replay = core.capture_replay && !texture_only;
|
||||
let (id, freed_at) = {
|
||||
let mut state = core.pool.lock();
|
||||
(
|
||||
@@ -2231,7 +2248,7 @@ fn make_allocation_ex(
|
||||
.size(len)
|
||||
.usage(floor::BUFFER_USAGE)
|
||||
.sharing_mode(vk::SharingMode::EXCLUSIVE);
|
||||
- if core.capture_replay {
|
||||
+ if capture_replay {
|
||||
info = info.flags(vk::BufferCreateFlags::DEVICE_ADDRESS_CAPTURE_REPLAY);
|
||||
if replay.is_some_and(|(b, _)| b != 0) {
|
||||
info = info.push_next(&mut buf_opaque);
|
||||
@@ -2244,7 +2261,7 @@ fn make_allocation_ex(
|
||||
// SAFETY: the buffer is the device's.
|
||||
let requirements = unsafe { device.get_buffer_memory_requirements(buffer) };
|
||||
let mut mem_flags = vk::MemoryAllocateFlags::DEVICE_ADDRESS;
|
||||
- if core.capture_replay {
|
||||
+ if capture_replay {
|
||||
mem_flags |= vk::MemoryAllocateFlags::DEVICE_ADDRESS_CAPTURE_REPLAY;
|
||||
}
|
||||
let mut flags = vk::MemoryAllocateFlagsInfo::default().flags(mem_flags);
|
||||
@@ -2254,7 +2271,7 @@ fn make_allocation_ex(
|
||||
.allocation_size(requirements.size.max(len))
|
||||
.memory_type_index(core.memory_type(class))
|
||||
.push_next(&mut flags);
|
||||
- if core.capture_replay && replay.is_some_and(|(_, m)| m != 0) {
|
||||
+ if capture_replay && replay.is_some_and(|(_, m)| m != 0) {
|
||||
allocate_info = allocate_info.push_next(&mut mem_opaque);
|
||||
}
|
||||
let bits = requirements.memory_type_bits;
|
||||
@@ -2285,6 +2302,7 @@ fn make_allocation_ex(
|
||||
live: 0,
|
||||
placed: 0,
|
||||
texture: false,
|
||||
+ texture_only,
|
||||
idle_since: crate::host_time(),
|
||||
made: (0, 0),
|
||||
wait: Wait::Progress(0),
|
||||
@@ -2313,7 +2331,7 @@ fn make_allocation_ex(
|
||||
let of = vk::BufferDeviceAddressInfo::default().buffer(buffer);
|
||||
// SAFETY: the buffer has device-address usage and is bound.
|
||||
allocation.address = unsafe { device.get_buffer_device_address(&of) };
|
||||
- if core.capture_replay {
|
||||
+ if capture_replay {
|
||||
allocation.opaque_buffer_address =
|
||||
unsafe { device.get_buffer_opaque_capture_address(&of) };
|
||||
let mof = vk::DeviceMemoryOpaqueCaptureAddressInfo::default().memory(memory);
|
||||
diff --git a/crates/metal2vulkan-runtime/src/places.rs b/crates/metal2vulkan-runtime/src/places.rs
|
||||
index 3d679bbaa..774af81be 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/places.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/places.rs
|
||||
@@ -1,6 +1,8 @@
|
||||
//! Places: the Private blocks the runtime places textures' images in, taken as the consumer takes
|
||||
//! blocks. A texture block holds images alone, so no buffer lies beside an optimal image in one
|
||||
//! block.
|
||||
+//! When the device enables buffer address replay, the pool keeps texture allocations separate
|
||||
+//! and leaves their replay flags clear. Restoring a buffer can still request its captured address.
|
||||
//!
|
||||
//! A place is a resource's bytes at a multiple of its alignment. One no longer than the class's
|
||||
//! block length ([`MemoryClass::block_len`]) is the first that fits in the blocks of that length,
|
||||
@@ -1,378 +0,0 @@
|
||||
diff --git a/crates/metal2vulkan-runtime/src/pipeline.rs b/crates/metal2vulkan-runtime/src/pipeline.rs
|
||||
index 810b53918..986f44a70 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/pipeline.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/pipeline.rs
|
||||
@@ -858,9 +858,8 @@ pub(crate) enum Place {
|
||||
|
||||
/// The word a buffer slot's [`FieldValue::BufferAddress`] parameter holds for `address`: the
|
||||
/// address less 2^31, as the translator's identity domains read a buffer slot's `SlotGuestBase`
|
||||
-/// (`docs/API.md`, section 5). A module adds an access's 32-bit byte offset plus 2^31 to the word,
|
||||
-/// zero-extended, which is the address plus the offset read as signed, and adds 2^31 back where it
|
||||
-/// reads the address itself.
|
||||
+/// (`docs/API.md`, section 5). A module restores the address with an explicit carry and adds
|
||||
+/// the access's sign-extended byte displacement.
|
||||
pub(crate) fn address_word(address: u64) -> u64 {
|
||||
address.wrapping_sub(1 << 31)
|
||||
}
|
||||
diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs
|
||||
index d5cbd7424..91c8efb77 100644
|
||||
--- a/crates/metal2vulkan/src/cache/mod.rs
|
||||
+++ b/crates/metal2vulkan/src/cache/mod.rs
|
||||
@@ -60,7 +60,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
-pub const SEMANTICS_VERSION: u32 = 2308;
|
||||
+pub const SEMANTICS_VERSION: u32 = 2309;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
diff --git a/crates/metal2vulkan/src/lower/access/emit.rs b/crates/metal2vulkan/src/lower/access/emit.rs
|
||||
index 16c49e4bf..02e30c8d9 100644
|
||||
--- a/crates/metal2vulkan/src/lower/access/emit.rs
|
||||
+++ b/crates/metal2vulkan/src/lower/access/emit.rs
|
||||
@@ -338,21 +338,13 @@ fn prepare_access(
|
||||
let lowering = cx.plan.families.access.slots.get(t.slot).copied().flatten();
|
||||
let ops = WordOps::of(crate::lower::sync::memory_model::coherence(cx.plan));
|
||||
if let Some(SlotLowering::Psb { start }) = lowering {
|
||||
- // Under the identity domains a slot whose address the binder holds to an alignment is
|
||||
- // reached from that address as it is (its biased word), a leaf at an offset proven a
|
||||
- // multiple of 8 or 16 accessed at that alignment up to the address's; any other from the
|
||||
- // word below each access.
|
||||
+ // Aligned slots keep their aligned leaf loads. Other slots use the word below the access.
|
||||
let aligned = cx.plan.families.access.aligned.get(&t.slot).copied();
|
||||
let a = if cx.plan.families.access.identity {
|
||||
+ let address = super::pointer::slot_address(cx, fb, choice.slot)?;
|
||||
match aligned {
|
||||
- Some(held) => {
|
||||
- let base = super::pointer::biased_slot_address(cx, fb, choice.slot)?;
|
||||
- psb::prepare_direct(base, m, held)
|
||||
- }
|
||||
- None => {
|
||||
- let address = super::pointer::slot_address(cx, fb, choice.slot)?;
|
||||
- psb::prepare_at(fb, address, m)?
|
||||
- }
|
||||
+ Some(held) => psb::prepare_direct(address, m, held),
|
||||
+ None => psb::prepare_at(fb, address, m)?,
|
||||
}
|
||||
} else {
|
||||
let table = cx.push_field(fb, PushField::RootTableAddress)?;
|
||||
diff --git a/crates/metal2vulkan/src/lower/access/mod.rs b/crates/metal2vulkan/src/lower/access/mod.rs
|
||||
index 47fac1863..34ce24166 100644
|
||||
--- a/crates/metal2vulkan/src/lower/access/mod.rs
|
||||
+++ b/crates/metal2vulkan/src/lower/access/mod.rs
|
||||
@@ -1127,10 +1127,8 @@ fn address_field(slot: SlotRef) -> PushField {
|
||||
}
|
||||
|
||||
/// The bias of a buffer slot's `SlotGuestBase` word under the identity domains, 2^31: the runtime
|
||||
-/// pushes the slot's address less it. An access adds its 32-bit byte offset plus the bias to the
|
||||
-/// word, zero-extended ([`psb::prepare_direct`]), which is the address plus the offset read as
|
||||
-/// signed in one 32-bit add, and every other read of the word adds the bias back
|
||||
-/// ([`pointer::slot_address`]).
|
||||
+/// pushes the slot's address less it. The translator adds the bias back with carry across
|
||||
+/// two words before using the address ([`pointer::slot_address`]).
|
||||
pub(crate) const SLOT_ADDRESS_BIAS: u64 = 1 << 31;
|
||||
|
||||
/// Whether profile `p` takes the identity domains, where a pointer is a device address used
|
||||
diff --git a/crates/metal2vulkan/src/lower/access/pointer.rs b/crates/metal2vulkan/src/lower/access/pointer.rs
|
||||
index c2cf85d17..9cfced155 100644
|
||||
--- a/crates/metal2vulkan/src/lower/access/pointer.rs
|
||||
+++ b/crates/metal2vulkan/src/lower/access/pointer.rs
|
||||
@@ -754,16 +754,26 @@ fn guest_base(
|
||||
if !words {
|
||||
return Ok(Address::U64(slot_address(cx, fb, slot)?));
|
||||
}
|
||||
- let v = cx.push_field(fb, PushField::SlotGuestBase(slot))?;
|
||||
- let word = wide::split(fb, v)?;
|
||||
+ let word = cx.push_field(fb, PushField::SlotGuestBase(slot))?;
|
||||
+ Ok(Address::Words(slot_address_words(cx, fb, word)?))
|
||||
+}
|
||||
+
|
||||
+/// Recover the two address words from a slot's push value. An explicit carry keeps the bias from
|
||||
+/// becoming a signed 32-bit offset to a physical storage buffer access.
|
||||
+fn slot_address_words(
|
||||
+ cx: &EmitCx<'_>,
|
||||
+ fb: &mut FunctionBuilder<'_>,
|
||||
+ value: SValue,
|
||||
+) -> BResult<Pair> {
|
||||
+ let word = wide::split(fb, value)?;
|
||||
if !biased(cx) {
|
||||
- return Ok(Address::Words(word));
|
||||
+ return Ok(word);
|
||||
}
|
||||
let bias = Pair {
|
||||
lo: k32(fb, super::SLOT_ADDRESS_BIAS as u32)?,
|
||||
hi: k32(fb, 0)?,
|
||||
};
|
||||
- Ok(Address::Words(wide::add(fb, word, bias)?))
|
||||
+ wide::add(fb, word, bias)
|
||||
}
|
||||
|
||||
/// Whether buffer slots' `SlotGuestBase` words are their Metal addresses less
|
||||
@@ -773,48 +783,24 @@ fn biased(cx: &EmitCx<'_>) -> bool {
|
||||
cx.plan.families.access.identity && !cx.plan.families.access.replay
|
||||
}
|
||||
|
||||
-/// Buffer slot `slot`'s `SlotGuestBase` word (a `uvec2`, low word first) as a `u64` (needs
|
||||
-/// `shaderInt64`).
|
||||
-fn slot_word(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, slot: SlotRef) -> BResult<SValue> {
|
||||
- let v = cx.push_field(fb, PushField::SlotGuestBase(slot))?;
|
||||
- let u64_ = fb.module().ty(SType::Int {
|
||||
- width: 64,
|
||||
- signed: false,
|
||||
- })?;
|
||||
- fb.convert(ConvOp::Bitcast, v, u64_)
|
||||
-}
|
||||
-
|
||||
-/// Buffer slot `slot`'s Metal address, the bound buffer's `gpuAddress` plus the bind offset, as a
|
||||
-/// `u64` (needs `shaderInt64`): its `SlotGuestBase` word, plus
|
||||
-/// [`SLOT_ADDRESS_BIAS`](super::SLOT_ADDRESS_BIAS) where the word is biased ([`biased`]). What a
|
||||
-/// pointer compare, a converted or stored pointer, and an access from the word below it read.
|
||||
+/// Buffer slot's Metal address, the bound buffer's device address plus the bind offset.
|
||||
pub(super) fn slot_address(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
slot: SlotRef,
|
||||
) -> BResult<SValue> {
|
||||
- let word = slot_word(cx, fb, slot)?;
|
||||
- if !biased(cx) {
|
||||
- return Ok(word);
|
||||
- }
|
||||
- let bias = k64(fb, super::SLOT_ADDRESS_BIAS)?;
|
||||
- fb.binary(BinOp::IAdd, word, bias)
|
||||
-}
|
||||
-
|
||||
-/// Buffer slot `slot`'s Metal address less [`SLOT_ADDRESS_BIAS`](super::SLOT_ADDRESS_BIAS), a
|
||||
-/// `u64`: its `SlotGuestBase` word where the word is biased ([`biased`]), the base an access
|
||||
-/// reached from the slot's own address adds its biased offset to (`psb::prepare_direct`).
|
||||
-pub(super) fn biased_slot_address(
|
||||
- cx: &mut EmitCx<'_>,
|
||||
- fb: &mut FunctionBuilder<'_>,
|
||||
- slot: SlotRef,
|
||||
-) -> BResult<SValue> {
|
||||
- let word = slot_word(cx, fb, slot)?;
|
||||
- if biased(cx) {
|
||||
- return Ok(word);
|
||||
- }
|
||||
- let bias = k64(fb, super::SLOT_ADDRESS_BIAS)?;
|
||||
- fb.binary(BinOp::ISub, word, bias)
|
||||
+ let word = cx.push_field(fb, PushField::SlotGuestBase(slot))?;
|
||||
+ let address = if biased(cx) {
|
||||
+ let words = slot_address_words(cx, fb, word)?;
|
||||
+ wide::join(fb, wide::wide_form(64, 1), words)?
|
||||
+ } else {
|
||||
+ word
|
||||
+ };
|
||||
+ let u64_ = fb.module().ty(SType::Int {
|
||||
+ width: 64,
|
||||
+ signed: false,
|
||||
+ })?;
|
||||
+ fb.convert(ConvOp::Bitcast, address, u64_)
|
||||
}
|
||||
|
||||
/// The start of the 2³² bytes a pointer into plan slot `slot` whose offset range the analysis
|
||||
diff --git a/crates/metal2vulkan/src/lower/access/psb.rs b/crates/metal2vulkan/src/lower/access/psb.rs
|
||||
index 41927edb8..b09b0c354 100644
|
||||
--- a/crates/metal2vulkan/src/lower/access/psb.rs
|
||||
+++ b/crates/metal2vulkan/src/lower/access/psb.rs
|
||||
@@ -42,7 +42,6 @@
|
||||
//! below its argument's alignment, `LoweringInputs::word_bound_buffers`), and any other rounds
|
||||
//! down to a multiple of 4.
|
||||
|
||||
-use super::SLOT_ADDRESS_BIAS;
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::memory::leaf::{k32, u32_op, Units, WordMem, WordOps};
|
||||
use crate::spirv::builder::FunctionBuilder;
|
||||
@@ -196,19 +195,9 @@ enum Reach {
|
||||
/// making no buffer longer than 2 GiB (`metal2vulkan_runtime::MAX_BUFFER_LENGTH`), so the product is
|
||||
/// exact, and no 64-bit shift or multiply scales an index.
|
||||
Below,
|
||||
- /// From a slot's own device address under the identity domains ([`prepare_direct`]), held
|
||||
- /// as that address less [`SLOT_ADDRESS_BIAS`] (2^31): each unit at that base plus its 32-bit
|
||||
- /// byte offset plus 2^31, modulo 2^32, zero-extended, in 64-bit integers, then one
|
||||
- /// `OpConvertUToPtr` to the unit's block (`NonWritable` for a load of an unwritten slot).
|
||||
- /// Every byte of a buffer lies within 2^31 bytes of each bind address in it, the runtime
|
||||
- /// making no buffer longer than 2 GiB (`metal2vulkan_runtime::MAX_BUFFER_LENGTH`), so the offset
|
||||
- /// read as signed is in `[-2^31, 2^31)`, the biased one is that offset plus 2^31 exactly, and
|
||||
- /// the sum is the address plus the offset. A unit index `x + c` with a constant `c` folds
|
||||
- /// `c`'s bytes into the bias: `(x + c) * s + 2^31` is `x * s + (c * s + 2^31)` modulo 2^32.
|
||||
- /// The bias is one 32-bit add, which a device fuses with the index's shift; the offset is
|
||||
- /// zero-extended, which a device splits into a scalar base and a vector offset; no shift of
|
||||
- /// the offset in 64 bits and no pointer bitcast. It holds the alignment the binder holds the
|
||||
- /// slot's address to (`RuntimeFact::AddressAlignment`).
|
||||
+ /// From an aligned slot's own device address under the identity domains. Add the 32-bit
|
||||
+ /// byte displacement as a signed value in 64 bits. Each valid access is within 2 GiB of
|
||||
+ /// the bind address, so the displacement fits on either side of it.
|
||||
Direct(u32),
|
||||
}
|
||||
|
||||
@@ -235,14 +224,8 @@ pub fn prepare_at(fb: &mut FunctionBuilder<'_>, address: Value, m: Value) -> BRe
|
||||
})
|
||||
}
|
||||
|
||||
-/// Prepare an access of a static slot at the `u32` displacement `m` from its bind offset, under
|
||||
-/// the identity domains, from `base` (a `u64`), the slot's own device address less
|
||||
-/// [`SLOT_ADDRESS_BIAS`], an address the binder holds to a multiple of `held`
|
||||
-/// (`RuntimeFact::AddressAlignment`): the access is the byte offset `m`, read as signed, from that
|
||||
-/// address, as a descriptor view's is `m` from its base ([`Reach::Direct`]). Every byte of a
|
||||
-/// buffer lies within 2^31 bytes of each bind address in it, the runtime making no buffer longer
|
||||
-/// than 2 GiB (`metal2vulkan_runtime::MAX_BUFFER_LENGTH`), so the offset is exact whatever the slot's
|
||||
-/// window. Nothing is rounded. The check, where the access takes one, is `emit::prepare`'s.
|
||||
+/// Prepare an access from the slot's own device address at displacement m. The binder holds
|
||||
+/// the address to alignment held, so leaves can keep their alignment without rounding the base.
|
||||
pub fn prepare_direct(base: Value, m: Value, held: u32) -> PsbAccess {
|
||||
PsbAccess {
|
||||
mem: PsbMem {
|
||||
@@ -394,15 +377,10 @@ impl PsbMem {
|
||||
self.place(fb, addr, ty, load)
|
||||
}
|
||||
Reach::Direct(_) => {
|
||||
- let shift = bytes.trailing_zeros();
|
||||
- let (x, c) = fb.sum_of(index).unwrap_or((index, 0));
|
||||
- let s = k32(fb, shift)?;
|
||||
- let at = u32_op(fb, BinOp::ShiftLeftLogical, x, s)?;
|
||||
- let bias = (c << shift).wrapping_add(SLOT_ADDRESS_BIAS as u32);
|
||||
- let bias = k32(fb, bias)?;
|
||||
- let at = u32_op(fb, BinOp::IAdd, at, bias)?;
|
||||
+ let shift = k32(fb, bytes.trailing_zeros())?;
|
||||
+ let at = u32_op(fb, BinOp::ShiftLeftLogical, index, shift)?;
|
||||
let u64_ = u64_ty(fb)?;
|
||||
- let d = fb.convert(ConvOp::UConvert, at, u64_)?;
|
||||
+ let d = fb.convert(ConvOp::SConvert, at, u64_)?;
|
||||
let addr = fb.binary(BinOp::IAdd, self.base, d)?;
|
||||
self.place(fb, addr, ty, load)
|
||||
}
|
||||
@@ -491,12 +469,10 @@ impl PsbMem {
|
||||
(u32_op(fb, BinOp::BitwiseAnd, off, mask)?, 4)
|
||||
}
|
||||
};
|
||||
- let (x, c) = fb.sum_of(off).unwrap_or((off, 0));
|
||||
- let bias = c.wrapping_add(at).wrapping_add(SLOT_ADDRESS_BIAS as u32);
|
||||
- let bias = k32(fb, bias)?;
|
||||
- let biased = u32_op(fb, BinOp::IAdd, x, bias)?;
|
||||
+ let at = k32(fb, at)?;
|
||||
+ let offset = u32_op(fb, BinOp::IAdd, off, at)?;
|
||||
let u64_ = u64_ty(fb)?;
|
||||
- let d = fb.convert(ConvOp::UConvert, biased, u64_)?;
|
||||
+ let d = fb.convert(ConvOp::SConvert, offset, u64_)?;
|
||||
let addr = fb.binary(BinOp::IAdd, self.base, d)?;
|
||||
Ok((self.place(fb, addr, pointee, load)?, align))
|
||||
}
|
||||
diff --git a/crates/metal2vulkan/src/memory/leaf.rs b/crates/metal2vulkan/src/memory/leaf.rs
|
||||
index 180f2118a..a55e75ecc 100644
|
||||
--- a/crates/metal2vulkan/src/memory/leaf.rs
|
||||
+++ b/crates/metal2vulkan/src/memory/leaf.rs
|
||||
@@ -683,14 +683,6 @@ pub fn u32_op(fb: &mut FunctionBuilder<'_>, op: BinOp, a: Value, b: Value) -> BR
|
||||
(BinOp::IMul, Some(1), _) | (BinOp::BitwiseAnd, Some(u32::MAX), _) => Ok(b),
|
||||
(BinOp::IMul | BinOp::BitwiseAnd, Some(0), _)
|
||||
| (BinOp::IMul | BinOp::BitwiseAnd, _, Some(0)) => k32(fb, 0),
|
||||
- // A sum of a value and a constant is noted, for a consumer that folds the constant
|
||||
- // (`psb`'s biased offsets).
|
||||
- (BinOp::IAdd, None, Some(c)) | (BinOp::IAdd, Some(c), None) => {
|
||||
- let x = if y.is_some() { a } else { b };
|
||||
- let r = fb.binary(op, a, b)?;
|
||||
- fb.note_sum(r, x, c);
|
||||
- Ok(r)
|
||||
- }
|
||||
_ => fb.binary(op, a, b),
|
||||
}
|
||||
}
|
||||
diff --git a/crates/metal2vulkan/src/spirv/builder/function.rs b/crates/metal2vulkan/src/spirv/builder/function.rs
|
||||
index 1707e1094..4d03f302a 100644
|
||||
--- a/crates/metal2vulkan/src/spirv/builder/function.rs
|
||||
+++ b/crates/metal2vulkan/src/spirv/builder/function.rs
|
||||
@@ -177,16 +177,6 @@ impl<'m> FunctionBuilder<'m> {
|
||||
self.m.lanes.get(&y).copied()
|
||||
}
|
||||
|
||||
- /// Note that `y`, a 32-bit unsigned integer, is `x + c` modulo 2^32: `x` dominates `y`.
|
||||
- pub fn note_sum(&mut self, y: Value, x: Value, c: u32) {
|
||||
- self.m.sums.insert(y, (x, c));
|
||||
- }
|
||||
-
|
||||
- /// The value and constant `y` was noted to add.
|
||||
- pub fn sum_of(&self, y: Value) -> Option<(Value, u32)> {
|
||||
- self.m.sums.get(&y).copied()
|
||||
- }
|
||||
-
|
||||
/// Note that `y`, a 32-bit unsigned integer, is the zero extension of 16-bit integer `of`:
|
||||
/// `of` dominates `y`.
|
||||
pub fn note_widened16(&mut self, y: Value, of: Value) {
|
||||
diff --git a/crates/metal2vulkan/src/spirv/builder/module.rs b/crates/metal2vulkan/src/spirv/builder/module.rs
|
||||
index c5b252ce5..4709996e6 100644
|
||||
--- a/crates/metal2vulkan/src/spirv/builder/module.rs
|
||||
+++ b/crates/metal2vulkan/src/spirv/builder/module.rs
|
||||
@@ -118,9 +118,6 @@ pub struct ModuleBuilder {
|
||||
/// The heap bytes of [`ModuleBuilder::vector_parts`]' part lists, for
|
||||
/// [`ModuleBuilder::footprint`].
|
||||
pub(super) vector_part_bytes: usize,
|
||||
- /// The value and constant each 32-bit unsigned sum of a value and a constant the lowering
|
||||
- /// noted adds (`FunctionBuilder::note_sum`). Nothing here changes the IR.
|
||||
- pub(super) sums: HashMap<Value, (Value, u32)>,
|
||||
/// How each struct the builder made holds its members, and what each extract from a struct
|
||||
/// reads (`FunctionBuilder::member_source`): every `OpCompositeConstruct` and
|
||||
/// `OpCompositeInsert` of a struct type and every `OpCompositeExtract` from one, by result.
|
||||
@@ -334,7 +331,6 @@ impl ModuleBuilder {
|
||||
+ map_bytes(&self.inserts)
|
||||
+ map_bytes(&self.vector_parts)
|
||||
+ self.vector_part_bytes
|
||||
- + map_bytes(&self.sums)
|
||||
+ map_bytes(&self.structs)
|
||||
+ self.struct_bytes
|
||||
+ map_bytes(&self.widened16)
|
||||
diff --git a/crates/metal2vulkan/src/tests/engine_identity.rs b/crates/metal2vulkan/src/tests/engine_identity.rs
|
||||
index af70dfd31..05a80706a 100644
|
||||
--- a/crates/metal2vulkan/src/tests/engine_identity.rs
|
||||
+++ b/crates/metal2vulkan/src/tests/engine_identity.rs
|
||||
@@ -286,6 +286,20 @@ fn a_buffer_kernel_reads_each_slot_at_its_pushed_device_address() {
|
||||
assert!(a.interface.descriptors.is_empty(), "{stem}");
|
||||
assert!(!a.interface.needs_pointer_translation, "{stem}");
|
||||
assert_eq!(plan.push.argument_table_size, 0, "{stem}");
|
||||
+ // The push value for each of these slots crosses a 32-bit word boundary when unbiassed.
|
||||
+ // Restore that carry before handing the address to the memory operation.
|
||||
+ let words = &a.module.words;
|
||||
+ let mut at_word = 5;
|
||||
+ let mut carries = 0;
|
||||
+ while at_word < words.len() {
|
||||
+ let header = words[at_word];
|
||||
+ carries += usize::from(header & 0xffff == crate::spv::Op::IAddCarry as u32);
|
||||
+ at_word += (header >> 16) as usize;
|
||||
+ }
|
||||
+ assert!(
|
||||
+ carries >= at.len(),
|
||||
+ "{stem}: expected a carry for each pushed slot"
|
||||
+ );
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
|
||||
let mut push = vec![0u8; plan.push.push_range.map_or(0, |(_, end)| end as usize)];
|
||||
let mut read = Vec::new();
|
||||
@@ -349,8 +363,8 @@ fn a_buffer_kernel_reads_each_slot_at_its_pushed_device_address() {
|
||||
|
||||
/// A slot pointer used as a value under the identity domains is its Metal address, though the
|
||||
/// runtime pushes each buffer slot's address less 2^31 (`lower::access::SLOT_ADDRESS_BIAS`): two
|
||||
-/// address compares add the bias back, and the loads beside them, one 4 bytes below its slot's
|
||||
-/// bind address, add their offsets plus the bias to the word. The two slots lie on either side of
|
||||
+/// address compares restore the address, and the loads beside them add signed displacements,
|
||||
+/// including one 4 bytes below its slot's bind address. The two slots lie on either side of
|
||||
/// 2^31, so their words lie on either side of 0 and a compare of the words would answer the other
|
||||
/// way.
|
||||
#[test]
|
||||
diff --git a/docs/API.md b/docs/API.md
|
||||
index 726741b97..4ee8b6e7f 100644
|
||||
--- a/docs/API.md
|
||||
+++ b/docs/API.md
|
||||
@@ -1148,11 +1148,10 @@ for dependency in &pipeline.dependencies {
|
||||
- Under the identity domains (section 1) a buffer slot's `PushField::SlotGuestBase` is its
|
||||
address, the bound buffer's `gpuAddress` plus the bind offset (or the address of its
|
||||
`setBytes` copy, or of the consumer's nil buffer where nothing is bound), less 2^31, modulo
|
||||
- 2^64. An access through the slot adds its 32-bit byte offset plus 2^31, modulo 2^32,
|
||||
- zero-extended, to that word; a pointer compare, a pulled vertex fetch and an access from the
|
||||
- word below it add the 2^31 back to read the address itself, and so does a slot pointer
|
||||
- converted to an integer or stored, which is the slot's address plus its offset. A runtime
|
||||
- writes the word so. A pointer loaded from memory (an argument buffer's pointer member, a `gpuAddress` the
|
||||
+ 2^64. The translator restores the address using separate low and high words with carry.
|
||||
+ Loads and stores through the slot add a signed 32-bit byte displacement to the restored
|
||||
+ 64-bit address. Pointer comparisons and conversions also use the restored address. A runtime
|
||||
+ writes the biased word. A pointer loaded from memory (an argument buffer's pointer member, a `gpuAddress` the
|
||||
program stored) and a pointer made from an integer are the device address the word holds,
|
||||
unbiased and used directly, unchecked: there is no root table, no `PushField::RootTableAddress`
|
||||
and no search. A texture's or sampler's `SlotGuestBase` is its `gpuResourceID`, unbiased. A
|
||||
@@ -1,525 +0,0 @@
|
||||
diff --git a/crates/metal2vulkan-runtime/src/block.rs b/crates/metal2vulkan-runtime/src/block.rs
|
||||
index 0ac77ecac0f3abb9e9b76fb82d17c3536e22f4f5..426d025513a2f04e97f31efa66d1632635f7254d 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/block.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/block.rs
|
||||
@@ -54,6 +54,12 @@ impl Block {
|
||||
Block { claim }
|
||||
}
|
||||
|
||||
+ /// Returns capture/replay address metadata for this block (if supported).
|
||||
+ pub fn capture_info(&self) -> Option<memory::BlockCaptureInfo> {
|
||||
+ let (core, block) = self.held().ok()?;
|
||||
+ core.pool.capture_info(&block.memory)
|
||||
+ }
|
||||
+
|
||||
/// Whether the block is of `core`'s device.
|
||||
pub(crate) fn is_of(&self, core: &Arc<Core>) -> bool {
|
||||
Weak::as_ptr(&self.claim.core) == Arc::as_ptr(core)
|
||||
diff --git a/crates/metal2vulkan-runtime/src/device.rs b/crates/metal2vulkan-runtime/src/device.rs
|
||||
index 8edf1f27202f9a19b19cc4a4484d1e31341b8ab1..68f79440cc7727f2fae6063756380fe7a85ce7f9 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/device.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/device.rs
|
||||
@@ -273,6 +273,7 @@ pub(crate) struct Core {
|
||||
/// every render pipeline takes its colour flag, and a draw reads an attachment of its pass
|
||||
/// with the image in the feedback layout.
|
||||
pub(crate) feedback_loop: bool,
|
||||
+ pub(crate) capture_replay: bool,
|
||||
/// `VK_EXT_device_fault`'s command, where device creation enabled it (where the device lists
|
||||
/// it): a lost device's fault report, read once, at its first loss (`crate::fault`).
|
||||
pub(crate) fault: Option<ash::ext::device_fault::Device>,
|
||||
@@ -860,6 +861,7 @@ impl Device {
|
||||
ticks,
|
||||
calibrated,
|
||||
feedback_loop: capabilities.feedback_loop,
|
||||
+ capture_replay: capabilities.buffer_device_address_capture_replay,
|
||||
fault,
|
||||
indirect,
|
||||
attachment_reads: capabilities.attachment_reads,
|
||||
@@ -1140,6 +1142,41 @@ impl Device {
|
||||
/// allocation past the device's count; [`Limit::AllocationNotMapped`](crate::Limit::AllocationNotMapped)
|
||||
/// where the consumer did not map the allocation the take made; [`Error::Vulkan`] where the
|
||||
/// device is out of memory or lost; [`Error::Quiesced`].
|
||||
+ /// Whether Vulkan `bufferDeviceAddressCaptureReplay` is enabled on this device.
|
||||
+ pub fn buffer_device_address_capture_replay(&self) -> bool {
|
||||
+ self.shared.core.capture_replay
|
||||
+ }
|
||||
+
|
||||
+ /// Waits non-destructively until all in-flight GPU work has completed and retired.
|
||||
+ pub fn wait_idle(&self) -> Result<(), Error> {
|
||||
+ let core = &self.shared.core;
|
||||
+ if core.closed() {
|
||||
+ return Err(Error::Quiesced);
|
||||
+ }
|
||||
+ // Wait for submitted command buffers to retire on the completion thread.
|
||||
+ let deadline = Instant::now() + Duration::from_secs(10);
|
||||
+ while core.pool.in_flight() > 0 && Instant::now() < deadline {
|
||||
+ std::thread::sleep(Duration::from_millis(1));
|
||||
+ }
|
||||
+ // SAFETY: `device` is live and wait_idle synchronizes all host queues.
|
||||
+ let _q = lock(&core.queues.runtime);
|
||||
+ unsafe { core.device.device_wait_idle() }.map_err(Error::vulkan("vkDeviceWaitIdle"))?;
|
||||
+ Ok(())
|
||||
+ }
|
||||
+
|
||||
+ /// Replays a previously captured block at its exact Vulkan device address.
|
||||
+ pub fn take_block_replayed(&self, capture: memory::BlockCaptureInfo) -> Result<Block, Error> {
|
||||
+ let core = &self.shared.core;
|
||||
+ if core.closed() {
|
||||
+ return Err(Error::Quiesced);
|
||||
+ }
|
||||
+ let memory = core.pool.take_replayed(core, capture, crate::counters::Site::take(capture.class))?;
|
||||
+ let info = memory.info();
|
||||
+ let block = memory::Block::new(memory, Arc::clone(core));
|
||||
+ Ok(Block::claim(core, info, block))
|
||||
+ }
|
||||
+
|
||||
+ /// Allocates a new GPU memory block of `class` and `len` bytes.
|
||||
pub fn take_block(&self, class: MemoryClass, len: u64) -> Result<Block, Error> {
|
||||
let core = &self.shared.core;
|
||||
if core.closed() {
|
||||
diff --git a/crates/metal2vulkan-runtime/src/event.rs b/crates/metal2vulkan-runtime/src/event.rs
|
||||
index fe95046625fb1d1c81e2925458c22c4dd3641197..8b47e5604f50dec0549733c515ce80e02dbe348e 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/event.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/event.rs
|
||||
@@ -140,6 +140,35 @@ impl Event {
|
||||
}
|
||||
}
|
||||
|
||||
+impl Event {
|
||||
+ /// Reads the current signaled value of this timeline event (for checkpointing).
|
||||
+ pub fn signaled_value(&self) -> u64 {
|
||||
+ let inner = &self.inner;
|
||||
+ let state = lock(&inner.state);
|
||||
+ let floor = state.observed.max(state.floor);
|
||||
+ inner.reached(None).map_or(floor, |reached| reached.max(floor))
|
||||
+ }
|
||||
+
|
||||
+ /// Restores the timeline semaphore and CPU floor to `value` on a freshly created event.
|
||||
+ pub fn restore_signaled_value(&self, value: u64) -> Result<(), Error> {
|
||||
+ if value == 0 {
|
||||
+ return Ok(());
|
||||
+ }
|
||||
+ let inner = &self.inner;
|
||||
+ let info = vk::SemaphoreSignalInfo::default()
|
||||
+ .semaphore(inner.semaphore)
|
||||
+ .value(value);
|
||||
+ // SAFETY: `semaphore` is a live timeline semaphore on `inner.core.device`.
|
||||
+ unsafe { inner.core.device.signal_semaphore(&info) }
|
||||
+ .map_err(Error::vulkan("vkSignalSemaphore"))?;
|
||||
+ let mut state = lock(&inner.state);
|
||||
+ state.floor = state.floor.max(value);
|
||||
+ state.observed = state.observed.max(value);
|
||||
+ inner.changed.notify_all();
|
||||
+ Ok(())
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
impl SharedEvent {
|
||||
/// `signaledValue`: the higher of the semaphore's value and the host's floor, the semaphore's
|
||||
/// value being one a host wait confirmed: a counter read finds it, and a wait with a timeout
|
||||
diff --git a/crates/metal2vulkan-runtime/src/floor.rs b/crates/metal2vulkan-runtime/src/floor.rs
|
||||
index 0e165934f4b7534d0a093b1a22bcd763a47db8d7..90c7f9e354af205aa5a6b2fbeb506e58fbba1ab8 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/floor.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/floor.rs
|
||||
@@ -1079,6 +1079,8 @@ pub struct Capabilities {
|
||||
/// [`ATTACHMENT_READ_EXTENSIONS`]: a draw reads an attachment through the attachment feedback
|
||||
/// loop, the feedback layout its image moves to and the flag every render pipeline takes.
|
||||
pub feedback_loop: bool,
|
||||
+ /// Whether `bufferDeviceAddressCaptureReplay` is enabled for checkpoint/restore.
|
||||
+ pub buffer_device_address_capture_replay: bool,
|
||||
/// The features device creation enables: every one the floor requires, each of the optional,
|
||||
/// step-rate, min-LOD, fill-mode, alpha-to-one, quad-control, pixel-interlock, linear-attachment
|
||||
/// and fault-report ones the device reports, the attachment-read ones where
|
||||
@@ -1425,6 +1427,10 @@ pub(crate) fn decide(device: &Queried) -> Result<Capabilities, BelowFloor> {
|
||||
let Some((queue_family, _)) = family.filter(|_| missing.is_empty()) else {
|
||||
return Err(BelowFloor { missing });
|
||||
};
|
||||
+ let capture_replay = reported.vulkan12.buffer_device_address_capture_replay == vk::TRUE;
|
||||
+ if capture_replay {
|
||||
+ features.vulkan12.buffer_device_address_capture_replay = vk::TRUE;
|
||||
+ }
|
||||
for feature in (OPTIONAL.iter().chain(STEP_RATES))
|
||||
.chain(MIN_LOD_CLAMPS)
|
||||
.chain(FILL_MODES)
|
||||
@@ -1491,6 +1497,7 @@ pub(crate) fn decide(device: &Queried) -> Result<Capabilities, BelowFloor> {
|
||||
texel_offset_operand: features.maintenance8.maintenance8 == vk::TRUE,
|
||||
attachment_reads,
|
||||
feedback_loop,
|
||||
+ buffer_device_address_capture_replay: capture_replay,
|
||||
features,
|
||||
extensions: DEVICE_EXTENSIONS
|
||||
.iter()
|
||||
diff --git a/crates/metal2vulkan-runtime/src/lib.rs b/crates/metal2vulkan-runtime/src/lib.rs
|
||||
index a2d59cc6f31eb64307c1a886fe7cf75f401511b1..557a1a4b213773df976895f703cd4c037ad2602b 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/lib.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/lib.rs
|
||||
@@ -100,7 +100,7 @@ pub use host_bytes::HostBytes;
|
||||
pub use import::ImportHandle;
|
||||
pub use indirect::{IndirectCommandBuffer, IndirectCommandBufferDescriptor, IndirectCommandType};
|
||||
pub use instance::{Instance, PhysicalDevice};
|
||||
-pub use memory::{AllocationId, AllocationInfo, BlockId, BlockInfo, BlockMappings, MemoryClass};
|
||||
+pub use memory::{AllocationId, AllocationInfo, BlockCaptureInfo, BlockId, BlockInfo, BlockMappings, MemoryClass};
|
||||
/// `MTLLibrary`: the translator's, read from AIR or a metallib.
|
||||
/// `MTLSamplerDescriptor`: the translator's.
|
||||
pub use metal2vulkan::bind::SamplerDescriptor;
|
||||
diff --git a/crates/metal2vulkan-runtime/src/memory.rs b/crates/metal2vulkan-runtime/src/memory.rs
|
||||
index 173e0858f2e6d07660cafd5f7893aee280f2dcdc..2864f4ba6b48a4892e6d9651548c75a4babcf395 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/memory.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/memory.rs
|
||||
@@ -235,8 +235,28 @@ impl AllocationId {
|
||||
/// device is torn down. It is a range of one allocation, whose one `VkBuffer`, with every buffer
|
||||
/// usage and a device address, spans it; an imported or exported block is the whole of an
|
||||
/// allocation of its own. Only an exported block is exportable.
|
||||
+/// Capture/replay address metadata for restoring a block at its exact Vulkan device address.
|
||||
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
+pub struct BlockCaptureInfo {
|
||||
+ /// Storage mode (`Shared` or `Private`).
|
||||
+ pub class: MemoryClass,
|
||||
+ /// Full parent Vulkan allocation length in bytes.
|
||||
+ pub alloc_len: u64,
|
||||
+ /// Offset of this block inside its parent allocation.
|
||||
+ pub offset: u64,
|
||||
+ /// Block length in bytes.
|
||||
+ pub len: u64,
|
||||
+ /// Guest-visible `VkDeviceAddress` of this block's first byte.
|
||||
+ pub gpu_address: u64,
|
||||
+ /// Opaque capture address of the parent `VkBuffer`.
|
||||
+ pub opaque_buffer_address: u64,
|
||||
+ /// Opaque capture address of the parent `VkDeviceMemory`.
|
||||
+ pub opaque_memory_address: u64,
|
||||
+}
|
||||
+
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
+/// Metadata describing an allocated GPU memory block.
|
||||
pub struct BlockInfo {
|
||||
/// The block's number.
|
||||
pub id: BlockId,
|
||||
@@ -611,6 +631,10 @@ struct Allocation {
|
||||
buffer: vk::Buffer,
|
||||
/// The device address of its first byte.
|
||||
address: u64,
|
||||
+ /// Opaque capture address of `buffer` (0 if capture-replay unsupported).
|
||||
+ opaque_buffer_address: u64,
|
||||
+ /// Opaque capture address of `memory` (0 if capture-replay unsupported).
|
||||
+ opaque_memory_address: u64,
|
||||
len: u64,
|
||||
mapping: Option<Mapping>,
|
||||
device_local: bool,
|
||||
@@ -823,6 +847,8 @@ struct State {
|
||||
/// The internal the block-maker thread took up and is making ([`run`]).
|
||||
making: Option<Internal>,
|
||||
stop: bool,
|
||||
+ replaying: bool,
|
||||
+ making_ahead: bool,
|
||||
next_id: u32,
|
||||
next_allocation: u32,
|
||||
/// The allocations [`BlockMappings::map`] accepted whose unmap has not run.
|
||||
@@ -952,6 +978,8 @@ impl Pool {
|
||||
asked: [true; INTERNALS],
|
||||
making: None,
|
||||
stop: false,
|
||||
+ replaying: false,
|
||||
+ making_ahead: false,
|
||||
next_id: 1,
|
||||
next_allocation: 1,
|
||||
mapped: HashSet::new(),
|
||||
@@ -1368,6 +1396,158 @@ impl Pool {
|
||||
}
|
||||
}
|
||||
|
||||
+ /// Returns capture/replay info for a pool block, if capture-replay is enabled.
|
||||
+ pub(crate) fn capture_info(&self, memory: &Memory) -> Option<BlockCaptureInfo> {
|
||||
+ if memory.own.is_some() {
|
||||
+ return None;
|
||||
+ }
|
||||
+ let state = self.lock();
|
||||
+ let alloc = state.allocations[memory.class.index()]
|
||||
+ .iter()
|
||||
+ .find(|a| a.memory == memory.memory)?;
|
||||
+
|
||||
+ Some(BlockCaptureInfo {
|
||||
+ class: memory.class,
|
||||
+ alloc_len: alloc.len,
|
||||
+ offset: memory.base,
|
||||
+ len: memory.len,
|
||||
+ gpu_address: memory.address,
|
||||
+ opaque_buffer_address: alloc.opaque_buffer_address,
|
||||
+ opaque_memory_address: alloc.opaque_memory_address,
|
||||
+ })
|
||||
+ }
|
||||
+
|
||||
+ /// Replays a previously captured pool block at its exact Vulkan device address.
|
||||
+ pub(crate) fn take_replayed(
|
||||
+ &self,
|
||||
+ core: &Core,
|
||||
+ cap: BlockCaptureInfo,
|
||||
+ site: Site,
|
||||
+ ) -> Result<Memory, Error> {
|
||||
+ let index = cap.class.index();
|
||||
+ // 1. Check if the parent allocation is already present (e.g. another sub-block restored it,
|
||||
+ // or a pre-stocked idle reserve landed at the exact same address!).
|
||||
+ {
|
||||
+ let mut state = self.lock();
|
||||
+ if state.stop {
|
||||
+ return Err(Error::Quiesced);
|
||||
+ }
|
||||
+ let id = number(&mut state)?;
|
||||
+ let want_base = cap.gpu_address.saturating_sub(cap.offset);
|
||||
+ if let Some(alloc) = state.allocations[index].iter_mut().find(|a| {
|
||||
+ a.address == want_base
|
||||
+ && a.opaque_buffer_address == cap.opaque_buffer_address
|
||||
+ && a.opaque_memory_address == cap.opaque_memory_address
|
||||
+ && a.len == cap.alloc_len
|
||||
+ }) {
|
||||
+ if alloc.free.take_at(cap.offset, cap.len) {
|
||||
+ let carve = alloc.carve(cap.offset);
|
||||
+ alloc.live += 1;
|
||||
+ alloc.placed += cap.len;
|
||||
+ alloc.ahead = false;
|
||||
+ self.counters.rise_by(cap.class.placed_gauge(), cap.len);
|
||||
+ self.settle(&mut state, cap.class);
|
||||
+ self.changed.notify_all();
|
||||
+ return Ok(carve.block(id, cap.class, cap.len));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // 2. Pause block-maker ahead allocations, wait for any in-flight ahead make,
|
||||
+ // and purge idle reserve slabs so none collide with the target opaque VA!
|
||||
+ let idle_allocs: Vec<Allocation> = {
|
||||
+ let mut state = self.lock();
|
||||
+ state.replaying = true;
|
||||
+ while state.making_ahead {
|
||||
+ state = self.wait(state);
|
||||
+ }
|
||||
+ // Re-check if an ahead allocation that just finished landed at the exact target VA!
|
||||
+ let want_base = cap.gpu_address.saturating_sub(cap.offset);
|
||||
+ let hit = state.allocations[index].iter_mut().find_map(|a| {
|
||||
+ if a.address == want_base
|
||||
+ && a.opaque_buffer_address == cap.opaque_buffer_address
|
||||
+ && a.opaque_memory_address == cap.opaque_memory_address
|
||||
+ && a.len == cap.alloc_len
|
||||
+ && a.free.take_at(cap.offset, cap.len)
|
||||
+ {
|
||||
+ let carve = a.carve(cap.offset);
|
||||
+ a.live += 1;
|
||||
+ a.placed += cap.len;
|
||||
+ a.ahead = false;
|
||||
+ Some(carve)
|
||||
+ } else {
|
||||
+ None
|
||||
+ }
|
||||
+ });
|
||||
+ if let Some(carve) = hit {
|
||||
+ let id = number(&mut state)?;
|
||||
+ state.replaying = false;
|
||||
+ self.counters.rise_by(cap.class.placed_gauge(), cap.len);
|
||||
+ self.settle(&mut state, cap.class);
|
||||
+ self.changed.notify_all();
|
||||
+ return Ok(carve.block(id, cap.class, cap.len));
|
||||
+ }
|
||||
+ let mut drained = Vec::new();
|
||||
+ for c in MemoryClass::ALL {
|
||||
+ let ci = c.index();
|
||||
+ let mut kept = Vec::new();
|
||||
+ for a in state.allocations[ci].drain(..) {
|
||||
+ if a.live == 0 {
|
||||
+ drained.push(a);
|
||||
+ } else {
|
||||
+ kept.push(a);
|
||||
+ }
|
||||
+ }
|
||||
+ state.allocations[ci] = kept;
|
||||
+ self.settle(&mut state, c);
|
||||
+ }
|
||||
+ drained
|
||||
+ };
|
||||
+ for a in idle_allocs {
|
||||
+ free_idle(core, a);
|
||||
+ }
|
||||
+ // 3. Allocate at the exact captured opaque buffer + memory addresses.
|
||||
+ let alloc_res = make_allocation_ex(
|
||||
+ core,
|
||||
+ cap.class,
|
||||
+ cap.alloc_len,
|
||||
+ Some(site),
|
||||
+ Some((cap.opaque_buffer_address, cap.opaque_memory_address)),
|
||||
+ );
|
||||
+ let mut allocation = match alloc_res {
|
||||
+ Ok(a) => a,
|
||||
+ Err(e) => {
|
||||
+ let mut state = self.lock();
|
||||
+ state.replaying = false;
|
||||
+ self.changed.notify_all();
|
||||
+ return Err(e);
|
||||
+ }
|
||||
+ };
|
||||
+ let mapped = self.map(&allocation, cap.class, true);
|
||||
+ if !mapped {
|
||||
+ free_allocation(core, allocation);
|
||||
+ let mut state = self.lock();
|
||||
+ state.replaying = false;
|
||||
+ self.changed.notify_all();
|
||||
+ return Err(Error::Limit(Limit::AllocationNotMapped {
|
||||
+ class: cap.class,
|
||||
+ len: cap.alloc_len,
|
||||
+ }));
|
||||
+ }
|
||||
+ let ok = allocation.free.take_at(cap.offset, cap.len);
|
||||
+ debug_assert!(ok, "fresh allocation must contain captured block range");
|
||||
+ let mut state = self.lock();
|
||||
+ let id = number(&mut state)?;
|
||||
+ let memory = allocation.carve(cap.offset).block(id, cap.class, cap.len);
|
||||
+ allocation.live = 1;
|
||||
+ allocation.placed = cap.len;
|
||||
+ state.allocations[index].push(allocation);
|
||||
+ state.replaying = false;
|
||||
+ self.counters.rise_by(cap.class.placed_gauge(), cap.len);
|
||||
+ self.settle(&mut state, cap.class);
|
||||
+ self.changed.notify_all();
|
||||
+ Ok(memory)
|
||||
+ }
|
||||
+
|
||||
/// Takes back a block taken with [`take`](Self::take): its bytes are a free range of its
|
||||
/// allocation at once.
|
||||
pub(crate) fn give_back(&self, memory: Memory) {
|
||||
@@ -1788,12 +1968,16 @@ pub(crate) fn run(core: Arc<Core>) {
|
||||
state = pool.lock();
|
||||
continue;
|
||||
}
|
||||
- let wanted = (MemoryClass::ALL.into_iter())
|
||||
- .find(|&class| !state.failed[class.index()] && !state.whole(class));
|
||||
+ let wanted = (!state.replaying).then(|| {
|
||||
+ (MemoryClass::ALL.into_iter())
|
||||
+ .find(|&class| !state.failed[class.index()] && !state.whole(class))
|
||||
+ }).flatten();
|
||||
if let Some(class) = wanted {
|
||||
+ state.making_ahead = true;
|
||||
drop(state);
|
||||
let made = ahead(&core, class);
|
||||
state = pool.lock();
|
||||
+ state.making_ahead = false;
|
||||
match made {
|
||||
// Idle from now: the reserve, which the idle rule does not weigh.
|
||||
Some(mut allocation) => {
|
||||
@@ -2022,6 +2206,16 @@ fn make_allocation(
|
||||
class: MemoryClass,
|
||||
len: u64,
|
||||
site: Option<Site>,
|
||||
+) -> Result<Allocation, Error> {
|
||||
+ make_allocation_ex(core, class, len, site, None)
|
||||
+}
|
||||
+
|
||||
+fn make_allocation_ex(
|
||||
+ core: &Core,
|
||||
+ class: MemoryClass,
|
||||
+ len: u64,
|
||||
+ site: Option<Site>,
|
||||
+ replay: Option<(u64, u64)>,
|
||||
) -> Result<Allocation, Error> {
|
||||
let device = &core.device;
|
||||
let (id, freed_at) = {
|
||||
@@ -2031,22 +2225,38 @@ fn make_allocation(
|
||||
state.freed_at[class.index()],
|
||||
)
|
||||
};
|
||||
- let info = vk::BufferCreateInfo::default()
|
||||
+ let mut buf_opaque = vk::BufferOpaqueCaptureAddressCreateInfo::default()
|
||||
+ .opaque_capture_address(replay.map_or(0, |(b, _)| b));
|
||||
+ let mut info = vk::BufferCreateInfo::default()
|
||||
.size(len)
|
||||
.usage(floor::BUFFER_USAGE)
|
||||
.sharing_mode(vk::SharingMode::EXCLUSIVE);
|
||||
+ if core.capture_replay {
|
||||
+ info = info.flags(vk::BufferCreateFlags::DEVICE_ADDRESS_CAPTURE_REPLAY);
|
||||
+ if replay.is_some_and(|(b, _)| b != 0) {
|
||||
+ info = info.push_next(&mut buf_opaque);
|
||||
+ }
|
||||
+ }
|
||||
// SAFETY: the device is live, and the create info valid: `len` is at most its
|
||||
// `maxBufferSize`.
|
||||
let buffer =
|
||||
unsafe { device.create_buffer(&info, None) }.map_err(Error::vulkan("vkCreateBuffer"))?;
|
||||
// SAFETY: the buffer is the device's.
|
||||
let requirements = unsafe { device.get_buffer_memory_requirements(buffer) };
|
||||
- let mut flags =
|
||||
- vk::MemoryAllocateFlagsInfo::default().flags(vk::MemoryAllocateFlags::DEVICE_ADDRESS);
|
||||
- let allocate_info = vk::MemoryAllocateInfo::default()
|
||||
+ let mut mem_flags = vk::MemoryAllocateFlags::DEVICE_ADDRESS;
|
||||
+ if core.capture_replay {
|
||||
+ mem_flags |= vk::MemoryAllocateFlags::DEVICE_ADDRESS_CAPTURE_REPLAY;
|
||||
+ }
|
||||
+ let mut flags = vk::MemoryAllocateFlagsInfo::default().flags(mem_flags);
|
||||
+ let mut mem_opaque = vk::MemoryOpaqueCaptureAddressAllocateInfo::default()
|
||||
+ .opaque_capture_address(replay.map_or(0, |(_, m)| m));
|
||||
+ let mut allocate_info = vk::MemoryAllocateInfo::default()
|
||||
.allocation_size(requirements.size.max(len))
|
||||
.memory_type_index(core.memory_type(class))
|
||||
.push_next(&mut flags);
|
||||
+ if core.capture_replay && replay.is_some_and(|(_, m)| m != 0) {
|
||||
+ allocate_info = allocate_info.push_next(&mut mem_opaque);
|
||||
+ }
|
||||
let bits = requirements.memory_type_bits;
|
||||
// SAFETY: the floor chose the memory type for buffers of this usage on this device, and
|
||||
// `bufferDeviceAddress` is enabled; a spill takes a type the buffer's requirements allow.
|
||||
@@ -2065,6 +2275,8 @@ fn make_allocation(
|
||||
memory,
|
||||
buffer,
|
||||
address: 0,
|
||||
+ opaque_buffer_address: 0,
|
||||
+ opaque_memory_address: 0,
|
||||
len,
|
||||
mapping: None,
|
||||
device_local: !spilled && core.device_local & (1 << core.memory_type(class)) != 0,
|
||||
@@ -2101,6 +2313,13 @@ fn make_allocation(
|
||||
let of = vk::BufferDeviceAddressInfo::default().buffer(buffer);
|
||||
// SAFETY: the buffer has device-address usage and is bound.
|
||||
allocation.address = unsafe { device.get_buffer_device_address(&of) };
|
||||
+ if core.capture_replay {
|
||||
+ allocation.opaque_buffer_address =
|
||||
+ unsafe { device.get_buffer_opaque_capture_address(&of) };
|
||||
+ let mof = vk::DeviceMemoryOpaqueCaptureAddressInfo::default().memory(memory);
|
||||
+ allocation.opaque_memory_address =
|
||||
+ unsafe { device.get_device_memory_opaque_capture_address(&mof) };
|
||||
+ }
|
||||
(core.spans).made(
|
||||
buffer,
|
||||
allocation.address,
|
||||
diff --git a/crates/metal2vulkan-runtime/src/places.rs b/crates/metal2vulkan-runtime/src/places.rs
|
||||
index 137fb5790de850552affd179497df69d9912266a..3d679bbaa5285e87d1639a7cc140e0025b49e84f 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/places.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/places.rs
|
||||
@@ -248,6 +248,33 @@ impl Ranges {
|
||||
Some(at)
|
||||
}
|
||||
|
||||
+ /// Takes the exact range `at..at + len` if it is completely free.
|
||||
+ pub(crate) fn take_at(&mut self, at: u64, len: u64) -> bool {
|
||||
+ let Some(stop) = at.checked_add(len) else {
|
||||
+ return false;
|
||||
+ };
|
||||
+ let Some(index) = self
|
||||
+ .free
|
||||
+ .iter()
|
||||
+ .position(|&(start, end)| start <= at && stop <= end)
|
||||
+ else {
|
||||
+ return false;
|
||||
+ };
|
||||
+ let (start, end) = self.free[index];
|
||||
+ match (start < at, stop < end) {
|
||||
+ (false, false) => {
|
||||
+ self.free.remove(index);
|
||||
+ }
|
||||
+ (true, false) => self.free[index] = (start, at),
|
||||
+ (false, true) => self.free[index] = (stop, end),
|
||||
+ (true, true) => {
|
||||
+ self.free[index] = (start, at);
|
||||
+ self.free.insert(index + 1, (stop, end));
|
||||
+ }
|
||||
+ }
|
||||
+ true
|
||||
+ }
|
||||
+
|
||||
/// Frees `offset..offset + len`, taken before, joining it to the free ranges beside it.
|
||||
pub(crate) fn give(&mut self, offset: u64, len: u64) {
|
||||
let end = offset + len;
|
||||
@@ -1,120 +0,0 @@
|
||||
diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md
|
||||
index 083011698..bec52546a 100644
|
||||
--- a/crates/metal2vulkan-runtime/README.md
|
||||
+++ b/crates/metal2vulkan-runtime/README.md
|
||||
@@ -4710,8 +4710,8 @@ cache is answered compile-required on both.
|
||||
from the layout the pass renders it in, the rest from home), and the rendering begins again
|
||||
with the attachment in that layout; the pass's second barrier moves the whole image home. Until then every draw of the
|
||||
pass reads the image's textures through their second elements (Set 1), a texture that reaches
|
||||
- no rendered level among them. Render pipelines declare `VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT`;
|
||||
- the encoder enables color feedback while an attachment is in the feedback layout. Each draw that
|
||||
+ no rendered level among them. Eligible render pipelines declare
|
||||
+ `VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT`. Each draw that
|
||||
reads an attachment through the loop, through a texture or by a fetch (below), counts in
|
||||
`Metrics::attachment_loop_reads`, its barriers in `Metrics::barriers`.
|
||||
- Through a copy, on a device without the feedback loop, and for a surface plane whose image took
|
||||
@@ -5494,7 +5494,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
|
||||
| `VK_KHR_portability_enumeration` | instance, where offered | listing portability devices, each checked against the floor as any other |
|
||||
| `VK_KHR_portability_subset` | device, where listed | Vulkan requires it enabled where a device lists it; the device is asked for the portability features below |
|
||||
| `VK_EXT_attachment_feedback_loop_layout` | device, with the feedback loop | a draw's read of an attachment of its own pass through a texture in the feedback layout |
|
||||
-| `VK_EXT_attachment_feedback_loop_dynamic_state` | device, with the feedback loop | enables feedback for the color aspect while an attachment is in the feedback layout |
|
||||
+| `VK_EXT_attachment_feedback_loop_dynamic_state` | device, with the feedback loop | qualifies the device for native attachment feedback |
|
||||
| `VK_KHR_vertex_attribute_divisor` | device, where listed | a vertex layout stepped per instance at a rate above 1, through the step-rate feature below |
|
||||
| `VK_EXT_vertex_attribute_divisor` | device, where listed | the same, on a device that lists only this extension, which the KHR was promoted from with the same feature and pipeline structures |
|
||||
| `VK_EXT_external_memory_host` | device, where listed | importing host memory by its address (`Device::import_host_memory`) |
|
||||
@@ -5845,7 +5845,7 @@ a copy of the image into its shadow (Render encoders), a known gap.
|
||||
| Attachment-read feature | Structure | Used for |
|
||||
|---|---|---|
|
||||
| `attachmentFeedbackLoopLayout` | `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT` | the feedback layout and usage |
|
||||
-| `attachmentFeedbackLoopDynamicState` | `VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT` | enables feedback for the color aspect at draw time |
|
||||
+| `attachmentFeedbackLoopDynamicState` | `VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT` | qualifies the device for native attachment feedback |
|
||||
|
||||
### Bound kernel buffers
|
||||
|
||||
diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs
|
||||
index 89ceff148..53a5dfd6e 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/render.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/render.rs
|
||||
@@ -1513,11 +1513,6 @@ impl RenderCompiled {
|
||||
.discard
|
||||
.then_some(vk::DynamicState::RASTERIZER_DISCARD_ENABLE),
|
||||
)
|
||||
- .chain(
|
||||
- core.feedback_loop
|
||||
- .as_ref()
|
||||
- .map(|_| vk::DynamicState::ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT),
|
||||
- )
|
||||
.collect();
|
||||
let dynamic_states = vk::PipelineDynamicStateCreateInfo::default().dynamic_states(&states);
|
||||
let mut rendering = vk::PipelineRenderingCreateInfo::default()
|
||||
@@ -1525,6 +1520,13 @@ impl RenderCompiled {
|
||||
.depth_attachment_format(fixed.depth)
|
||||
.stencil_attachment_format(fixed.stencil);
|
||||
let mut info = vk::GraphicsPipelineCreateInfo::default()
|
||||
+ // The attachments a draw can sample depend on its bindings. Declare color
|
||||
+ // feedback on every eligible pipeline without changing the feature gate.
|
||||
+ .flags(if core.feedback_loop.is_some() {
|
||||
+ vk::PipelineCreateFlags::COLOR_ATTACHMENT_FEEDBACK_LOOP_EXT
|
||||
+ } else {
|
||||
+ vk::PipelineCreateFlags::empty()
|
||||
+ })
|
||||
.push_next(&mut rendering)
|
||||
.stages(&stages)
|
||||
.vertex_input_state(&vertex_input)
|
||||
diff --git a/crates/metal2vulkan-runtime/src/render_encoder.rs b/crates/metal2vulkan-runtime/src/render_encoder.rs
|
||||
index bd43630a4..b2c27c940 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/render_encoder.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/render_encoder.rs
|
||||
@@ -34,8 +34,8 @@
|
||||
//! attachment layout, the rest from home), and the rendering begins again with the attachment in
|
||||
//! that layout; the pass's second barrier moves the whole image home. While it is there, every
|
||||
//! draw of the pass reads the image's textures through their elements in that layout
|
||||
-//! (`crate::arrays`). Render pipelines declare dynamic feedback state. The encoder enables
|
||||
-//! color feedback for draws while an attachment is in the feedback layout.
|
||||
+//! (`crate::arrays`). Render pipelines on a device with native feedback use the
|
||||
+//! static color-attachment feedback flag.
|
||||
//!
|
||||
//! What such a draw reads that an earlier draw of the pass rendered, Metal orders by a memory
|
||||
//! barrier between the two. A memory barrier after draws that wrote no memory, where the pass
|
||||
@@ -2741,14 +2741,6 @@ impl RenderCommandEncoder {
|
||||
core.device.cmd_set_rasterizer_discard_enable(command, true);
|
||||
}
|
||||
}
|
||||
- if let Some(feedback) = &core.feedback_loop {
|
||||
- let aspects = if self.moved.is_empty() {
|
||||
- vk::ImageAspectFlags::empty()
|
||||
- } else {
|
||||
- vk::ImageAspectFlags::COLOR
|
||||
- };
|
||||
- (feedback.fp().cmd_set_attachment_feedback_loop_enable_ext)(command, aspects);
|
||||
- }
|
||||
self.record_state(topology, restart, hidden);
|
||||
// A mode's query begins at its first draw, after what that draw ended the rendering
|
||||
// to record first: the command buffer is inside the pass's rendering, and keeps the
|
||||
diff --git a/crates/metal2vulkan-runtime/src/tests/draw.rs b/crates/metal2vulkan-runtime/src/tests/draw.rs
|
||||
index a7601ae11..c6756f4ac 100644
|
||||
--- a/crates/metal2vulkan-runtime/src/tests/draw.rs
|
||||
+++ b/crates/metal2vulkan-runtime/src/tests/draw.rs
|
||||
@@ -3065,18 +3065,18 @@ define internal void @_GLOBAL__sub_I_() section "air.static_init" {
|
||||
});
|
||||
}
|
||||
|
||||
- /// A draw can sample its attachment with dynamic feedback enabled. The following draw can
|
||||
+ /// A draw can sample its attachment with native feedback enabled. The following draw can
|
||||
/// bind a different pipeline and write to the same attachment in the feedback layout.
|
||||
#[test]
|
||||
- fn a_draw_reads_an_attachment_with_dynamic_feedback() {
|
||||
+ fn a_draw_reads_an_attachment_across_pipeline_changes() {
|
||||
let Some(library) = examples() else {
|
||||
return;
|
||||
};
|
||||
let plain = descriptor(&library, "colored_fragment", PixelFormat::RGBA8Unorm);
|
||||
let own = descriptor(&library, "own_pixel_fragment", PixelFormat::RGBA8Unorm);
|
||||
- each_device("dynamic_feedback", |name, _, device| {
|
||||
+ each_device("feedback_pipeline_change", |name, _, device| {
|
||||
if device.core().feedback_loop.is_none() {
|
||||
- println!("{name}: no dynamic attachment feedback support");
|
||||
+ println!("{name}: no native attachment feedback support");
|
||||
return;
|
||||
}
|
||||
let plain = state(name, &device, &plain);
|
||||
@@ -1,524 +0,0 @@
|
||||
diff --git a/src/http.rs b/src/http.rs
|
||||
index 69aeb817b8dc1ff2cebb91bbcad5d4ad749b1540..777a7d8adf65faaff0f08e228a4165ed48984e42 100644
|
||||
--- a/src/http.rs
|
||||
+++ b/src/http.rs
|
||||
@@ -13,13 +13,15 @@
|
||||
use crate::progress::{self, Reporter};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use std::fs::{File, OpenOptions};
|
||||
-use std::io::{Read, Seek, SeekFrom, Write};
|
||||
+use std::io::{Cursor, Read, Seek, SeekFrom, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
+use std::thread;
|
||||
use std::time::Duration;
|
||||
use ureq::Agent;
|
||||
|
||||
/// The most each request asks for.
|
||||
pub const SEGMENT: u64 = 64 << 20;
|
||||
+const PARALLEL_REQUESTS: usize = 4;
|
||||
/// How long a request may take to send its range: a stall is noticed within this. (On a
|
||||
/// connection too slow to send a whole range in it, each request sends what it can.)
|
||||
pub const SEGMENT_BUDGET: Duration = Duration::from_secs(180);
|
||||
@@ -124,6 +126,8 @@ pub struct Download<'a> {
|
||||
/// For requests the server refuses (401, 403): new headers, such as a fresh asset token.
|
||||
pub refresh: Option<&'a mut dyn FnMut() -> Result<Headers>>,
|
||||
pub user_agent: Option<&'static str>,
|
||||
+ /// Fetch the public installer package in parallel within each checked segment.
|
||||
+ pub parallel: bool,
|
||||
/// Failed requests in a row, with no byte received between them, before it gives up:
|
||||
/// [`MAX_FAILURES`], or fewer when there is another place to download the file from.
|
||||
pub tries: u32,
|
||||
@@ -138,6 +142,7 @@ impl Download<'_> {
|
||||
size: None,
|
||||
refresh: None,
|
||||
user_agent: None,
|
||||
+ parallel: false,
|
||||
tries: MAX_FAILURES,
|
||||
}
|
||||
}
|
||||
@@ -229,6 +234,8 @@ pub fn download(
|
||||
let mut failures = 0u32;
|
||||
let mut bad_chunks = 0u32;
|
||||
let mut buf = vec![0u8; 1 << 18];
|
||||
+ let mut parallel =
|
||||
+ d.parallel && check.verifies() && d.headers.is_empty() && d.user_agent.is_none();
|
||||
r.progress(have, total);
|
||||
|
||||
'requests: loop {
|
||||
@@ -240,94 +247,116 @@ pub fn download(
|
||||
Some(t) => (have + SEGMENT).min(t) - 1,
|
||||
None => have + SEGMENT - 1,
|
||||
};
|
||||
- let mut req = agent
|
||||
- .get(&d.url)
|
||||
- .header("Range", format!("bytes={have}-{end}"));
|
||||
- for (k, v) in &d.headers {
|
||||
- req = req.header(k, v);
|
||||
- }
|
||||
- let mut cfg = req.config().timeout_recv_body(Some(SEGMENT_BUDGET));
|
||||
- if let Some(ua) = d.user_agent {
|
||||
- cfg = cfg.user_agent(ua);
|
||||
- }
|
||||
- let resp = match cfg.build().call() {
|
||||
- Ok(resp) => resp,
|
||||
- Err(e) => {
|
||||
- failures += 1;
|
||||
- retry_or_fail(&mut failures, d.tries, &format!("{e}"), &d.url, r)?;
|
||||
- continue;
|
||||
+ // Keep one segment in memory and commit it through the same ordered
|
||||
+ // writer and chunk checker used by serial downloads.
|
||||
+ let batch = if parallel
|
||||
+ && let Some(size) = total
|
||||
+ && end - have >= (PARALLEL_REQUESTS - 1) as u64
|
||||
+ {
|
||||
+ match read_parallel_segment(agent, &d.url, have, end, size, r) {
|
||||
+ Ok(bytes) => Some(bytes),
|
||||
+ Err(_) => {
|
||||
+ progress::check(r)?;
|
||||
+ parallel = false;
|
||||
+ r.note("Parallel ranges could not be read. Continuing with one connection.");
|
||||
+ None
|
||||
+ }
|
||||
}
|
||||
+ } else {
|
||||
+ None
|
||||
};
|
||||
- let status = resp.status().as_u16();
|
||||
- match status {
|
||||
- 206 => {
|
||||
- let range = resp
|
||||
- .headers()
|
||||
- .get("content-range")
|
||||
- .and_then(|v| v.to_str().ok())
|
||||
- .and_then(content_range)
|
||||
- .with_context(|| format!("{} sent a range without Content-Range", d.url))?;
|
||||
- if range.0 != have {
|
||||
- bail!(
|
||||
- "{} sent bytes from {} when asked for {have}",
|
||||
- d.url,
|
||||
- range.0
|
||||
- );
|
||||
+ let mut body: Box<dyn Read> = if let Some(bytes) = batch {
|
||||
+ Box::new(Cursor::new(bytes))
|
||||
+ } else {
|
||||
+ let mut req = agent
|
||||
+ .get(&d.url)
|
||||
+ .header("Range", format!("bytes={have}-{end}"));
|
||||
+ for (k, v) in &d.headers {
|
||||
+ req = req.header(k, v);
|
||||
+ }
|
||||
+ let mut cfg = req.config().timeout_recv_body(Some(SEGMENT_BUDGET));
|
||||
+ if let Some(ua) = d.user_agent {
|
||||
+ cfg = cfg.user_agent(ua);
|
||||
+ }
|
||||
+ let resp = match cfg.build().call() {
|
||||
+ Ok(resp) => resp,
|
||||
+ Err(e) => {
|
||||
+ failures += 1;
|
||||
+ retry_or_fail(&mut failures, d.tries, &format!("{e}"), &d.url, r)?;
|
||||
+ continue;
|
||||
+ }
|
||||
+ };
|
||||
+ let status = resp.status().as_u16();
|
||||
+ match status {
|
||||
+ 206 => {
|
||||
+ let range = resp
|
||||
+ .headers()
|
||||
+ .get("content-range")
|
||||
+ .and_then(|v| v.to_str().ok())
|
||||
+ .and_then(content_range)
|
||||
+ .with_context(|| format!("{} sent a range without Content-Range", d.url))?;
|
||||
+ if range.0 != have {
|
||||
+ bail!(
|
||||
+ "{} sent bytes from {} when asked for {have}",
|
||||
+ d.url,
|
||||
+ range.0
|
||||
+ );
|
||||
+ }
|
||||
+ match (total, range.1) {
|
||||
+ (Some(t), Some(rt)) if t != rt => bail!(
|
||||
+ "{} is {} long, not the expected {}: it changed on the server",
|
||||
+ d.url,
|
||||
+ rt,
|
||||
+ t
|
||||
+ ),
|
||||
+ (None, Some(rt)) => {
|
||||
+ total = Some(rt);
|
||||
+ r.progress(have, total);
|
||||
+ }
|
||||
+ _ => {}
|
||||
+ }
|
||||
}
|
||||
- match (total, range.1) {
|
||||
- (Some(t), Some(rt)) if t != rt => bail!(
|
||||
- "{} is {} long, not the expected {}: it changed on the server",
|
||||
- d.url,
|
||||
- rt,
|
||||
- t
|
||||
- ),
|
||||
- (None, Some(rt)) => {
|
||||
- total = Some(rt);
|
||||
- r.progress(have, total);
|
||||
+ 200 => {
|
||||
+ // The whole file: the server ignored the range.
|
||||
+ if have > 0 {
|
||||
+ cut(file, 0)?;
|
||||
+ have = 0;
|
||||
+ check.restart_at(0);
|
||||
+ }
|
||||
+ if total.is_none() {
|
||||
+ total = resp.body().content_length();
|
||||
}
|
||||
- _ => {}
|
||||
}
|
||||
- }
|
||||
- 200 => {
|
||||
- // The whole file: the server ignored the range.
|
||||
- if have > 0 {
|
||||
+ 416 if total.is_some_and(|t| have >= t) => break,
|
||||
+ 416 => {
|
||||
+ // Past the end: the file on the server is shorter than what we have.
|
||||
+ if have == 0 {
|
||||
+ bail!("{} refused every range", d.url);
|
||||
+ }
|
||||
+ r.note("The file changed on the server: starting over");
|
||||
cut(file, 0)?;
|
||||
have = 0;
|
||||
check.restart_at(0);
|
||||
+ continue;
|
||||
}
|
||||
- if total.is_none() {
|
||||
- total = resp.body().content_length();
|
||||
- }
|
||||
- }
|
||||
- 416 if total.is_some_and(|t| have >= t) => break,
|
||||
- 416 => {
|
||||
- // Past the end: the file on the server is shorter than what we have.
|
||||
- if have == 0 {
|
||||
- bail!("{} refused every range", d.url);
|
||||
+ 401 | 403 if d.refresh.is_some() && failures < 3 => {
|
||||
+ failures += 1;
|
||||
+ if let Some(f) = d.refresh.as_mut() {
|
||||
+ d.headers = f()?;
|
||||
+ }
|
||||
+ continue;
|
||||
}
|
||||
- r.note("The file changed on the server: starting over");
|
||||
- cut(file, 0)?;
|
||||
- have = 0;
|
||||
- check.restart_at(0);
|
||||
- continue;
|
||||
- }
|
||||
- 401 | 403 if d.refresh.is_some() && failures < 3 => {
|
||||
- failures += 1;
|
||||
- if let Some(f) = d.refresh.as_mut() {
|
||||
- d.headers = f()?;
|
||||
+ 408 | 429 | 500..=599 => {
|
||||
+ failures += 1;
|
||||
+ retry_or_fail(&mut failures, d.tries, &format!("HTTP {status}"), &d.url, r)?;
|
||||
+ continue;
|
||||
}
|
||||
- continue;
|
||||
- }
|
||||
- 408 | 429 | 500..=599 => {
|
||||
- failures += 1;
|
||||
- retry_or_fail(&mut failures, d.tries, &format!("HTTP {status}"), &d.url, r)?;
|
||||
- continue;
|
||||
+ _ => bail!("{} answered HTTP {status}", d.url),
|
||||
}
|
||||
- _ => bail!("{} answered HTTP {status}", d.url),
|
||||
- }
|
||||
+ Box::new(resp.into_body().into_reader())
|
||||
+ };
|
||||
|
||||
file.seek(SeekFrom::Start(base + have))?;
|
||||
- let mut body = resp.into_body().into_reader();
|
||||
let start = have;
|
||||
loop {
|
||||
if r.cancelled() {
|
||||
@@ -389,6 +418,79 @@ pub fn download(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+fn read_parallel_segment(
|
||||
+ agent: &Agent,
|
||||
+ url: &str,
|
||||
+ start: u64,
|
||||
+ end: u64,
|
||||
+ total: u64,
|
||||
+ r: &dyn Reporter,
|
||||
+) -> Result<Vec<u8>> {
|
||||
+ let mut segment = vec![0; (end - start + 1) as usize];
|
||||
+ let request_size = segment.len().div_ceil(PARALLEL_REQUESTS);
|
||||
+ thread::scope(|scope| -> Result<()> {
|
||||
+ let mut requests = Vec::with_capacity(PARALLEL_REQUESTS);
|
||||
+ for (index, chunk) in segment.chunks_mut(request_size).enumerate() {
|
||||
+ let first = start + (index * request_size) as u64;
|
||||
+ let request = thread::Builder::new().spawn_scoped(scope, move || {
|
||||
+ read_exact_range(agent, url, first, total, chunk, r)
|
||||
+ })?;
|
||||
+ requests.push(request);
|
||||
+ }
|
||||
+ for request in requests {
|
||||
+ request
|
||||
+ .join()
|
||||
+ .map_err(|_| anyhow::anyhow!("range worker failed"))??;
|
||||
+ }
|
||||
+ Ok(())
|
||||
+ })?;
|
||||
+ Ok(segment)
|
||||
+}
|
||||
+
|
||||
+fn read_exact_range(
|
||||
+ agent: &Agent,
|
||||
+ url: &str,
|
||||
+ start: u64,
|
||||
+ total: u64,
|
||||
+ mut remaining: &mut [u8],
|
||||
+ r: &dyn Reporter,
|
||||
+) -> Result<()> {
|
||||
+ let end = start + remaining.len() as u64 - 1;
|
||||
+ progress::check(r)?;
|
||||
+ let response = agent
|
||||
+ .get(url)
|
||||
+ .header("Range", format!("bytes={start}-{end}"))
|
||||
+ .header("Accept-Encoding", "identity")
|
||||
+ .config()
|
||||
+ .timeout_recv_body(Some(SEGMENT_BUDGET))
|
||||
+ .build()
|
||||
+ .call()?;
|
||||
+ let expected = format!("bytes {start}-{end}/{total}");
|
||||
+ if response.status().as_u16() != 206
|
||||
+ || response
|
||||
+ .headers()
|
||||
+ .get("Content-Range")
|
||||
+ .and_then(|value| value.to_str().ok())
|
||||
+ != Some(expected.as_str())
|
||||
+ {
|
||||
+ bail!("server did not return the requested byte range");
|
||||
+ }
|
||||
+ let mut body = response.into_body().into_reader();
|
||||
+ while !remaining.is_empty() {
|
||||
+ progress::check(r)?;
|
||||
+ let n = body.read(remaining)?;
|
||||
+ if n == 0 {
|
||||
+ bail!("range body ended before its declared length");
|
||||
+ }
|
||||
+ remaining = &mut remaining[n..];
|
||||
+ }
|
||||
+ progress::check(r)?;
|
||||
+ if body.read(&mut [0u8; 1])? != 0 {
|
||||
+ bail!("range body exceeded its declared length");
|
||||
+ }
|
||||
+ Ok(())
|
||||
+}
|
||||
+
|
||||
fn retry_or_fail(
|
||||
failures: &mut u32,
|
||||
tries: u32,
|
||||
@@ -455,6 +557,173 @@ pub fn hex(b: &[u8]) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
+ use std::io::{BufRead, BufReader};
|
||||
+ use std::net::{TcpListener, TcpStream};
|
||||
+
|
||||
+ struct Silent;
|
||||
+
|
||||
+ impl Reporter for Silent {
|
||||
+ fn event(&self, _: progress::Event) {}
|
||||
+ }
|
||||
+
|
||||
+ fn read_request(stream: &TcpStream) -> Result<String> {
|
||||
+ stream.set_read_timeout(Some(Duration::from_secs(5)))?;
|
||||
+ let mut reader = BufReader::new(stream);
|
||||
+ let mut range = String::new();
|
||||
+ loop {
|
||||
+ let mut line = String::new();
|
||||
+ if reader.read_line(&mut line)? == 0 || line == "\r\n" {
|
||||
+ break;
|
||||
+ }
|
||||
+ if let Some((name, value)) = line.split_once(':')
|
||||
+ && name.eq_ignore_ascii_case("range")
|
||||
+ {
|
||||
+ range = value.trim().to_string();
|
||||
+ }
|
||||
+ }
|
||||
+ Ok(range)
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn sends_four_ranges_before_waiting_for_their_bodies() -> Result<()> {
|
||||
+ let listener = TcpListener::bind("127.0.0.1:0")?;
|
||||
+ listener.set_nonblocking(true)?;
|
||||
+ let url = format!("http://{}", listener.local_addr()?);
|
||||
+ let server = thread::spawn(move || -> Result<()> {
|
||||
+ let deadline = std::time::Instant::now() + Duration::from_secs(5);
|
||||
+ let mut requests = std::collections::BTreeMap::new();
|
||||
+ while requests.len() < 4 {
|
||||
+ match listener.accept() {
|
||||
+ Ok((stream, _)) => {
|
||||
+ let range = read_request(&stream)?;
|
||||
+ requests.insert(range, stream);
|
||||
+ }
|
||||
+ Err(e)
|
||||
+ if e.kind() == std::io::ErrorKind::WouldBlock
|
||||
+ && std::time::Instant::now() < deadline =>
|
||||
+ {
|
||||
+ thread::sleep(Duration::from_millis(5));
|
||||
+ }
|
||||
+ Err(e) => {
|
||||
+ return Err(e).context("waiting for four simultaneous range requests");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // No worker gets a response until all four requests have arrived.
|
||||
+ let data = b"abcdefghijklmnop";
|
||||
+ for offset in (0..data.len()).step_by(4).rev() {
|
||||
+ let mut stream = requests
|
||||
+ .remove(&format!("bytes={offset}-{}", offset + 3))
|
||||
+ .context("missing requested range")?;
|
||||
+ write!(
|
||||
+ stream,
|
||||
+ "HTTP/1.1 206 Partial Content\r\nContent-Length: 4\r\nContent-Range: bytes {offset}-{}/16\r\nConnection: close\r\n\r\n",
|
||||
+ offset + 3
|
||||
+ )?;
|
||||
+ stream.write_all(&data[offset..offset + 4])?;
|
||||
+ }
|
||||
+ Ok(())
|
||||
+ });
|
||||
+ let data = read_parallel_segment(&test_agent(), &url, 0, 15, 16, &Silent);
|
||||
+ server
|
||||
+ .join()
|
||||
+ .map_err(|_| anyhow::anyhow!("test server failed"))??;
|
||||
+ assert_eq!(data?, b"abcdefghijklmnop");
|
||||
+ Ok(())
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn rejects_ignored_misaligned_and_truncated_ranges() -> Result<()> {
|
||||
+ let listener = TcpListener::bind("127.0.0.1:0")?;
|
||||
+ let url = format!("http://{}", listener.local_addr()?);
|
||||
+ let server = thread::spawn(move || -> Result<()> {
|
||||
+ for reply in [
|
||||
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\nConnection: close\r\n\r\nabcd",
|
||||
+ "HTTP/1.1 206 Partial Content\r\nContent-Length: 4\r\nContent-Range: bytes 5-8/16\r\nConnection: close\r\n\r\nabcd",
|
||||
+ "HTTP/1.1 206 Partial Content\r\nContent-Length: 3\r\nContent-Range: bytes 4-7/16\r\nConnection: close\r\n\r\nabc",
|
||||
+ ] {
|
||||
+ let (mut stream, _) = listener.accept()?;
|
||||
+ read_request(&stream)?;
|
||||
+ stream.write_all(reply.as_bytes())?;
|
||||
+ }
|
||||
+ Ok(())
|
||||
+ });
|
||||
+ let agent = test_agent();
|
||||
+ for _ in 0..3 {
|
||||
+ assert!(read_exact_range(&agent, &url, 4, 16, &mut [0; 4], &Silent).is_err());
|
||||
+ }
|
||||
+ server
|
||||
+ .join()
|
||||
+ .map_err(|_| anyhow::anyhow!("test server failed"))??;
|
||||
+ Ok(())
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn falls_back_to_a_single_request_from_the_verified_prefix() -> Result<()> {
|
||||
+ use crate::chunklist::{ChunkCheck, Chunklist, Signature};
|
||||
+ use sha2::{Digest, Sha256};
|
||||
+
|
||||
+ let data = b"abcdefghijklmnop";
|
||||
+ let listener = TcpListener::bind("127.0.0.1:0")?;
|
||||
+ let url = format!("http://{}", listener.local_addr()?);
|
||||
+ let server = thread::spawn(move || -> Result<()> {
|
||||
+ for _ in 0..PARALLEL_REQUESTS {
|
||||
+ let (mut stream, _) = listener.accept()?;
|
||||
+ read_request(&stream)?;
|
||||
+ stream.write_all(
|
||||
+ b"HTTP/1.1 200 OK\r\nContent-Length: 0\r\nConnection: close\r\n\r\n",
|
||||
+ )?;
|
||||
+ }
|
||||
+ let (mut stream, _) = listener.accept()?;
|
||||
+ assert_eq!(read_request(&stream)?, "bytes=4-15");
|
||||
+ stream.write_all(
|
||||
+ b"HTTP/1.1 206 Partial Content\r\nContent-Length: 12\r\nContent-Range: bytes 4-15/16\r\nConnection: close\r\n\r\n",
|
||||
+ )?;
|
||||
+ stream.write_all(&data[4..])?;
|
||||
+ Ok(())
|
||||
+ });
|
||||
+ let dir = std::env::temp_dir().join(format!("reims-util-fallback-{}", std::process::id()));
|
||||
+ std::fs::create_dir_all(&dir)?;
|
||||
+ let path = dir.join("download");
|
||||
+ std::fs::write(part_path(&path), &data[..4])?;
|
||||
+ let chunks = data
|
||||
+ .chunks_exact(4)
|
||||
+ .map(|chunk| (4, Sha256::digest(chunk).into()))
|
||||
+ .collect();
|
||||
+ let mut check = ChunkCheck::new(Chunklist {
|
||||
+ chunks,
|
||||
+ signature: Signature::Digest,
|
||||
+ });
|
||||
+ let mut request = Download::new(&url, "Test download".into());
|
||||
+ request.size = Some(data.len() as u64);
|
||||
+ request.parallel = true;
|
||||
+ let result = download(
|
||||
+ &test_agent(),
|
||||
+ request,
|
||||
+ Dest::File(&path),
|
||||
+ &mut check,
|
||||
+ &Silent,
|
||||
+ );
|
||||
+ let actual = std::fs::read(&path);
|
||||
+ let _ = std::fs::remove_file(&path);
|
||||
+ let _ = std::fs::remove_file(part_path(&path));
|
||||
+ let _ = std::fs::remove_dir(&dir);
|
||||
+ result?;
|
||||
+ server
|
||||
+ .join()
|
||||
+ .map_err(|_| anyhow::anyhow!("test server failed"))??;
|
||||
+ assert_eq!(actual?, data);
|
||||
+ Ok(())
|
||||
+ }
|
||||
+
|
||||
+ fn test_agent() -> Agent {
|
||||
+ Agent::config_builder()
|
||||
+ .proxy(None)
|
||||
+ .http_status_as_error(false)
|
||||
+ .timeout_global(Some(Duration::from_secs(5)))
|
||||
+ .build()
|
||||
+ .into()
|
||||
+ }
|
||||
|
||||
#[test]
|
||||
fn parses_content_range() {
|
||||
diff --git a/src/installer.rs b/src/installer.rs
|
||||
index 7c17423300c153fd24fe9e031de3a835dcda57e1..265031a5d2ff54e0b8c9b752bad579c5927c5ef1 100644
|
||||
--- a/src/installer.rs
|
||||
+++ b/src/installer.rs
|
||||
@@ -475,6 +475,7 @@ pub fn offline_installer(inst: &Installer, dir: &Path, r: &dyn Reporter) -> Resu
|
||||
progress::check(r)?;
|
||||
let mut d = Download::new(&inst.url, format!("Downloading {}", inst.label()));
|
||||
d.size = Some(inst.size);
|
||||
+ d.parallel = true;
|
||||
let pkg = Dest::Region {
|
||||
file: &mut f,
|
||||
offset: pkg_at,
|
||||
@@ -746,6 +747,7 @@ mod tests {
|
||||
/// macOS 12's and 26's do, through `<target>Applications`), and where it fails after placing
|
||||
/// the app (as Big Sur's does, needing zsh), the app gets the package as SharedSupport.dmg
|
||||
/// and the script starts its startosinstall on the volume.
|
||||
+ #[cfg(unix)]
|
||||
#[test]
|
||||
fn install_script_runs_without_dirname_or_zsh() {
|
||||
use std::os::unix::fs::{PermissionsExt, symlink};
|
||||
diff --git a/src/recovery.rs b/src/recovery.rs
|
||||
index fe4eadc745ac4867802254a53197821acac3d411..11406e790884549b7e4e6b297f29c3a0285c606f 100644
|
||||
--- a/src/recovery.rs
|
||||
+++ b/src/recovery.rs
|
||||
@@ -311,6 +311,7 @@ impl Image {
|
||||
size: Some(self.size()),
|
||||
refresh: Some(&mut refresh),
|
||||
user_agent: Some(USER_AGENT),
|
||||
+ parallel: false,
|
||||
tries: http::MAX_FAILURES,
|
||||
};
|
||||
http::download(&self.agent, d, dest, check, r)
|
||||
@@ -1,12 +1,6 @@
|
||||
# Patch queue, in the order the patches are applied (see patches/README.md).
|
||||
# One patch per line: <target> <file>.
|
||||
# The runtime forks contain the Reims vGPU and QEMU changes.
|
||||
# This queue applies additional patches to their pinned dependencies.
|
||||
# Runtime components are built from the pinned Reims-Go organization forks.
|
||||
# The queue is reserved for temporary patches to those pinned checkouts.
|
||||
# CI (runtime-preview.yml via scripts/apply-patch-series.ps1) and
|
||||
# scripts/pack-runtime.ps1 both read this file; add or retire patches here.
|
||||
reims-util reims-util-parallel-offline-download.patch
|
||||
metal2vulkan metal2vulkan-snapshot-replay.patch
|
||||
metal2vulkan metal2vulkan-psb-address-carry.patch
|
||||
metal2vulkan metal2vulkan-dynamic-attachment-feedback.patch
|
||||
metal2vulkan metal2vulkan-static-attachment-feedback.patch
|
||||
metal2vulkan metal2vulkan-places-texture-pool.patch
|
||||
@@ -138,10 +138,9 @@ if (Test-Path -LiteralPath $runtimeFeatures) {
|
||||
$capabilities = @((Get-Content -Raw -LiteralPath $runtimeFeatures | ConvertFrom-Json).capabilities)
|
||||
}
|
||||
|
||||
# reims-util's pinned commit is a constant in reims-ctl (crates/reims-ctl/src/reims_util.rs, REV).
|
||||
$utilSrc = Get-Content -Raw -LiteralPath (Join-Path $ReimsRepo 'crates\reims-ctl\src\reims_util.rs')
|
||||
if ($utilSrc -notmatch 'pub const REV: &str = "([0-9a-f]{40})"') { throw 'reims-util REV not found in reims_util.rs' }
|
||||
$utilCommit = $Matches[1]
|
||||
$pins = & (Join-Path $PSScriptRoot 'read-runtime-dependencies.ps1') -RuntimeRepo $ReimsRepo
|
||||
$utilCommit = $pins.Util.Rev
|
||||
$m2vCommit = $pins.Metal.Rev
|
||||
$checkouts = Join-Path $CargoHome 'git\checkouts'
|
||||
$utilTree = if ($UtilRepo) {
|
||||
(Resolve-Path -LiteralPath $UtilRepo).Path
|
||||
@@ -154,15 +153,6 @@ if (-not $utilTree) { throw "reims-util source at $utilCommit not found" }
|
||||
$actualUtil = git -C $utilTree rev-parse HEAD
|
||||
if ($LASTEXITCODE -ne 0 -or $actualUtil -ne $utilCommit) { throw "reims-util checkout must be at $utilCommit" }
|
||||
|
||||
# metal2vulkan's pinned commit (workspace Cargo.toml, falling back to Cargo.lock).
|
||||
$cargoToml = Get-Content -Raw -LiteralPath (Join-Path $ReimsRepo 'Cargo.toml')
|
||||
if ($cargoToml -match 'metal2vulkan\s*=\s*\{[^}]*rev\s*=\s*"([0-9a-f]{40})"') {
|
||||
$m2vCommit = $Matches[1]
|
||||
} else {
|
||||
$lock = Get-Content -Raw -LiteralPath (Join-Path $ReimsRepo 'Cargo.lock')
|
||||
if ($lock -notmatch 'metal2vulkan\?rev=([0-9a-f]{40})') { throw 'metal2vulkan rev not found in Cargo.toml or Cargo.lock' }
|
||||
$m2vCommit = $Matches[1]
|
||||
}
|
||||
$m2vTree = if ($Metal2VulkanRepo) {
|
||||
(Resolve-Path -LiteralPath $Metal2VulkanRepo).Path
|
||||
} else {
|
||||
@@ -453,7 +443,9 @@ foreach ($extra in @(
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path "$srcDir\patches" | Out-Null
|
||||
Copy-Item -Path "$bundleDir\patches\*" -Destination "$srcDir\patches\"
|
||||
foreach ($ps in $patchSpecs) {
|
||||
Copy-Item -LiteralPath (Join-Path "$bundleDir\patches" $ps.Name) -Destination "$srcDir\patches\"
|
||||
}
|
||||
Copy-Item -LiteralPath "$bundleDir\MSYS2-PACKAGES.txt" -Destination "$srcDir\MSYS2-PACKAGES.txt"
|
||||
Copy-Item -LiteralPath "$bundleDir\NOTICE.md" -Destination "$srcDir\NOTICE.md"
|
||||
$m2vBuildSteps = if ($byTarget.Contains('metal2vulkan')) {
|
||||
@@ -466,7 +458,7 @@ and point Cargo at the patched checkout via ```$CARGO_HOME/config.toml``:
|
||||
|
||||
$m2vApply
|
||||
cat >> "`${CARGO_HOME:-`$HOME/.cargo}/config.toml" <<EOF
|
||||
[patch."https://github.com/steelbrain/metal2vulkan"]
|
||||
[patch."$($pins.Metal.Url)"]
|
||||
metal2vulkan = { path = "`$(cygpath -m "`$(pwd)/$m2vDir")/crates/metal2vulkan" }
|
||||
metal2vulkan-runtime = { path = "`$(cygpath -m "`$(pwd)/$m2vDir")/crates/metal2vulkan-runtime" }
|
||||
EOF
|
||||
@@ -489,6 +481,14 @@ $utilApply
|
||||
|
||||
"@
|
||||
}
|
||||
$applyRuntimePatches = @(
|
||||
foreach ($ps in $patchSpecs) {
|
||||
switch ($ps.Target) {
|
||||
'reims-vgpu' { " git -C reims-vgpu-$commit apply ../patches/$($ps.Name)" }
|
||||
'vendor/qemu' { " git -C reims-vgpu-$commit/vendor/qemu apply ../../../patches/$($ps.Name)" }
|
||||
}
|
||||
}
|
||||
)
|
||||
Write-Utf8 "$srcDir\README.md" @"
|
||||
# Source for $bundleName
|
||||
|
||||
@@ -498,21 +498,18 @@ Corresponding source for the binaries in ``$bundleName.tar.zst``.
|
||||
| :-- | :-- | :-- |
|
||||
| ``reims-vgpu-$commit/`` | $reimsSource | ``$fullCommit`` |
|
||||
| ``reims-vgpu-$commit/vendor/qemu/`` | $qemuSource | ``$qemuCommit`` |
|
||||
| ``reims-util-$($utilCommit.Substring(0, 7))/`` | https://github.com/steelbrain/reims-util | ``$utilCommit`` |
|
||||
| ``metal2vulkan-$($m2vCommit.Substring(0, 7))/`` | https://github.com/steelbrain/metal2vulkan | ``$m2vCommit`` |
|
||||
| ``reims-util-$($utilCommit.Substring(0, 7))/`` | $($pins.Util.Url) | ``$utilCommit`` |
|
||||
| ``metal2vulkan-$($m2vCommit.Substring(0, 7))/`` | $($pins.Metal.Url) | ``$m2vCommit`` |
|
||||
|
||||
The archive exports the commits above. Apply the patches in ``patches/``
|
||||
before compiling:
|
||||
$(
|
||||
if ($applyRuntimePatches) {
|
||||
"Apply the runtime patches from the archive root.`n`n" + ($applyRuntimePatches -join "`n")
|
||||
}
|
||||
)
|
||||
|
||||
cd reims-vgpu-$commit
|
||||
$((($patchSpecs | Where-Object { $_.Target -eq 'reims-vgpu' } | ForEach-Object { " git apply ../patches/$($_.Name)" }) -join "`n"))
|
||||
cd vendor/qemu
|
||||
$((($patchSpecs | Where-Object { $_.Target -eq 'vendor/qemu' } | ForEach-Object { " git apply ../../../patches/$($_.Name)" }) -join "`n"))
|
||||
|
||||
(``patch -p1`` works too.)
|
||||
$m2vBuildSteps
|
||||
Then build as upstream documents (``scripts/install-ctl.sh``
|
||||
in an MSYS2 CLANG64 shell). The DLLs in ``qemu/bin`` come from the MSYS2
|
||||
From ``reims-vgpu-$commit/``, run ``scripts/install-ctl.sh``
|
||||
in an MSYS2 CLANG64 shell. The DLLs in ``qemu/bin`` come from the MSYS2
|
||||
packages listed in ``MSYS2-PACKAGES.txt``, with links to their sources.
|
||||
$utilBuildSteps
|
||||
"@
|
||||
@@ -532,7 +529,9 @@ $manifest = [ordered]@{
|
||||
full_commit = $fullCommit
|
||||
vendor_qemu_repo = $qemuSource
|
||||
vendor_qemu_commit = $qemuCommit
|
||||
util_repo = $pins.Util.Url
|
||||
util_commit = $utilCommit
|
||||
metal2vulkan_repo = $pins.Metal.Url
|
||||
metal2vulkan_commit = $m2vCommit
|
||||
patches = $patchEntries
|
||||
capabilities = $capabilities
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
param([Parameter(Mandatory)][string]$RuntimeRepo)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$githubUrl = 'https://github\.com/[\w.-]+/[\w.-]+'
|
||||
$util = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'crates/reims-ctl/src/reims_util.rs')
|
||||
$utilUrl = [regex]::Match($util, "pub const REPO: &str = ""($githubUrl)"";").Groups[1].Value
|
||||
$utilRev = [regex]::Match($util, 'pub const REV: &str = "([0-9a-f]{40})";').Groups[1].Value
|
||||
if (-not $utilUrl -or -not $utilRev) { throw 'reims-util REPO or REV is missing from reims_util.rs' }
|
||||
|
||||
$cargo = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'Cargo.toml')
|
||||
$metal = foreach ($name in 'metal2vulkan', 'metal2vulkan-runtime') {
|
||||
$entry = [regex]::Match($cargo, "(?m)^$name\s*=\s*\{([^}]+)\}").Groups[1].Value
|
||||
$url = [regex]::Match($entry, "git\s*=\s*""($githubUrl)""").Groups[1].Value
|
||||
if (-not $url) { throw "$name git URL is missing from Cargo.toml" }
|
||||
$rev = [regex]::Match($entry, 'rev\s*=\s*"([0-9a-f]{40})"').Groups[1].Value
|
||||
if (-not $rev) {
|
||||
$lock = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'Cargo.lock')
|
||||
$pin = '(?m)^source = "git\+' + [regex]::Escape($url) + '\?rev=([0-9a-f]{40})#[0-9a-f]{40}"'
|
||||
$rev = [regex]::Match($lock, $pin).Groups[1].Value
|
||||
}
|
||||
if (-not $rev) { throw "$name revision is missing from Cargo.toml and Cargo.lock" }
|
||||
[pscustomobject]@{ Url = $url; Rev = $rev }
|
||||
}
|
||||
if ($metal[0].Url -cne $metal[1].Url -or $metal[0].Rev -cne $metal[1].Rev) {
|
||||
throw 'metal2vulkan and metal2vulkan-runtime must use the same repository and commit'
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
Util = [pscustomobject]@{ Url = $utilUrl; Rev = $utilRev }
|
||||
Metal = $metal[0]
|
||||
}
|
||||
Reference in new issue
Block a user