Every pipeline making reports what its driver found, so no found record is written again
What: the runtime's own pipelines were made through the shader cache with no
VK_EXT_pipeline_creation_feedback: its owned kernels, the depth, stencil and planes split
kernels, and the draws of its copies, resolves and planes steps. So each such making read the
driver's data back and compared its SHA-256 with what the cache was loaded with. Two functions of
DeviceShared now make every pipeline that goes through a record, each chaining the feedback:
make_compute_pipeline makes a program's compute pipelines and the runtime's kernels, and
make_graphics_pipeline makes the libraries of shaders a render pipeline is linked from and the
runtime's draws. A making the driver reports found in the cache its record loaded reads nothing
back and writes nothing (driver_data_found). Its report counts in driver_pipeline_hits and
misses. The unreported DeviceShared::make_pipelines, which nothing calls now, is gone. The
whole render pipeline's making keeps its own call, which already reported.
Why: RADV's data after a making from its record is now and then not the record's byte for byte
(Mesa 26.2.6 on a Radeon 780M: one byte of over a thousand, at the same length; the previous
commit fixed the libraries of shaders, the cause of the warm flake). The byte comparison took
that for new data and wrote the record again: needless SSD writes at a device's makings of its
helpers.
The negative: tests::driver_pipeline_compile::the_runtime_s_own_kernels_found_in_their_records_write_nothing.
A second device, over the directory where a first device made two of the runtime's kernels
(RowsCopy, VisibilityCombine), makes them again. It must count one report per kernel, with found
== hits, and where both are found it writes no record (driver_saves 0). Without the fix it reads
0 hits and 0 misses and fails.
That proves the missing reports, not drift writes on those two kernels: without the fix their
records were written 0 times in 50 runs on PHOENIX. The drift I measured was on the libraries.
With the fix, a kernel found in its record is neither read back nor written, whatever bytes the
driver returns.
Verified on um790's 780M (RADV PHOENIX via MESA_VK_DEVICE_SELECT=1002:15bf!, Mesa 26.2.6,
release, --cfg m2v_gpu), job 11523:
- The test alone (the negative) failed 50 of 50: 2 kernels made, 0 hits and 0 misses reported,
0 written, 2 loaded.
- With the fix:
- The own-kernel test passed x51: 2 hits, 2 found, 0 written.
- a_library_of_shaders_reports_what_its_driver_found passed x51.
- The warm own-directory test passed x100: 4 found, 0 written.
- tests::warm, shader_cache, driver_pipeline_compile, owned_kernel_builds and owned_pushes:
34 passed.
- The runtime suite (the GPU-hazard filter, the GPU-time tests left out) passed in 2 runs,
1965 tests each.
- runtime_lane::pipeline_records and runtime_lane::cache: 10 passed. The second device read
loads 2, saves 0, found 2, hits 2. The cache lane read 26 makings, each counted once by its
report.
- lavapipe (--cfg m2v_cpu_icd, llvmpipe from Mesa 26.2.6), job 11524: both report tests passed
(each 0 hits, 2 misses, 0 written) and the touched modules passed, 34 tests.
- cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings is clean, plain
and with --cfg m2v_gpu (job 11527).
Not yet run: NVIDIA (the 5080).
(cherry picked from commit f82a8a3b3f192fef6bb7dc74c030797f0a2773eb)
This commit is contained in:
1 parent
1dcb4eb4a6
commit
c0f334eaff
13 files changed
+214
-255
No files matched your search
@@ -540,7 +540,6 @@ fn resolve_pipeline(
|
||||
making: Making,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let shared = device.shared();
|
||||
let raw = shared.vk();
|
||||
let stages = [
|
||||
vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::VERTEX)
|
||||
@@ -582,17 +581,7 @@ fn resolve_pipeline(
|
||||
.layout(made.layout)
|
||||
.render_pass(made.render_pass)
|
||||
.subpass(0);
|
||||
let created = shared
|
||||
.make_pipelines(making, |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_graphics_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
shared.make_graphics_pipeline(making, info)
|
||||
}
|
||||
|
||||
/// The objects one pass's resolves hold until its command buffer completes, and, kept
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
use super::binding_view::VkView;
|
||||
use super::degradation::Degradation;
|
||||
use super::device::{device_error, lock};
|
||||
use super::error::{internal, vulkan, Error};
|
||||
use super::error::{internal, Error};
|
||||
use super::release;
|
||||
use super::render_pass::Target;
|
||||
use super::sample_planes::{pipeline_layout, set_layout, shader_module};
|
||||
@@ -500,17 +500,8 @@ impl Device {
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(kernel.layout);
|
||||
let created = shared
|
||||
.make_pipelines(Making::new("depth split").words(&module.spirv), |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_compute_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
kernel.pipeline = created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))?;
|
||||
kernel.pipeline = shared
|
||||
.make_compute_pipeline(Making::new("depth split").words(&module.spirv), info)?;
|
||||
Ok(())
|
||||
})();
|
||||
match made {
|
||||
@@ -691,7 +682,6 @@ fn depth_pipeline(
|
||||
(colour, making): (bool, Making),
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let shared = device.shared();
|
||||
let raw = shared.vk();
|
||||
let stages = [
|
||||
vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::VERTEX)
|
||||
@@ -749,17 +739,7 @@ fn depth_pipeline(
|
||||
true => info,
|
||||
false => info.depth_stencil_state(&depth_stencil),
|
||||
};
|
||||
let created = shared
|
||||
.make_pipelines(making, |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_graphics_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
shared.make_graphics_pipeline(making, info)
|
||||
}
|
||||
|
||||
/// Make, where they are not yet made, the draw's objects for a destination of `format` at
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
use super::device::{device_error, lock};
|
||||
use super::encoder::EncoderCore;
|
||||
use super::error::{internal, vulkan, Error, RuntimeGap};
|
||||
use super::error::{internal, Error, RuntimeGap};
|
||||
use super::release;
|
||||
use super::render_pass::{PassLayout, Target};
|
||||
use super::resource::ResourceKey;
|
||||
@@ -341,7 +341,6 @@ fn draw_pipeline(
|
||||
(write, making): (ResolveWrite, Making),
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let shared = device.shared();
|
||||
let raw = shared.vk();
|
||||
let stages = [
|
||||
vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::VERTEX)
|
||||
@@ -405,17 +404,7 @@ fn draw_pipeline(
|
||||
.layout(shaders.layout)
|
||||
.render_pass(render_pass)
|
||||
.subpass(0);
|
||||
let created = shared
|
||||
.make_pipelines(making, |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_graphics_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
shared.make_graphics_pipeline(making, info)
|
||||
}
|
||||
|
||||
/// Whether the draws can resolve `aspects` of `source` by `pick` into `into`, and their objects
|
||||
|
||||
@@ -55,7 +55,7 @@ use super::depth_copy::DepthCopyObjects;
|
||||
use super::depth_stencil_resolve::DepthStencilResolveObjects;
|
||||
use super::draw_source::{sized_index_bind, SizedIndexBind};
|
||||
use super::dynamic_state::{ColorWriteMasks, ExtendedDynamicState};
|
||||
use super::error::{vulkan, Error};
|
||||
use super::error::{internal, vulkan, Error};
|
||||
use super::exit_guard::{self, Call};
|
||||
use super::freed_memory::Parking;
|
||||
use super::function_table::TableShared;
|
||||
@@ -79,7 +79,8 @@ use super::resource_ids::{PassingHolds, ResourceIds, SamplerIdReads};
|
||||
use super::sample_planes::PlanesObjects;
|
||||
use super::sampler::{LiveSamplers, SamplerCount};
|
||||
use super::scheduler::Scheduler;
|
||||
use super::shader_cache::{CacheSetup, ShaderCache};
|
||||
use super::shader_cache::driver::Making;
|
||||
use super::shader_cache::{found_in_cache, CacheSetup, ShaderCache, REPORTED_STAGES};
|
||||
use super::sharing::Sharing;
|
||||
use super::spares::Spares;
|
||||
use super::sparse::device::SparseDevice;
|
||||
@@ -690,25 +691,16 @@ impl DeviceShared {
|
||||
}
|
||||
|
||||
/// What `create` makes with the `VkPipelineCache` it is handed, its `vkCreate*Pipelines` call:
|
||||
/// a cache of the making's own, seeded from the record `making` names
|
||||
/// (`ShaderCache::make_pipelines`, `shader_cache/driver.rs`). On a pool's thread the exit waits
|
||||
/// for it longer (`exit_guard::driver_making`).
|
||||
pub(crate) fn make_pipelines<T, E>(
|
||||
&self,
|
||||
making: crate::shader_cache::driver::Making,
|
||||
create: impl FnOnce(vk::PipelineCache) -> Result<T, E>,
|
||||
) -> Result<T, E> {
|
||||
self.make_pipelines_reported(making, |cache| (create(cache), None))
|
||||
}
|
||||
|
||||
/// [`make_pipelines`](Self::make_pipelines), with what the driver reported of the making:
|
||||
/// `create` returns, with what it made, whether the driver found its pipeline in the cache it
|
||||
/// was handed (`shader_cache::found_in_cache`, `None` where it reports nothing). A making
|
||||
/// from its record that the driver reports found reads no data back and writes nothing
|
||||
/// (`shader_cache/driver.rs`).
|
||||
/// the device's cache of the record `making` names, seeded from that record
|
||||
/// (`ShaderCache::make_pipelines`, `shader_cache/driver.rs`). `create` returns, with what it
|
||||
/// made, whether the driver found its pipeline in the cache it was handed
|
||||
/// (`shader_cache::found_in_cache`, `None` where it reports nothing). A making from its record
|
||||
/// that the driver reports found reads no data back and writes nothing
|
||||
/// (`shader_cache/driver.rs`). On a pool's thread the exit waits for it longer
|
||||
/// (`exit_guard::driver_making`).
|
||||
pub(crate) fn make_pipelines_reported<T, E>(
|
||||
&self,
|
||||
making: crate::shader_cache::driver::Making,
|
||||
making: Making,
|
||||
create: impl FnOnce(vk::PipelineCache) -> (Result<T, E>, Option<bool>),
|
||||
) -> Result<T, E> {
|
||||
// What every making is measured to report, withheld inside it (`driver_facts.rs`); a
|
||||
@@ -721,6 +713,92 @@ impl DeviceShared {
|
||||
})
|
||||
}
|
||||
|
||||
/// The compute pipeline of `info`, made as
|
||||
/// [`make_pipelines_reported`](Self::make_pipelines_reported) makes one under the record
|
||||
/// `making` names, with what its driver reports of it where the device's makings report
|
||||
/// (`VK_EXT_pipeline_creation_feedback`, counted in `driver_pipeline_hits` and `misses`): one
|
||||
/// found in a cache loaded from its record reads no data back and writes nothing, whatever
|
||||
/// bytes the driver's data holds after it. A program's compute pipelines and the runtime's
|
||||
/// own kernels.
|
||||
pub(crate) fn make_compute_pipeline(
|
||||
&self,
|
||||
making: Making,
|
||||
info: vk::ComputePipelineCreateInfo<'_>,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let reports = self.shader_cache.driver_reports();
|
||||
let mut whole = vk::PipelineCreationFeedback::default();
|
||||
let mut stage = [vk::PipelineCreationFeedback::default()];
|
||||
let made = self.make_pipelines_reported(making, |cache| {
|
||||
let mut feedback = vk::PipelineCreationFeedbackCreateInfo::default()
|
||||
.pipeline_creation_feedback(&mut whole)
|
||||
.pipeline_stage_creation_feedbacks(&mut stage);
|
||||
let mut info = info;
|
||||
if reports {
|
||||
info = info.push_next(&mut feedback);
|
||||
}
|
||||
// SAFETY: what `info` points to outlives it, and so the call; the cache is the
|
||||
// device's of the record, or none.
|
||||
let made = unsafe { self.vk().create_compute_pipelines(cache, &[info], None) };
|
||||
let found = reports.then(|| found_in_cache(&whole, &stage)).flatten();
|
||||
(made, found)
|
||||
});
|
||||
self.made_one(made, reports.then_some((&whole, &stage[..])))
|
||||
}
|
||||
|
||||
/// The graphics pipeline, or graphics pipeline library, of `info`, made and reported as
|
||||
/// [`make_compute_pipeline`](Self::make_compute_pipeline) makes a compute pipeline: a library
|
||||
/// of shaders of a render pipeline linked from libraries (`pipeline/graphics.rs`), and the
|
||||
/// runtime's own draws (its copies, resolves and planes steps).
|
||||
pub(crate) fn make_graphics_pipeline(
|
||||
&self,
|
||||
making: Making,
|
||||
info: vk::GraphicsPipelineCreateInfo<'_>,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let reports = self.shader_cache.driver_reports();
|
||||
// Its stages' feedback where it has at most `REPORTED_STAGES`, none where more (a count of
|
||||
// 0 is valid, one equal to `stageCount` else:
|
||||
// VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594).
|
||||
let mut whole = vk::PipelineCreationFeedback::default();
|
||||
let mut stages = [vk::PipelineCreationFeedback::default(); REPORTED_STAGES];
|
||||
let count = info.stage_count as usize;
|
||||
let reported = if count <= REPORTED_STAGES { count } else { 0 };
|
||||
let made = self.make_pipelines_reported(making, |cache| {
|
||||
let mut feedback = vk::PipelineCreationFeedbackCreateInfo::default()
|
||||
.pipeline_creation_feedback(&mut whole)
|
||||
.pipeline_stage_creation_feedbacks(&mut stages[..reported]);
|
||||
let mut info = info;
|
||||
if reports {
|
||||
info = info.push_next(&mut feedback);
|
||||
}
|
||||
// SAFETY: as `make_compute_pipeline`'s.
|
||||
let made = unsafe { self.vk().create_graphics_pipelines(cache, &[info], None) };
|
||||
let found = reports
|
||||
.then(|| found_in_cache(&whole, &stages[..reported]))
|
||||
.flatten();
|
||||
(made, found)
|
||||
});
|
||||
self.made_one(made, reports.then_some((&whole, &stages[..reported])))
|
||||
}
|
||||
|
||||
/// The one pipeline a making `made`, with what its driver reported of it, `reported`, counted
|
||||
/// where the making chained the reports and made it.
|
||||
fn made_one(
|
||||
&self,
|
||||
made: Result<Vec<vk::Pipeline>, (Vec<vk::Pipeline>, vk::Result)>,
|
||||
reported: Option<(
|
||||
&vk::PipelineCreationFeedback,
|
||||
&[vk::PipelineCreationFeedback],
|
||||
)>,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let made = made.map_err(|(_, error)| vulkan(error))?;
|
||||
if let Some((whole, stages)) = reported {
|
||||
self.shader_cache.driver_reported(whole, stages);
|
||||
}
|
||||
made.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
}
|
||||
|
||||
/// The device's functions. The runtime's own threads reach them only inside a section of
|
||||
/// the exit guard, or while they run the program's code, and a section reaches only the exit
|
||||
/// guard's table of entry points; builds with debug assertions end the process otherwise
|
||||
|
||||
@@ -965,26 +965,16 @@ fn make(
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(kernel.layout);
|
||||
let created = shared
|
||||
.make_pipelines(
|
||||
Making::new("owned kernel").words(spirv).text(&(
|
||||
images,
|
||||
storage_images,
|
||||
buffers,
|
||||
push_bytes,
|
||||
pushed,
|
||||
)),
|
||||
|cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_compute_pipelines(cache, &[info], None) }
|
||||
},
|
||||
)
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
kernel.pipeline = created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))?;
|
||||
kernel.pipeline = shared.make_compute_pipeline(
|
||||
Making::new("owned kernel").words(spirv).text(&(
|
||||
images,
|
||||
storage_images,
|
||||
buffers,
|
||||
push_bytes,
|
||||
pushed,
|
||||
)),
|
||||
info,
|
||||
)?;
|
||||
Ok(())
|
||||
})();
|
||||
match made {
|
||||
|
||||
@@ -1348,32 +1348,34 @@ impl VariantObjects {
|
||||
vk::GraphicsPipelineLibraryCreateInfoEXT::default().flags(part.flag());
|
||||
let info = infos.part(part, &mut flag);
|
||||
// A part with shaders is made through the device's shader cache, under a record
|
||||
// of its own; one without holds nothing a record would keep.
|
||||
// of its own, with what its driver reports of it; one without holds nothing a
|
||||
// record would keep.
|
||||
let made = match part.holds_shaders() {
|
||||
true => {
|
||||
let _ = creation_log::take_record();
|
||||
let made =
|
||||
self.library_of_shaders(Making::new(part.kind()).digest(name), info);
|
||||
let made = shared
|
||||
.make_graphics_pipeline(Making::new(part.kind()).digest(name), info);
|
||||
made_here = Some(creation_log::take_record());
|
||||
made
|
||||
made?
|
||||
}
|
||||
false => {
|
||||
made_here = Some(None);
|
||||
// SAFETY: every pointer in `info` outlives the call.
|
||||
unsafe {
|
||||
let made = unsafe {
|
||||
shared.vk().create_graphics_pipelines(
|
||||
vk::PipelineCache::null(),
|
||||
&[info],
|
||||
None,
|
||||
)
|
||||
}
|
||||
};
|
||||
made.map_err(|(_, error)| vulkan(error))?
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline library"))?
|
||||
}
|
||||
};
|
||||
let made = made.map_err(|(_, error)| vulkan(error))?;
|
||||
shared.counts.pipeline_library_made(part);
|
||||
made.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline library"))
|
||||
Ok(made)
|
||||
})?;
|
||||
if let Some(at) = asked {
|
||||
let how = match made_here {
|
||||
@@ -1407,50 +1409,6 @@ impl VariantObjects {
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver linked no pipeline"))
|
||||
}
|
||||
|
||||
/// The library of `info`, a part that holds shaders, made through the device's shader cache
|
||||
/// under the record `making` names, with what its driver reports of it as a whole pipeline's
|
||||
/// making has (`shader_cache::found_in_cache`, counted in `driver_pipeline_hits` and
|
||||
/// `misses`): one found in a cache loaded from its record reads no data back and writes
|
||||
/// nothing (`shader_cache/driver.rs`), whatever bytes the driver's data holds after it.
|
||||
fn library_of_shaders(
|
||||
&self,
|
||||
making: Making,
|
||||
info: vk::GraphicsPipelineCreateInfo<'_>,
|
||||
) -> Result<Vec<vk::Pipeline>, (Vec<vk::Pipeline>, vk::Result)> {
|
||||
let shared = self.device.shared();
|
||||
let driver_reports = shared.shader_cache.driver_reports();
|
||||
// Its stages' feedback where it has at most `REPORTED_STAGES`, none where more (a count
|
||||
// of 0 is valid, one equal to `stageCount` else:
|
||||
// VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594).
|
||||
let mut whole = vk::PipelineCreationFeedback::default();
|
||||
let mut stages = [vk::PipelineCreationFeedback::default(); REPORTED_STAGES];
|
||||
let count = info.stage_count as usize;
|
||||
let reported_stages = if count <= REPORTED_STAGES { count } else { 0 };
|
||||
let made = shared.make_pipelines_reported(making, |cache| {
|
||||
let reported = &mut stages[..reported_stages];
|
||||
let mut feedback = vk::PipelineCreationFeedbackCreateInfo::default()
|
||||
.pipeline_creation_feedback(&mut whole)
|
||||
.pipeline_stage_creation_feedbacks(reported);
|
||||
let mut info = info;
|
||||
if driver_reports {
|
||||
info = info.push_next(&mut feedback);
|
||||
}
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// device's for the record, or none.
|
||||
let made = unsafe { shared.vk().create_graphics_pipelines(cache, &[info], None) };
|
||||
let found = driver_reports
|
||||
.then(|| found_in_cache(&whole, &stages[..reported_stages]))
|
||||
.flatten();
|
||||
(made, found)
|
||||
});
|
||||
if driver_reports && made.is_ok() {
|
||||
shared
|
||||
.shader_cache
|
||||
.driver_reported(&whole, &stages[..reported_stages]);
|
||||
}
|
||||
made
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1052,13 +1052,7 @@ impl VariantObjects {
|
||||
if bindable {
|
||||
info = info.push_next(&mut flags);
|
||||
}
|
||||
// Whether the making's cache held it and its one stage, where the making reports them
|
||||
// (`shader_cache::found_in_cache`; one stage's feedback, as
|
||||
// VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566 allows).
|
||||
let mut whole = vk::PipelineCreationFeedback::default();
|
||||
let mut stage = [vk::PipelineCreationFeedback::default()];
|
||||
let shared = self.device.shared();
|
||||
let driver_reports = shared.shader_cache.driver_reports();
|
||||
// Its record is named by the variant's content and what this making adds to it.
|
||||
let making = self.making("compute").text(&(
|
||||
c.object.stage.as_raw(),
|
||||
@@ -1084,34 +1078,10 @@ impl VariantObjects {
|
||||
let started = std::time::Instant::now();
|
||||
// With what the driver reports of the making: a pipeline found in its record's cache
|
||||
// reads no data back (`shader_cache/driver.rs`).
|
||||
let created = shared
|
||||
.make_pipelines_reported(making, |cache| {
|
||||
let mut feedback = vk::PipelineCreationFeedbackCreateInfo::default()
|
||||
.pipeline_creation_feedback(&mut whole)
|
||||
.pipeline_stage_creation_feedbacks(&mut stage);
|
||||
let mut info = info;
|
||||
if driver_reports {
|
||||
info = info.push_next(&mut feedback);
|
||||
}
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own, destroyed once the call returned.
|
||||
let made = unsafe { shared.vk().create_compute_pipelines(cache, &[info], None) };
|
||||
let found = driver_reports
|
||||
.then(|| crate::shader_cache::found_in_cache(&whole, &stage))
|
||||
.flatten();
|
||||
(made, found)
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
let raw = shared.make_compute_pipeline(making, info)?;
|
||||
let created_in = started.elapsed();
|
||||
drop(leader);
|
||||
drop(turn);
|
||||
if driver_reports {
|
||||
shared.shader_cache.driver_reported(&whole, &stage);
|
||||
}
|
||||
let raw = created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))?;
|
||||
self.device.shared().counts.variant_pipeline_made();
|
||||
let pipeline = RawPipeline {
|
||||
device: self.device.clone(),
|
||||
|
||||
@@ -255,20 +255,10 @@ impl Device {
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(kernel.layout);
|
||||
let created = shared
|
||||
.make_pipelines(
|
||||
Making::new("interleave split").words(&module.spirv),
|
||||
|cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_compute_pipelines(cache, &[info], None) }
|
||||
},
|
||||
)
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
kernel.pipeline = created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))?;
|
||||
kernel.pipeline = shared.make_compute_pipeline(
|
||||
Making::new("interleave split").words(&module.spirv),
|
||||
info,
|
||||
)?;
|
||||
Ok(())
|
||||
})();
|
||||
if let Err(error) = made {
|
||||
@@ -431,7 +421,6 @@ fn merge_pipeline(
|
||||
making: Making,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let shared = device.shared();
|
||||
let raw = shared.vk();
|
||||
let stages = [
|
||||
vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::VERTEX)
|
||||
@@ -477,17 +466,7 @@ fn merge_pipeline(
|
||||
.layout(shaders.layout)
|
||||
.render_pass(render_pass)
|
||||
.subpass(0);
|
||||
let created = shared
|
||||
.make_pipelines(making, |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_graphics_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
shared.make_graphics_pipeline(making, info)
|
||||
}
|
||||
|
||||
/// A band's descriptor pool and framebuffer, held until the command buffer completes.
|
||||
|
||||
@@ -467,17 +467,8 @@ impl Device {
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(kernel.layout);
|
||||
let created = shared
|
||||
.make_pipelines(Making::new("planes split").words(&module.spirv), |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_compute_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
kernel.pipeline = created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))?;
|
||||
kernel.pipeline = shared
|
||||
.make_compute_pipeline(Making::new("planes split").words(&module.spirv), info)?;
|
||||
Ok(())
|
||||
})();
|
||||
match made {
|
||||
@@ -651,7 +642,6 @@ fn merge_pipeline(
|
||||
making: Making,
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let shared = device.shared();
|
||||
let raw = shared.vk();
|
||||
let stages = [
|
||||
vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::VERTEX)
|
||||
@@ -697,17 +687,7 @@ fn merge_pipeline(
|
||||
.layout(shaders.layout)
|
||||
.render_pass(render_pass)
|
||||
.subpass(0);
|
||||
let created = shared
|
||||
.make_pipelines(making, |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_graphics_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
shared.make_graphics_pipeline(making, info)
|
||||
}
|
||||
|
||||
/// The objects one pass's planes steps hold until its command buffer completes: their
|
||||
|
||||
@@ -30,14 +30,16 @@
|
||||
//! library map iterates its modules' keys opposite to their insertion), so the byte comparison
|
||||
//! alone wrote every record of two modules again at each warm making. The data's format is
|
||||
//! MoltenVK's own, undocumented beyond Vulkan's header, so no comparison here reads its
|
||||
//! entries. A library of shaders, where the device links its render pipelines from graphics
|
||||
//! pipeline libraries, is made with its driver's report as a whole pipeline is: RADV's data
|
||||
//! after a library's making from its record is now and then not the record's byte for byte,
|
||||
//! one byte of over a thousand differing at the same length (Mesa 26.2.6 on a Radeon 780M:
|
||||
//! both libraries of a state, in 2 runs of 20), which the byte comparison alone took for data
|
||||
//! the making added, and wrote the record again. A making whose driver reports nothing, or
|
||||
//! reports a compile, or whose cache was made empty, reads the data and compares its SHA-256
|
||||
//! with what the cache was loaded with or last wrote.
|
||||
//! entries. Every making asks for the driver's report where the device's makings report
|
||||
//! (`DeviceShared::make_compute_pipeline`, `make_graphics_pipeline`): a program's pipelines,
|
||||
//! the libraries of shaders a render pipeline is linked from, and the runtime's own pipelines
|
||||
//! (its copies, resolves, planes steps and kernels). RADV's data after a making from its record
|
||||
//! is now and then not the record's byte for byte, one byte of over a thousand differing at the
|
||||
//! same length (Mesa 26.2.6 on a Radeon 780M: both libraries of a state, in 2 runs of 20),
|
||||
//! which the byte comparison alone took for data the making added, and wrote the record again.
|
||||
//! A making whose driver reports nothing, or reports a compile, or whose cache was made empty,
|
||||
//! reads the data and compares its SHA-256 with what the cache was loaded with or last
|
||||
//! wrote.
|
||||
//! - **Named by what a stage's conversion reads** ([`Making`]). A record is named by the SHA-256
|
||||
//! of [`VERSION`], the making's description, the driver's identity (vendor, device, driver
|
||||
//! version, `pipelineCacheUUID`) and the digest of the layer settings the instance was created
|
||||
|
||||
@@ -250,7 +250,8 @@ pub struct ShaderCacheStatistics {
|
||||
/// `APPLICATION_PIPELINE_CACHE_HIT`, or every stage's feedback is valid and says it. Drivers
|
||||
/// differ in where they say it: most for the whole pipeline; MoltenVK 1.4.1 for each stage
|
||||
/// alone, whose Metal function it found converted in the cache (its whole pipeline's
|
||||
/// feedback is only ever valid). Where the device links render pipelines from graphics
|
||||
/// feedback is only ever valid). The runtime's own pipelines (its copies, resolves and
|
||||
/// kernels) count as the program's do; where the device links render pipelines from graphics
|
||||
/// pipeline libraries, each library of shaders is such a making (its pre-rasterization or
|
||||
/// fragment shader part), and the link itself is none.
|
||||
pub driver_pipeline_hits: u64,
|
||||
|
||||
@@ -172,17 +172,8 @@ impl Device {
|
||||
let info = vk::ComputePipelineCreateInfo::default()
|
||||
.stage(stage)
|
||||
.layout(kernel.layout);
|
||||
let created = shared
|
||||
.make_pipelines(Making::new("stencil split").words(&module.spirv), |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_compute_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
kernel.pipeline = created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))?;
|
||||
kernel.pipeline = shared
|
||||
.make_compute_pipeline(Making::new("stencil split").words(&module.spirv), info)?;
|
||||
Ok(())
|
||||
})();
|
||||
match made {
|
||||
@@ -377,7 +368,6 @@ fn plane_pipeline(
|
||||
(samples, bit, making): (u32, StencilBit, Making),
|
||||
) -> Result<vk::Pipeline, Error> {
|
||||
let shared = device.shared();
|
||||
let raw = shared.vk();
|
||||
let stages = [
|
||||
vk::PipelineShaderStageCreateInfo::default()
|
||||
.stage(vk::ShaderStageFlags::VERTEX)
|
||||
@@ -435,17 +425,7 @@ fn plane_pipeline(
|
||||
.layout(shaders.layout)
|
||||
.render_pass(render_pass)
|
||||
.subpass(0);
|
||||
let created = shared
|
||||
.make_pipelines(making, |cache| {
|
||||
// SAFETY: every pointer in `info` outlives the call; the pipeline cache is the
|
||||
// making's own (`shader_cache/driver.rs`).
|
||||
unsafe { raw.create_graphics_pipelines(cache, &[info], None) }
|
||||
})
|
||||
.map_err(|(_, error)| vulkan(error))?;
|
||||
created
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or_else(|| internal("the driver made no pipeline"))
|
||||
shared.make_graphics_pipeline(making, info)
|
||||
}
|
||||
|
||||
/// The objects one copy holds until its command buffer completes: its descriptor set's pool and,
|
||||
|
||||
@@ -55,7 +55,9 @@
|
||||
//! **A library of shaders reports what its driver found**, as a whole pipeline's making does: a
|
||||
//! later device over the directory an earlier one wrote counts one report per library of shaders
|
||||
//! it makes, and reads no data back for one found in its record
|
||||
//! (`a_library_of_shaders_reports_what_its_driver_found`).
|
||||
//! (`a_library_of_shaders_reports_what_its_driver_found`). So do the runtime's own kernels, and
|
||||
//! one found in its record writes no record again
|
||||
//! (`the_runtime_s_own_kernels_found_in_their_records_write_nothing`).
|
||||
//!
|
||||
//! The device takes a shader cache directory of its own, empty, so no run reads a record an
|
||||
//! earlier run stored.
|
||||
@@ -66,6 +68,7 @@
|
||||
|
||||
use super::blit_holds::{device, Scratch};
|
||||
use super::descriptor_key_once::descriptor;
|
||||
use crate::owned_kernel::OwnedModule;
|
||||
use crate::PipelineOptions;
|
||||
use metal2vulkan::metal::{BlendFactor, BlendOperation};
|
||||
|
||||
@@ -247,3 +250,63 @@ fn a_library_of_shaders_reports_what_its_driver_found() {
|
||||
assert_eq!(saves, 0, "libraries found in their records write nothing");
|
||||
}
|
||||
}
|
||||
|
||||
/// The runtime's own kernels made again on a later device report what their driver found, and
|
||||
/// those it reports found in the records an earlier device over the same directory wrote write no
|
||||
/// record again (`driver_saves`), whatever bytes the driver's data holds after them: RADV's
|
||||
/// differs from the record's now and then (`shader_cache/driver.rs`), which a byte comparison
|
||||
/// took for new data and wrote the record again at the device's every making of them.
|
||||
#[test]
|
||||
fn the_runtime_s_own_kernels_found_in_their_records_write_nothing() {
|
||||
let scratch = Scratch::new("driver-own-kernels");
|
||||
let kernels = [OwnedModule::RowsCopy, OwnedModule::VisibilityCombine];
|
||||
{
|
||||
let device = device(&scratch.0);
|
||||
let reports = device.shared().shader_cache.driver_reports();
|
||||
if !reports {
|
||||
println!("DRIVER-OWN-KERNELS: not covered (the device's makings report nothing)");
|
||||
return;
|
||||
}
|
||||
for which in kernels {
|
||||
device.owned_kernel(which).unwrap();
|
||||
}
|
||||
}
|
||||
// The first device is gone, so its cache thread wrote what its makings handed it.
|
||||
let device = device(&scratch.0);
|
||||
let before = device.shader_cache_statistics();
|
||||
let counts_before = device.work_counts();
|
||||
for which in kernels {
|
||||
device.owned_kernel(which).unwrap();
|
||||
}
|
||||
let after = device.shader_cache_statistics();
|
||||
let made = device.work_counts().owned_kernels_made - counts_before.owned_kernels_made;
|
||||
let since = |of: fn(&crate::ShaderCacheStatistics) -> u64| of(&after) - of(&before);
|
||||
let (hits, misses) = (
|
||||
since(|s| s.driver_pipeline_hits),
|
||||
since(|s| s.driver_pipeline_misses),
|
||||
);
|
||||
let (found, saves) = (since(|s| s.driver_data_found), since(|s| s.driver_saves));
|
||||
println!(
|
||||
"DRIVER-OWN-KERNELS: {made} kernels made, {hits} hits and {misses} misses reported, \
|
||||
{found} found and read nothing back, {saves} records' data written, {} loaded",
|
||||
since(|s| s.driver_loads)
|
||||
);
|
||||
assert_eq!(
|
||||
made,
|
||||
kernels.len() as u64,
|
||||
"the later device made each kernel"
|
||||
);
|
||||
assert_eq!(
|
||||
hits + misses,
|
||||
made,
|
||||
"each of the runtime's kernels reports what its driver found: {hits} hits and {misses} \
|
||||
misses"
|
||||
);
|
||||
assert_eq!(
|
||||
found, hits,
|
||||
"each kernel its driver reports found in the cache its record loaded reads no data back"
|
||||
);
|
||||
if hits == made {
|
||||
assert_eq!(saves, 0, "kernels found in their records write nothing");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user