Skip to content

Commit

Permalink
[rs] Framework and README update
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Jun 1, 2021
1 parent f438f0b commit e98f362
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 42 deletions.
70 changes: 35 additions & 35 deletions wgpu/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@ All the examples use [WGSL](https://gpuweb.github.io/gpuweb/wgsl.html) shaders u
All framework-based examples render to the window.

## Feature matrix
| Feature | boids | cube | mipmap | msaa-line | shadow | skybox | texture-arrays | water | conservative-raster |
| ---------------------------- | ------ | ------ | ------ | --------- | ------ | ------ | -------------- | ------ | ------------------- |
| vertex attributes | :star: | :star: | | :star: | :star: | :star: | :star: | :star: | |
| instancing | :star: | | | | | | | | |
| lines and points | | | | :star: | | | | | :star: |
| dynamic buffer offsets | | | | | :star: | | | | |
| implicit layout | | | :star: | | | | | | |
| sampled color textures | :star: | :star: | :star: | | | :star: | :star: | :star: | :star: |
| storage textures | :star: | | | | | | | | |
| binding array | | | | | | | :star: | | |
| comparison samplers | | | | | :star: | | | | |
| subresource views | | | :star: | | :star: | | | | |
| cubemaps | | | | | | :star: | | | |
| multisampling | | | | :star: | | | | | |
| off-screen rendering | | | | | :star: | | | :star: | :star: |
| stencil testing | | | | | | | | | |
| depth testing | | | | | :star: | :star: | | :star: | |
| depth biasing | | | | | :star: | | | | |
| read-only depth | | | | | | | | :star: | |
| blending | | :star: | | | | | | :star: | |
| render bundles | | | | :star: | | | | :star: | |
| compute passes | :star: | | | | | | | | |
| *optional extensions* | | | | | | | :star: | | |
| - SPIR-V shaders | | | | | | | :star: | | |
| - binding indexing | | | | | | | :star: | | |
| - push constants | | | | | | | :star: | | |
| - depth clamping | | | | | :star: | | | | |
| - compressed textures | | | | | | :star: | | | |
| - polygon mode | | :star: | | | | | | | |
| - queries | | | :star: | | | | | | |
| - conservative rasterization | | | | | | | | | :star: |
| *integrations* | | | | | | | | | |
| - staging belt | | | | | | | | | |
| - typed arena | | | | | | | | | |
| - obj loading | | | | | | :star: | | | |
| Feature | boids | bunnymark | cube | mipmap | msaa-line | shadow | skybox | texture-arrays | water | conservative-raster |
| ---------------------------- | ------ | --------- | ------ | ------ | --------- | ------ | ------ | -------------- | ------ | ------------------- |
| vertex attributes | :star: | | :star: | | :star: | :star: | :star: | :star: | :star: | |
| instancing | :star: | | | | | | | | | |
| lines and points | | | | | :star: | | | | | :star: |
| dynamic buffer offsets | | :star: | | | | :star: | | | | |
| implicit layout | | | | :star: | | | | | | |
| sampled color textures | :star: | :star: | :star: | :star: | | | :star: | :star: | :star: | :star: |
| storage textures | :star: | | | | | | | | | |
| binding array | | | | | | | | :star: | | |
| comparison samplers | | | | | | :star: | | | | |
| subresource views | | | | :star: | | :star: | | | | |
| cubemaps | | | | | | | :star: | | | |
| multisampling | | | | | :star: | | | | | |
| off-screen rendering | | | | | | :star: | | | :star: | :star: |
| stencil testing | | | | | | | | | | |
| depth testing | | | | | | :star: | :star: | | :star: | |
| depth biasing | | | | | | :star: | | | | |
| read-only depth | | | | | | | | | :star: | |
| blending | | :star: | :star: | | | | | | :star: | |
| render bundles | | | | | :star: | | | | :star: | |
| compute passes | :star: | | | | | | | | | |
| *optional extensions* | | | | | | | | :star: | | |
| - SPIR-V shaders | | | | | | | | :star: | | |
| - binding indexing | | | | | | | | :star: | | |
| - push constants | | | | | | | | :star: | | |
| - depth clamping | | | | | | :star: | | | | |
| - compressed textures | | | | | | | :star: | | | |
| - polygon mode | | | :star: | | | | | | | |
| - queries | | | | :star: | | | | | | |
| - conservative rasterization | | | | | | | | | | :star: |
| *integrations* | | | | | | | | | | |
| - staging belt | | | | | | | | | | |
| - typed arena | | | | | | | | | | |
| - obj loading | | | | | | | :star: | | | |

## Hacking

Expand Down
Binary file removed wgpu/examples/bunnymark/icon.png
Binary file not shown.
7 changes: 1 addition & 6 deletions wgpu/examples/bunnymark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct Example {
}

impl framework::Example for Example {
/// constructs initial instance of Example struct
fn init(
sc_desc: &wgpu::SwapChainDescriptor,
_adapter: &wgpu::Adapter,
Expand Down Expand Up @@ -132,7 +131,7 @@ impl framework::Example for Example {
});

let texture = {
let img_data = include_bytes!("icon.png");
let img_data = include_bytes!("../../logo.png");
let decoder = png::Decoder::new(std::io::Cursor::new(img_data));
let (info, mut reader) = decoder.read_info().unwrap();
let mut buf = vec![0; info.buffer_size()];
Expand Down Expand Up @@ -247,7 +246,6 @@ impl framework::Example for Example {
}
}

/// update is called for any WindowEvent not handled by the framework
fn update(&mut self, event: winit::event::WindowEvent) {
if let winit::event::WindowEvent::KeyboardInput {
input:
Expand Down Expand Up @@ -278,7 +276,6 @@ impl framework::Example for Example {
}
}

/// resize is called on WindowEvent::Resized events
fn resize(
&mut self,
_sc_desc: &wgpu::SwapChainDescriptor,
Expand All @@ -288,8 +285,6 @@ impl framework::Example for Example {
//empty
}

/// render is called each frame, dispatching compute groups proportional
/// a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
fn render(
&mut self,
frame: &wgpu::SwapChainTexture,
Expand Down
19 changes: 19 additions & 0 deletions wgpu/examples/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ fn start<E: Example>(

#[cfg(not(target_arch = "wasm32"))]
let mut last_update_inst = Instant::now();
#[cfg(not(target_arch = "wasm32"))]
let mut last_frame_inst = Instant::now();
#[cfg(not(target_arch = "wasm32"))]
let (mut frame_count, mut accum_time) = (0, 0.0);

log::info!("Entering render loop...");
event_loop.run(move |event, _, control_flow| {
Expand Down Expand Up @@ -275,6 +279,21 @@ fn start<E: Example>(
}
},
event::Event::RedrawRequested(_) => {
#[cfg(not(target_arch = "wasm32"))]
{
accum_time += last_frame_inst.elapsed().as_secs_f32();
last_frame_inst = Instant::now();
frame_count += 1;
if frame_count == 100 {
println!(
"Avg frame time {}ms",
accum_time * 1000.0 / frame_count as f32
);
accum_time = 0.0;
frame_count = 0;
}
}

let frame = match swap_chain.get_current_frame() {
Ok(frame) => frame,
Err(_) => {
Expand Down
2 changes: 1 addition & 1 deletion wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ impl crate::Context for Context {
}
}

fn adapter_downlevel_properties(&self, adapter: &Self::AdapterId) -> wgt::DownlevelProperties {
fn adapter_downlevel_properties(&self, _adapter: &Self::AdapterId) -> wgt::DownlevelProperties {
// WebGPU is assumed to be fully compliant
wgt::DownlevelProperties::default()
}
Expand Down

0 comments on commit e98f362

Please sign in to comment.