summaryrefslogtreecommitdiffstats
path: root/examples/integration_wgpu
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/integration/.gitignore (renamed from examples/integration_wgpu/.gitignore)0
-rw-r--r--examples/integration/Cargo.toml (renamed from examples/integration_wgpu/Cargo.toml)6
-rw-r--r--examples/integration/README.md (renamed from examples/integration_wgpu/README.md)0
-rw-r--r--examples/integration/index.html (renamed from examples/integration_wgpu/index.html)4
-rw-r--r--examples/integration/src/controls.rs (renamed from examples/integration_wgpu/src/controls.rs)10
-rw-r--r--examples/integration/src/main.rs (renamed from examples/integration_wgpu/src/main.rs)122
-rw-r--r--examples/integration/src/scene.rs (renamed from examples/integration_wgpu/src/scene.rs)2
-rw-r--r--examples/integration/src/shader/frag.wgsl (renamed from examples/integration_wgpu/src/shader/frag.wgsl)0
-rw-r--r--examples/integration/src/shader/vert.wgsl (renamed from examples/integration_wgpu/src/shader/vert.wgsl)0
9 files changed, 75 insertions, 69 deletions
diff --git a/examples/integration_wgpu/.gitignore b/examples/integration/.gitignore
index e188dc28..e188dc28 100644
--- a/examples/integration_wgpu/.gitignore
+++ b/examples/integration/.gitignore
diff --git a/examples/integration_wgpu/Cargo.toml b/examples/integration/Cargo.toml
index c0e4fd81..22914742 100644
--- a/examples/integration_wgpu/Cargo.toml
+++ b/examples/integration/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "integration_wgpu"
+name = "integration"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
@@ -7,7 +7,9 @@ publish = false
[dependencies]
iced_winit = { path = "../../winit" }
-iced_wgpu = { path = "../../wgpu", features = ["webgl"] }
+iced_wgpu = { path = "../../wgpu" }
+iced_widget = { path = "../../widget" }
+iced_renderer = { path = "../../renderer", features = ["wgpu"] }
env_logger = "0.10"
[target.'cfg(target_arch = "wasm32")'.dependencies]
diff --git a/examples/integration_wgpu/README.md b/examples/integration/README.md
index ece9ba1e..ece9ba1e 100644
--- a/examples/integration_wgpu/README.md
+++ b/examples/integration/README.md
diff --git a/examples/integration_wgpu/index.html b/examples/integration/index.html
index 461e67a4..920bc4a0 100644
--- a/examples/integration_wgpu/index.html
+++ b/examples/integration/index.html
@@ -8,8 +8,8 @@
<h1>integration_wgpu</h1>
<canvas id="iced_canvas"></canvas>
<script type="module">
- import init from "./integration_wgpu.js";
- init('./integration_wgpu_bg.wasm');
+ import init from "./integration.js";
+ init('./integration_bg.wasm');
</script>
<style>
body {
diff --git a/examples/integration_wgpu/src/controls.rs b/examples/integration/src/controls.rs
index 42623b15..14e53ede 100644
--- a/examples/integration_wgpu/src/controls.rs
+++ b/examples/integration/src/controls.rs
@@ -1,6 +1,8 @@
use iced_wgpu::Renderer;
-use iced_winit::widget::{slider, text_input, Column, Row, Text};
-use iced_winit::{Alignment, Color, Command, Element, Length, Program};
+use iced_widget::{slider, text_input, Column, Row, Text};
+use iced_winit::core::{Alignment, Color, Element, Length};
+use iced_winit::runtime::{Command, Program};
+use iced_winit::style::Theme;
pub struct Controls {
background_color: Color,
@@ -27,7 +29,7 @@ impl Controls {
}
impl Program for Controls {
- type Renderer = Renderer;
+ type Renderer = Renderer<Theme>;
type Message = Message;
fn update(&mut self, message: Message) -> Command<Message> {
@@ -43,7 +45,7 @@ impl Program for Controls {
Command::none()
}
- fn view(&self) -> Element<Message, Renderer> {
+ fn view(&self) -> Element<Message, Renderer<Theme>> {
let background_color = self.background_color;
let text = &self.text;
diff --git a/examples/integration_wgpu/src/main.rs b/examples/integration/src/main.rs
index 15901db8..c935aca7 100644
--- a/examples/integration_wgpu/src/main.rs
+++ b/examples/integration/src/main.rs
@@ -4,11 +4,14 @@ mod scene;
use controls::Controls;
use scene::Scene;
-use iced_wgpu::{wgpu, Backend, Renderer, Settings, Viewport};
-use iced_winit::{
- conversion, futures, program, renderer, winit, Clipboard, Color, Debug,
- Size,
-};
+use iced_wgpu::graphics::Viewport;
+use iced_wgpu::{wgpu, Backend, Renderer, Settings};
+use iced_winit::core::renderer;
+use iced_winit::core::{Color, Size};
+use iced_winit::runtime::program;
+use iced_winit::runtime::Debug;
+use iced_winit::style::Theme;
+use iced_winit::{conversion, futures, winit, Clipboard};
use winit::{
dpi::PhysicalPosition,
@@ -34,7 +37,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
.and_then(|win| win.document())
.and_then(|doc| doc.get_element_by_id("iced_canvas"))
.and_then(|element| element.dyn_into::<HtmlCanvasElement>().ok())
- .expect("Canvas with id `iced_canvas` is missing")
+ .expect("Get canvas element")
};
#[cfg(not(target_arch = "wasm32"))]
env_logger::init();
@@ -74,47 +77,49 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
});
let surface = unsafe { instance.create_surface(&window) }?;
- let (format, (device, queue)) = futures::executor::block_on(async {
- let adapter = wgpu::util::initialize_adapter_from_env_or_default(
- &instance,
- backend,
- Some(&surface),
- )
- .await
- .expect("No suitable GPU adapters found on the system!");
-
- let adapter_features = adapter.features();
-
- #[cfg(target_arch = "wasm32")]
- let needed_limits = wgpu::Limits::downlevel_webgl2_defaults()
- .using_resolution(adapter.limits());
-
- #[cfg(not(target_arch = "wasm32"))]
- let needed_limits = wgpu::Limits::default();
-
- let capabilities = surface.get_capabilities(&adapter);
-
- (
- capabilities
- .formats
- .iter()
- .copied()
- .find(wgpu::TextureFormat::is_srgb)
- .or_else(|| capabilities.formats.first().copied())
- .expect("Get preferred format"),
- adapter
- .request_device(
- &wgpu::DeviceDescriptor {
- label: None,
- features: adapter_features & wgpu::Features::default(),
- limits: needed_limits,
- },
- None,
- )
- .await
- .expect("Request device"),
- )
- });
+ let (format, (device, queue)) =
+ futures::futures::executor::block_on(async {
+ let adapter = wgpu::util::initialize_adapter_from_env_or_default(
+ &instance,
+ backend,
+ Some(&surface),
+ )
+ .await
+ .expect("Create adapter");
+
+ let adapter_features = adapter.features();
+
+ #[cfg(target_arch = "wasm32")]
+ let needed_limits = wgpu::Limits::downlevel_webgl2_defaults()
+ .using_resolution(adapter.limits());
+
+ #[cfg(not(target_arch = "wasm32"))]
+ let needed_limits = wgpu::Limits::default();
+
+ let capabilities = surface.get_capabilities(&adapter);
+
+ (
+ capabilities
+ .formats
+ .iter()
+ .copied()
+ .find(wgpu::TextureFormat::is_srgb)
+ .or_else(|| capabilities.formats.first().copied())
+ .expect("Get preferred format"),
+ adapter
+ .request_device(
+ &wgpu::DeviceDescriptor {
+ label: None,
+ features: adapter_features
+ & wgpu::Features::default(),
+ limits: needed_limits,
+ },
+ None,
+ )
+ .await
+ .expect("Request device"),
+ )
+ });
surface.configure(
&device,
@@ -131,17 +136,18 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut resized = false;
- // Initialize staging belt
- let mut staging_belt = wgpu::util::StagingBelt::new(5 * 1024);
-
// Initialize scene and GUI controls
let scene = Scene::new(&device, format);
let controls = Controls::new();
// Initialize iced
let mut debug = Debug::new();
- let mut renderer =
- Renderer::new(Backend::new(&device, Settings::default(), format));
+ let mut renderer = Renderer::new(Backend::new(
+ &device,
+ &queue,
+ Settings::default(),
+ format,
+ ));
let mut state = program::State::new(
controls,
@@ -193,7 +199,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
viewport.scale_factor(),
),
&mut renderer,
- &iced_wgpu::Theme::Dark,
+ &Theme::Dark,
&renderer::Style { text_color: Color::WHITE },
&mut clipboard,
&mut debug,
@@ -221,7 +227,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
height: size.height,
present_mode: wgpu::PresentMode::AutoVsync,
alpha_mode: wgpu::CompositeAlphaMode::Auto,
- view_formats: vec![]
+ view_formats: vec![],
},
);
@@ -254,8 +260,9 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
renderer.with_primitives(|backend, primitive| {
backend.present(
&device,
- &mut staging_belt,
+ &queue,
&mut encoder,
+ None,
&view,
primitive,
&viewport,
@@ -264,7 +271,6 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
});
// Then we submit the work
- staging_belt.finish();
queue.submit(Some(encoder.finish()));
frame.present();
@@ -274,10 +280,6 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
state.mouse_interaction(),
),
);
-
- // And recall staging buffers
- staging_belt.recall();
-
}
Err(error) => match error {
wgpu::SurfaceError::OutOfMemory => {
diff --git a/examples/integration_wgpu/src/scene.rs b/examples/integration/src/scene.rs
index 3e41fbda..90c7efbf 100644
--- a/examples/integration_wgpu/src/scene.rs
+++ b/examples/integration/src/scene.rs
@@ -1,5 +1,5 @@
use iced_wgpu::wgpu;
-use iced_winit::Color;
+use iced_winit::core::Color;
pub struct Scene {
pipeline: wgpu::RenderPipeline,
diff --git a/examples/integration_wgpu/src/shader/frag.wgsl b/examples/integration/src/shader/frag.wgsl
index cf27bb56..cf27bb56 100644
--- a/examples/integration_wgpu/src/shader/frag.wgsl
+++ b/examples/integration/src/shader/frag.wgsl
diff --git a/examples/integration_wgpu/src/shader/vert.wgsl b/examples/integration/src/shader/vert.wgsl
index e353e6ba..e353e6ba 100644
--- a/examples/integration_wgpu/src/shader/vert.wgsl
+++ b/examples/integration/src/shader/vert.wgsl