Struct vulkano::pipeline::cache::PipelineCache [−][src]
pub struct PipelineCache { /* fields omitted */ }
Opaque cache that contains pipeline objects.
See the documentation of the module for more info.
Methods
impl PipelineCache
[src]
impl PipelineCache
pub unsafe fn with_data(
device: Arc<Device>,
initial_data: &[u8]
) -> Result<Arc<PipelineCache>, OomError>
[src]
pub unsafe fn with_data(
device: Arc<Device>,
initial_data: &[u8]
) -> Result<Arc<PipelineCache>, OomError>
Builds a new pipeline cache from existing data. The data must have been previously obtained
with get_data
.
The data passed to this function will most likely be blindly trusted by the Vulkan implementation. Therefore you can easily crash your application or the system by passing wrong data. Hence why this function is unsafe.
Example
This example loads a cache from a file, if it exists.
See get_data
for how to store the data in a file.
TODO: there's a header in the cached data that must be checked ; talk about this
use std::fs::File; use std::io::Read; use vulkano::pipeline::cache::PipelineCache; let data = { let file = File::open("pipeline_cache.bin"); if let Ok(mut file) = file { let mut data = Vec::new(); if let Ok(_) = file.read_to_end(&mut data) { Some(data) } else { None } } else { None } }; let cache = if let Some(data) = data { // This is unsafe because there is no way to be sure that the file contains valid data. unsafe { PipelineCache::with_data(device.clone(), &data).unwrap() } } else { PipelineCache::empty(device.clone()).unwrap() };
pub fn empty(device: Arc<Device>) -> Result<Arc<PipelineCache>, OomError>
[src]
pub fn empty(device: Arc<Device>) -> Result<Arc<PipelineCache>, OomError>
Builds a new empty pipeline cache.
Example
use vulkano::pipeline::cache::PipelineCache; let cache = PipelineCache::empty(device.clone()).unwrap();
pub fn merge<'a, I>(&self, pipelines: I) -> Result<(), OomError> where
I: IntoIterator<Item = &'a &'a Arc<PipelineCache>>,
[src]
pub fn merge<'a, I>(&self, pipelines: I) -> Result<(), OomError> where
I: IntoIterator<Item = &'a &'a Arc<PipelineCache>>,
Merges other pipeline caches into this one.
It is self
that is modified here. The pipeline caches passed as parameter are untouched.
Panic
- Panics if
self
is included in the list of other pipelines.
pub fn get_data(&self) -> Result<Vec<u8>, OomError>
[src]
pub fn get_data(&self) -> Result<Vec<u8>, OomError>
Obtains the data from the cache.
This data can be stored and then reloaded and passed to PipelineCache::with_data
.
Example
This example stores the data of a pipeline cache on the disk.
See with_data
for how to reload it.
use std::fs; use std::fs::File; use std::io::Write; // If an error happens (eg. no permission for the file) we simply skip storing the cache. if let Ok(data) = cache.get_data() { if let Ok(mut file) = File::create("pipeline_cache.bin.tmp") { if let Ok(_) = file.write_all(&data) { let _ = fs::rename("pipeline_cache.bin.tmp", "pipeline_cache.bin"); } else { let _ = fs::remove_file("pipeline_cache.bin.tmp"); } } }
Trait Implementations
impl VulkanObject for PipelineCache
[src]
impl VulkanObject for PipelineCache
type Object = PipelineCache
The type of the object.
const TYPE: DebugReportObjectTypeEXT
TYPE: DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT
The DebugReportObjectTypeEXT
of the internal Vulkan handle.
fn internal_object(&self) -> PipelineCache
[src]
fn internal_object(&self) -> PipelineCache
Returns a reference to the object.
impl Drop for PipelineCache
[src]
impl Drop for PipelineCache
Auto Trait Implementations
impl Send for PipelineCache
impl Send for PipelineCache
impl Sync for PipelineCache
impl Sync for PipelineCache