[rs] Framework and README update

This commit is contained in:
Dzmitry Malyshau 2021-05-31 23:00:15 -04:00
parent f438f0b920
commit e98f36245b
5 changed files with 56 additions and 42 deletions

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -38,7 +38,6 @@ struct Example {
} }
impl framework::Example for Example { impl framework::Example for Example {
/// constructs initial instance of Example struct
fn init( fn init(
sc_desc: &wgpu::SwapChainDescriptor, sc_desc: &wgpu::SwapChainDescriptor,
_adapter: &wgpu::Adapter, _adapter: &wgpu::Adapter,
@ -132,7 +131,7 @@ impl framework::Example for Example {
}); });
let texture = { 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 decoder = png::Decoder::new(std::io::Cursor::new(img_data));
let (info, mut reader) = decoder.read_info().unwrap(); let (info, mut reader) = decoder.read_info().unwrap();
let mut buf = vec![0; info.buffer_size()]; let mut buf = vec![0; info.buffer_size()];
@ -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) { fn update(&mut self, event: winit::event::WindowEvent) {
if let winit::event::WindowEvent::KeyboardInput { if let winit::event::WindowEvent::KeyboardInput {
input: input:
@ -278,7 +276,6 @@ impl framework::Example for Example {
} }
} }
/// resize is called on WindowEvent::Resized events
fn resize( fn resize(
&mut self, &mut self,
_sc_desc: &wgpu::SwapChainDescriptor, _sc_desc: &wgpu::SwapChainDescriptor,
@ -288,8 +285,6 @@ impl framework::Example for Example {
//empty //empty
} }
/// render is called each frame, dispatching compute groups proportional
/// a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
fn render( fn render(
&mut self, &mut self,
frame: &wgpu::SwapChainTexture, frame: &wgpu::SwapChainTexture,

View File

@ -211,6 +211,10 @@ fn start<E: Example>(
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
let mut last_update_inst = Instant::now(); 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..."); log::info!("Entering render loop...");
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
@ -275,6 +279,21 @@ fn start<E: Example>(
} }
}, },
event::Event::RedrawRequested(_) => { 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() { let frame = match swap_chain.get_current_frame() {
Ok(frame) => frame, Ok(frame) => frame,
Err(_) => { Err(_) => {

View File

@ -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 // WebGPU is assumed to be fully compliant
wgt::DownlevelProperties::default() wgt::DownlevelProperties::default()
} }