Skip to content

Commit

Permalink
split into a separate public function
Browse files Browse the repository at this point in the history
to keep wasm-bindgen happy
  • Loading branch information
davidar committed Sep 17, 2023
1 parent 51b3fd9 commit 287307a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use context::WgpuContext;
use lazy_regex::regex;
use num::Integer;
use pp::{SourceMap, WGSLError};
use wgpu::{Maintain, SubmissionIndex};
use std::collections::HashMap;
use std::mem::{size_of, take};
use std::sync::atomic::{AtomicBool, Ordering};
use wasm_bindgen::prelude::*;
use wgpu::{Maintain, SubmissionIndex};

// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
Expand Down Expand Up @@ -198,7 +198,18 @@ impl WgpuToyRenderer {
}
}

pub fn render_to(&mut self, frame: &wgpu::SurfaceTexture) -> (Option<wgpu::Buffer>, SubmissionIndex) {
#[cfg(not(target_arch = "wasm32"))]
pub fn render_to_surface(
&mut self,
frame: &wgpu::SurfaceTexture,
) -> (Option<wgpu::Buffer>, SubmissionIndex) {
self.render_to(frame)
}

fn render_to(
&mut self,
frame: &wgpu::SurfaceTexture,
) -> (Option<wgpu::Buffer>, SubmissionIndex) {
let mut encoder = self.wgpu.device.create_command_encoder(&Default::default());
self.bindings.stage(&self.wgpu.queue);
if self.bindings.time.host.frame % STATS_PERIOD == 0 {
Expand Down

0 comments on commit 287307a

Please sign in to comment.