Compare commits

...

2 Commits

Author SHA1 Message Date
Benjamin Hansen 5eacaf4e9c fixed model code 2 weeks ago
Benjamin Hansen 8bb1b080b4 fixed up to model loading for wasm 2 weeks ago

@ -28,7 +28,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -178,6 +181,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -200,9 +204,15 @@ async fn run() {
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
state.resize(*physical_size);
surface_configured = true;
}
WindowEvent::RedrawRequested => {
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -29,7 +29,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -191,6 +194,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -214,11 +218,17 @@ pub async fn run() {
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
log::info!("physical_size: {physical_size:?}");
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -26,7 +26,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -286,6 +289,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -307,11 +311,17 @@ async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -28,7 +28,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -248,6 +251,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -269,11 +273,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -89,7 +89,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -367,6 +370,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -388,11 +392,17 @@ async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -85,7 +85,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -326,6 +329,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -347,11 +351,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -91,7 +91,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -394,6 +397,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -415,11 +419,17 @@ async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -91,7 +91,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -372,6 +375,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -393,11 +397,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -241,7 +241,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -561,6 +564,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -582,11 +586,17 @@ async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -241,7 +241,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -581,6 +584,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -602,11 +606,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -295,7 +295,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -662,6 +665,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -683,11 +687,17 @@ async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -302,7 +302,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -679,6 +682,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -700,11 +704,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -494,7 +494,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -869,6 +872,7 @@ async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -890,11 +894,17 @@ async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -312,7 +312,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -706,6 +709,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -727,11 +731,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -14,10 +14,9 @@ impl Texture {
device: &wgpu::Device,
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
) -> Self {let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {
@ -58,9 +57,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -28,6 +28,7 @@ pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
const NUM_INSTANCES_PER_ROW: u32 = 10;
#[derive(Debug)]
struct Camera {
eye: cgmath::Point3<f32>,
target: cgmath::Point3<f32>,
@ -47,7 +48,7 @@ impl Camera {
}
#[repr(C)]
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
struct CameraUniform {
view_proj: [[f32; 4]; 4],
}
@ -506,10 +507,10 @@ impl<'a> State<'a> {
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 {
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.size = new_size;
self.config.width = new_size.width;
self.config.height = new_size.height;
self.size = new_size;
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.surface.configure(&self.device, &self.config);
self.depth_texture =
texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture");
@ -521,7 +522,9 @@ impl<'a> State<'a> {
fn update(&mut self) {
self.camera_controller.update_camera(&mut self.camera);
log::info!("{:?}", self.camera);
self.camera_uniform.update_view_proj(&self.camera);
log::info!("{:?}", self.camera_uniform);
self.queue.write_buffer(
&self.camera_buffer,
0,
@ -624,6 +627,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -645,11 +649,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -144,7 +144,7 @@ pub async fn load_model(
usage: wgpu::BufferUsages::INDEX,
});
log::info!("{}", m.name);
log::info!("Mesh: {}", m.name);
model::Mesh {
name: file_name.to_string(),
vertex_buffer,

@ -347,7 +347,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -620,10 +623,10 @@ impl<'a> State<'a> {
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 {
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.size = new_size;
self.config.width = new_size.width;
self.config.height = new_size.height;
self.size = new_size;
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.surface.configure(&self.device, &self.config);
self.depth_texture =
texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture");
@ -761,6 +764,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -782,11 +786,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -15,9 +15,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -347,7 +347,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -671,10 +674,10 @@ impl<'a> State<'a> {
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 {
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.size = new_size;
self.config.width = new_size.width;
self.config.height = new_size.height;
self.size = new_size;
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.surface.configure(&self.device, &self.config);
self.depth_texture =
texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture");
@ -809,6 +812,7 @@ pub async fn run() {
// State::new uses async code, so we're going to wait for it to finish
let mut state = State::new(&window).await;
let mut surface_configured = false;
event_loop
.run(move |event, control_flow| {
@ -830,11 +834,17 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
surface_configured = true;
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {
// This tells winit that we want another frame after this one
state.window().request_redraw();
if !surface_configured {
return;
}
state.update();
match state.render() {
Ok(_) => {}

@ -15,9 +15,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -227,7 +227,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

@ -16,8 +16,8 @@ impl Texture {
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -247,10 +247,10 @@ impl<'a> State<'a> {
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
// UPDATED
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::BROWSER_WEBGPU,
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
..Default::default()
});

@ -16,9 +16,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -228,7 +228,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

@ -16,9 +16,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -166,7 +166,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

@ -30,9 +30,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -36,7 +36,10 @@ impl<'a> Display<'a> {
pub async fn new(window: &'a Window) -> Result<Display<'a>, Error> {
let size = window.inner_size();
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
let surface = instance.create_surface(window).unwrap();

@ -232,7 +232,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

@ -15,9 +15,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -41,7 +41,10 @@ impl<'a> Render<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

@ -226,7 +226,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

@ -15,9 +15,9 @@ impl Texture {
config: &wgpu::SurfaceConfiguration,
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
let size = wgpu::Extent3d {
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -61,7 +61,10 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// Backends::all => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});

Loading…
Cancel
Save