Use latest wgpu

This commit is contained in:
Héctor Ramón Jiménez 2019-10-07 19:50:04 +02:00
parent 67f8da4b34
commit 0995950526
3 changed files with 13 additions and 19 deletions

View file

@ -21,9 +21,6 @@ members = [
"web", "web",
] ]
[features]
vulkan = ["iced_wgpu/vulkan"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
iced_winit = { version = "0.1.0-alpha", path = "winit" } iced_winit = { version = "0.1.0-alpha", path = "winit" }
iced_wgpu = { version = "0.1.0-alpha", path = "wgpu" } iced_wgpu = { version = "0.1.0-alpha", path = "wgpu" }

View file

@ -7,12 +7,9 @@ description = "A wgpu renderer for Iced"
license = "MIT" license = "MIT"
repository = "https://github.com/hecrj/iced" repository = "https://github.com/hecrj/iced"
[features]
vulkan = ["wgpu/vulkan"]
[dependencies] [dependencies]
iced_native = { version = "0.1.0-alpha", path = "../native" } iced_native = { version = "0.1.0-alpha", path = "../native" }
wgpu = "0.3" wgpu = { version = "0.3", git = "https://github.com/gfx-rs/wgpu-rs", rev = "cb25914b95b58fee0dc139b400867e7a731d98f4" }
wgpu_glyph = "0.4" wgpu_glyph = { version = "0.4", git = "https://github.com/hecrj/wgpu_glyph", branch = "improvement/update-wgpu" }
raw-window-handle = "0.1" raw-window-handle = "0.1"
log = "0.4" log = "0.4"

View file

@ -3,8 +3,8 @@ use iced_native::{renderer::Debugger, Color, Layout, Point, Widget};
use raw_window_handle::HasRawWindowHandle; use raw_window_handle::HasRawWindowHandle;
use wgpu::{ use wgpu::{
Adapter, CommandEncoderDescriptor, Device, DeviceDescriptor, Extensions, Adapter, BackendBit, CommandEncoderDescriptor, Device, DeviceDescriptor,
Instance, Limits, PowerPreference, RequestAdapterOptions, Surface, Extensions, Limits, PowerPreference, Queue, RequestAdapterOptions, Surface,
SwapChain, SwapChainDescriptor, TextureFormat, TextureUsage, SwapChain, SwapChainDescriptor, TextureFormat, TextureUsage,
}; };
use wgpu_glyph::{GlyphBrush, GlyphBrushBuilder, Section}; use wgpu_glyph::{GlyphBrush, GlyphBrushBuilder, Section};
@ -21,10 +21,10 @@ mod slider;
mod text; mod text;
pub struct Renderer { pub struct Renderer {
instance: Instance,
surface: Surface, surface: Surface,
adapter: Adapter, adapter: Adapter,
device: Device, device: Device,
queue: Queue,
quad_pipeline: quad::Pipeline, quad_pipeline: quad::Pipeline,
quads: Vec<Quad>, quads: Vec<Quad>,
@ -40,20 +40,20 @@ pub struct Target {
impl Renderer { impl Renderer {
pub fn new<W: HasRawWindowHandle>(window: &W) -> Self { pub fn new<W: HasRawWindowHandle>(window: &W) -> Self {
let instance = Instance::new(); let adapter = Adapter::request(&RequestAdapterOptions {
let adapter = instance.request_adapter(&RequestAdapterOptions {
power_preference: PowerPreference::LowPower, power_preference: PowerPreference::LowPower,
}); backends: BackendBit::all(),
})
.expect("Request adapter");
let mut device = adapter.request_device(&DeviceDescriptor { let (mut device, queue) = adapter.request_device(&DeviceDescriptor {
extensions: Extensions { extensions: Extensions {
anisotropic_filtering: false, anisotropic_filtering: false,
}, },
limits: Limits { max_bind_groups: 1 }, limits: Limits { max_bind_groups: 1 },
}); });
let surface = instance.create_surface(window.raw_window_handle()); let surface = Surface::create(window);
// TODO: Think about font loading strategy // TODO: Think about font loading strategy
// Loading system fonts with fallback may be a good idea // Loading system fonts with fallback may be a good idea
@ -66,10 +66,10 @@ impl Renderer {
let quad_pipeline = quad::Pipeline::new(&mut device); let quad_pipeline = quad::Pipeline::new(&mut device);
Self { Self {
instance,
surface, surface,
adapter, adapter,
device, device,
queue,
quad_pipeline, quad_pipeline,
quads: Vec::new(), quads: Vec::new(),
@ -143,7 +143,7 @@ impl Renderer {
) )
.expect("Draw text"); .expect("Draw text");
self.device.get_queue().submit(&[encoder.finish()]); self.queue.submit(&[encoder.finish()]);
} }
fn draw_primitive(&mut self, primitive: &Primitive) { fn draw_primitive(&mut self, primitive: &Primitive) {