address feedback

This commit is contained in:
Chad Brokaw 2022-12-08 12:43:09 -05:00
parent e5081b51e4
commit 4ea379aaa7
7 changed files with 18 additions and 150 deletions

1
Cargo.lock generated
View file

@ -2019,7 +2019,6 @@ version = "0.1.0"
dependencies = [
"console_error_panic_hook",
"console_log",
"js-sys",
"piet-scene",
"piet-wgsl",
"pollster",

View file

@ -1,7 +1,8 @@
[package]
name = "winit-demo"
version = "0.1.0"
edition = "2021"
version.workspace = true
authors.workspace = true
edition.workspace = true
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -19,133 +20,4 @@ roxmltree = "0.13"
console_error_panic_hook = "0.1.7"
console_log = "0.2"
wasm-bindgen-futures = "0.4.33"
js-sys = "0.3.60"
web-sys = { version = "0.3.60", features = [
"Document",
"Navigator",
"Node",
"NodeList",
"Gpu",
"GpuAdapter",
"GpuAddressMode",
"GpuAutoLayoutMode",
"GpuBindGroup",
"GpuBindGroupDescriptor",
"GpuBindGroupEntry",
"GpuBindGroupLayout",
"GpuBindGroupLayoutDescriptor",
"GpuBindGroupLayoutEntry",
"GpuBlendComponent",
"GpuBlendFactor",
"GpuBlendOperation",
"GpuBlendState",
"GpuBuffer",
"GpuBufferBinding",
"GpuBufferBindingLayout",
"GpuBufferBindingType",
"GpuBufferDescriptor",
"GpuCanvasAlphaMode",
"GpuCanvasContext",
"GpuCanvasConfiguration",
"GpuColorDict",
"GpuColorTargetState",
"GpuCommandBuffer",
"GpuCommandBufferDescriptor",
"GpuCommandEncoder",
"GpuCommandEncoderDescriptor",
"GpuCompareFunction",
"GpuCompilationInfo",
"GpuCompilationMessage",
"GpuCompilationMessageType",
"GpuComputePassDescriptor",
"GpuComputePassEncoder",
"GpuComputePipeline",
"GpuComputePipelineDescriptor",
"GpuCullMode",
"GpuDepthStencilState",
"GpuDevice",
"GpuDeviceDescriptor",
"GpuDeviceLostInfo",
"GpuDeviceLostReason",
"GpuError",
"GpuErrorFilter",
"GpuExtent3dDict",
"GpuFeatureName",
"GpuFilterMode",
"GpuFragmentState",
"GpuFrontFace",
"GpuImageCopyBuffer",
"GpuImageCopyExternalImage",
"GpuImageCopyTexture",
"GpuImageCopyTextureTagged",
"GpuImageDataLayout",
"GpuIndexFormat",
"GpuLoadOp",
"gpu_map_mode",
"GpuMipmapFilterMode",
"GpuMultisampleState",
"GpuObjectDescriptorBase",
"GpuOrigin2dDict",
"GpuOrigin3dDict",
"GpuOutOfMemoryError",
"GpuPipelineDescriptorBase",
"GpuPipelineLayout",
"GpuPipelineLayoutDescriptor",
"GpuPowerPreference",
"GpuPrimitiveState",
"GpuPrimitiveTopology",
"GpuProgrammableStage",
"GpuQuerySet",
"GpuQuerySetDescriptor",
"GpuQueryType",
"GpuQueue",
"GpuRenderBundle",
"GpuRenderBundleDescriptor",
"GpuRenderBundleEncoder",
"GpuRenderBundleEncoderDescriptor",
"GpuRenderPassColorAttachment",
"GpuRenderPassDepthStencilAttachment",
"GpuRenderPassDescriptor",
"GpuRenderPassEncoder",
"GpuRenderPipeline",
"GpuRenderPipelineDescriptor",
"GpuRequestAdapterOptions",
"GpuSampler",
"GpuSamplerBindingLayout",
"GpuSamplerBindingType",
"GpuSamplerDescriptor",
"GpuShaderModule",
"GpuShaderModuleDescriptor",
"GpuStencilFaceState",
"GpuStencilOperation",
"GpuStorageTextureAccess",
"GpuStorageTextureBindingLayout",
"GpuStoreOp",
"GpuSupportedFeatures",
"GpuSupportedLimits",
"GpuTexture",
"GpuTextureAspect",
"GpuTextureBindingLayout",
"GpuTextureDescriptor",
"GpuTextureDimension",
"GpuTextureFormat",
"GpuTextureSampleType",
"GpuTextureView",
"GpuTextureViewDescriptor",
"GpuTextureViewDimension",
"GpuUncapturedErrorEvent",
"GpuUncapturedErrorEventInit",
"GpuValidationError",
"GpuVertexAttribute",
"GpuVertexBufferLayout",
"GpuVertexFormat",
"GpuVertexState",
"GpuVertexStepMode",
"HtmlCanvasElement",
"OffscreenCanvas",
"ImageBitmap",
"ImageBitmapRenderingContext",
"Window",
"WorkerGlobalScope",
"WorkerNavigator"
] }
web-sys = "0.3.60"

View file

@ -22,18 +22,7 @@ use piet_scene::{Scene, SceneBuilder};
use piet_wgsl::{util::RenderContext, Renderer};
use winit::{event_loop::EventLoop, window::Window};
async fn run() {
use winit::{dpi::LogicalSize, window::WindowBuilder};
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_inner_size(LogicalSize::new(1044, 800))
.with_resizable(true)
.build(&event_loop)
.unwrap();
run_wasm(event_loop, window).await
}
async fn run_wasm(event_loop: EventLoop<()>, window: Window) {
async fn run(event_loop: EventLoop<()>, window: Window) {
use winit::{event::*, event_loop::ControlFlow};
let render_cx = RenderContext::new().await.unwrap();
let size = window.inner_size();
@ -106,7 +95,14 @@ async fn run_wasm(event_loop: EventLoop<()>, window: Window) {
fn main() {
#[cfg(not(target_arch = "wasm32"))]
{
pollster::block_on(run());
use winit::{dpi::LogicalSize, window::WindowBuilder};
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_inner_size(LogicalSize::new(1044, 800))
.with_resizable(true)
.build(&event_loop)
.unwrap();
pollster::block_on(run(event_loop, window));
}
#[cfg(target_arch = "wasm32")]
{
@ -126,6 +122,6 @@ fn main() {
.and_then(|doc| doc.body())
.and_then(|body| body.append_child(&web_sys::Element::from(canvas)).ok())
.expect("couldn't append canvas to document body");
wasm_bindgen_futures::spawn_local(run_wasm(event_loop, window));
wasm_bindgen_futures::spawn_local(run(event_loop, window));
}
}

View file

@ -45,7 +45,7 @@ let SY = 0.00390625;
let WG_SIZE = 256u;
let N_SLICE = 8u;
//const N_SLICE = WG_SIZE / 32u;
//let N_SLICE = WG_SIZE / 32u;
let N_SUBSLICE = 4u;
var<workgroup> sh_bitmaps: array<array<atomic<u32>, N_TILE>, N_SLICE>;

View file

@ -46,7 +46,7 @@ var<storage, read_write> ptcl: array<u32>;
// Much of this code assumes WG_SIZE == N_TILE. If these diverge, then
// a fair amount of fixup is needed.
let WG_SIZE = 256u;
//const N_SLICE = WG_SIZE / 32u;
//let N_SLICE = WG_SIZE / 32u;
let N_SLICE = 8u;
var<workgroup> sh_bitmaps: array<array<atomic<u32>, N_TILE>, N_SLICE>;

View file

@ -34,5 +34,5 @@ let TILE_HEIGHT = 16u;
// Number of tiles per bin
let N_TILE_X = 16u;
let N_TILE_Y = 16u;
//const N_TILE = N_TILE_X * N_TILE_Y;
//let N_TILE = N_TILE_X * N_TILE_Y;
let N_TILE = 256u;

View file

@ -3,6 +3,7 @@ name = "run-wasm"
version.workspace = true
authors.workspace = true
edition.workspace = true
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html