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]

[src]

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()
};

[src]

Builds a new empty pipeline cache.

Example

use vulkano::pipeline::cache::PipelineCache;
let cache = PipelineCache::empty(device.clone()).unwrap();

[src]

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.

[src]

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]

The type of the object.

TYPE: DebugReportObjectTypeEXT = vk::DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT

The DebugReportObjectTypeEXT of the internal Vulkan handle.

[src]

Returns a reference to the object.

impl Drop for PipelineCache
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl Send for PipelineCache

impl Sync for PipelineCache