mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 22:34:43 +00:00
Fix Instance
example (#872)
This commit is contained in:
parent
6b8938fe26
commit
d80d5a6791
@ -6,6 +6,8 @@
|
||||
- Added `vulkano_win::create_vk_surface` which allows creating a surface safely without taking ownership of
|
||||
the window.
|
||||
- `AutoCommandBufferBuilder::draw` and friends no longer consume the `DynamicState` argument, allowing reuse between calls.
|
||||
- `Instance::new` and `Instance::with_loader` now take in the layers as an iterator of borrowed `str`s, not of references to
|
||||
borrowed `str`s.
|
||||
|
||||
# Version 0.9.0 (2018-03-13)
|
||||
|
||||
|
@ -50,7 +50,7 @@ fn main() {
|
||||
|
||||
// NOTE: To simplify the example code we won't verify these layer(s) are actually in the layers list:
|
||||
let layer = "VK_LAYER_LUNARG_standard_validation";
|
||||
let layers = vec![&layer];
|
||||
let layers = vec![layer];
|
||||
|
||||
// Important: pass the extension(s) and layer(s) when creating the vulkano instance
|
||||
let instance = Instance::new(None, &extensions, layers).expect("failed to create Vulkan instance");
|
||||
|
@ -30,7 +30,7 @@ fn main() {
|
||||
// `triangle` example if you haven't done so yet.
|
||||
|
||||
let extensions = vulkano_win::required_extensions();
|
||||
let instance = vulkano::instance::Instance::new(None, &extensions, &[]).expect("failed to create instance");
|
||||
let instance = vulkano::instance::Instance::new(None, &extensions, None).expect("failed to create instance");
|
||||
|
||||
let physical = vulkano::instance::PhysicalDevice::enumerate(&instance)
|
||||
.next().expect("no device available");
|
||||
@ -162,7 +162,7 @@ fn main() {
|
||||
dimensions = surface.capabilities(physical)
|
||||
.expect("failed to get surface capabilities")
|
||||
.current_extent.unwrap_or([1024, 768]);
|
||||
|
||||
|
||||
let (new_swapchain, new_images) = match swapchain.recreate_with_dimension(dimensions) {
|
||||
Ok(r) => r,
|
||||
Err(vulkano::swapchain::SwapchainCreationError::UnsupportedDimensions) => {
|
||||
|
@ -68,19 +68,25 @@ use version::Version;
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// // FIXME: this example doesn't run because of ownership problems ; Instance::new() needs a tweak
|
||||
/// use vulkano::instance;
|
||||
/// use vulkano::instance::Instance;
|
||||
/// use vulkano::instance::InstanceExtensions;
|
||||
///
|
||||
/// // For the sake of the example, we activate all the layers that contain the word "foo" in their
|
||||
/// // description.
|
||||
/// let layers = instance::layers_list().unwrap()
|
||||
/// ```
|
||||
/// # use vulkano::instance;
|
||||
/// # use vulkano::instance::Instance;
|
||||
/// # use vulkano::instance::InstanceExtensions;
|
||||
/// # use std::sync::Arc;
|
||||
/// # use std::error::Error;
|
||||
/// # fn test() -> Result<Arc<Instance>, Box<Error>> {
|
||||
/// // For the sake of the example, we activate all the layers that
|
||||
/// // contain the word "foo" in their description.
|
||||
/// let layers: Vec<_> = instance::layers_list()?
|
||||
/// .filter(|l| l.description().contains("foo"))
|
||||
/// .collect();
|
||||
///
|
||||
/// let layer_names = layers.iter()
|
||||
/// .map(|l| l.name());
|
||||
///
|
||||
/// let instance = Instance::new(None, &InstanceExtensions::none(), layers).unwrap();
|
||||
/// let instance = Instance::new(None, &InstanceExtensions::none(), layer_names)?;
|
||||
/// # Ok(instance)
|
||||
/// # }
|
||||
/// ```
|
||||
// TODO: mention that extensions must be supported by layers as well
|
||||
pub struct Instance {
|
||||
@ -127,12 +133,12 @@ impl Instance {
|
||||
// the choice to Vulkan
|
||||
pub fn new<'a, L, Ext>(app_infos: Option<&ApplicationInfo>, extensions: Ext, layers: L)
|
||||
-> Result<Arc<Instance>, InstanceCreationError>
|
||||
where L: IntoIterator<Item = &'a &'a str>,
|
||||
where L: IntoIterator<Item = &'a str>,
|
||||
Ext: Into<RawInstanceExtensions>
|
||||
{
|
||||
let layers = layers
|
||||
.into_iter()
|
||||
.map(|&layer| CString::new(layer).unwrap())
|
||||
.map(|layer| CString::new(layer).unwrap())
|
||||
.collect::<SmallVec<[_; 16]>>();
|
||||
|
||||
Instance::new_inner(app_infos,
|
||||
@ -145,12 +151,12 @@ impl Instance {
|
||||
pub fn with_loader<'a, L, Ext>(loader: FunctionPointers<Box<Loader + Send + Sync>>,
|
||||
app_infos: Option<&ApplicationInfo>, extensions: Ext, layers: L)
|
||||
-> Result<Arc<Instance>, InstanceCreationError>
|
||||
where L: IntoIterator<Item = &'a &'a str>,
|
||||
where L: IntoIterator<Item = &'a str>,
|
||||
Ext: Into<RawInstanceExtensions>
|
||||
{
|
||||
let layers = layers
|
||||
.into_iter()
|
||||
.map(|&layer| CString::new(layer).unwrap())
|
||||
.map(|layer| CString::new(layer).unwrap())
|
||||
.collect::<SmallVec<[_; 16]>>();
|
||||
|
||||
Instance::new_inner(app_infos,
|
||||
|
Loading…
Reference in New Issue
Block a user