mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 08:14:20 +00:00
added code to get to OutOfDeviceMemory error
This commit is contained in:
parent
0dddd6f7e5
commit
40e0b24127
@ -10,3 +10,6 @@ categories = ["rendering::graphics-api"]
|
||||
[dependencies]
|
||||
vulkano = { version = "0.3.0", path = "../vulkano" }
|
||||
winit = "0.6.4"
|
||||
metal-rs = "0.3"
|
||||
cocoa = "0.8.1"
|
||||
objc = ""
|
@ -1,6 +1,10 @@
|
||||
extern crate vulkano;
|
||||
extern crate winit;
|
||||
|
||||
extern crate objc;
|
||||
extern crate cocoa;
|
||||
extern crate metal_rs as metal;
|
||||
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
@ -13,6 +17,15 @@ use vulkano::swapchain::SurfaceCreationError;
|
||||
use winit::{EventsLoop, WindowBuilder};
|
||||
use winit::CreationError as WindowCreationError;
|
||||
|
||||
use objc::runtime::{YES};
|
||||
|
||||
use cocoa::base::id as cocoa_id;
|
||||
use cocoa::appkit::{NSWindow, NSView};
|
||||
|
||||
use metal::*;
|
||||
|
||||
use std::mem;
|
||||
|
||||
pub fn required_extensions() -> InstanceExtensions {
|
||||
let ideal = InstanceExtensions {
|
||||
khr_surface: true,
|
||||
@ -160,5 +173,20 @@ unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window)
|
||||
-> Result<Arc<Surface>, SurfaceCreationError>
|
||||
{
|
||||
use winit::os::macos::WindowExt;
|
||||
|
||||
unsafe {
|
||||
let wnd: cocoa_id = mem::transmute(win.get_nswindow());
|
||||
|
||||
let layer = CAMetalLayer::new();
|
||||
|
||||
layer.set_edge_antialiasing_mask(0);
|
||||
layer.set_presents_with_transaction(false);
|
||||
layer.remove_all_animations();
|
||||
|
||||
let view = wnd.contentView();
|
||||
view.setWantsLayer(YES);
|
||||
view.setLayer(mem::transmute(layer.0)); // Bombs here with out of memory
|
||||
}
|
||||
|
||||
Surface::from_macos_moltenvk(instance, win.get_nsview() as *const ())
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ fn main() {
|
||||
println!("cargo:rustc-link-lib=framework=MoltenVK");
|
||||
println!("cargo:rustc-link-lib=framework=QuartzCore");
|
||||
println!("cargo:rustc-link-lib=framework=Metal");
|
||||
println!("cargo:rustc-link-lib=framework=Foundation");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user