From 899ecaa430f9b671d76a2cf84c8289a5c856e9c6 Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Thu, 13 Apr 2023 20:31:12 -0700 Subject: [PATCH] Remove the reduced render method This method was intended for the coverage mask variant of the pipelines that was present in piet-gpu. This code has regressed since the wgpu rewrite and the mask rendering variant of the pipelines will be redesigned. Remove this for now instead of having to maintain it until the rewrite. --- src/render.rs | 83 +------------------------------------------------- src/shaders.rs | 72 ------------------------------------------- 2 files changed, 1 insertion(+), 154 deletions(-) diff --git a/src/render.rs b/src/render.rs index ee3e47a..3cc1658 100644 --- a/src/render.rs +++ b/src/render.rs @@ -2,7 +2,7 @@ use crate::{ engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}, - shaders::{self, FullShaders, Shaders}, + shaders::{self, FullShaders}, RenderParams, Scene, }; use { @@ -80,87 +80,6 @@ struct BumpAllocators { blend: u32, } -#[allow(unused)] -fn render(scene: &Scene, shaders: &Shaders) -> (Recording, BufProxy) { - let mut recording = Recording::default(); - let data = scene.data(); - let n_pathtag = data.path_tags.len(); - let pathtag_padded = align_up(n_pathtag, 4 * shaders::PATHTAG_REDUCE_WG); - let pathtag_wgs = pathtag_padded / (4 * shaders::PATHTAG_REDUCE_WG as usize); - let mut scene: Vec = Vec::with_capacity(pathtag_padded); - let pathtag_base = size_to_words(scene.len()); - scene.extend(bytemuck::cast_slice(&data.path_tags)); - scene.resize(pathtag_padded, 0); - let pathdata_base = size_to_words(scene.len()); - scene.extend(&data.path_data); - - let config = GpuConfig { - width_in_tiles: 64, - height_in_tiles: 64, - target_width: 64 * 16, - target_height: 64 * 16, - layout: Layout { - path_tag_base: pathtag_base, - path_data_base: pathdata_base, - ..Default::default() - }, - ..Default::default() - }; - let scene_buf = recording.upload("scene", scene); - let config_buf = recording.upload_uniform("config", bytemuck::bytes_of(&config)); - - let reduced_buf = BufProxy::new(pathtag_wgs as u64 * TAG_MONOID_SIZE, "reduced_buf"); - // TODO: really only need pathtag_wgs - 1 - recording.dispatch( - shaders.pathtag_reduce, - (pathtag_wgs as u32, 1, 1), - [config_buf, scene_buf, reduced_buf], - ); - - let tagmonoid_buf = BufProxy::new( - pathtag_wgs as u64 * shaders::PATHTAG_REDUCE_WG as u64 * TAG_MONOID_SIZE, - "tagmonoid_buf", - ); - recording.dispatch( - shaders.pathtag_scan, - (pathtag_wgs as u32, 1, 1), - [config_buf, scene_buf, reduced_buf, tagmonoid_buf], - ); - - let path_coarse_wgs = - (n_pathtag as u32 + shaders::PATH_COARSE_WG - 1) / shaders::PATH_COARSE_WG; - // TODO: more principled size calc - let tiles_buf = BufProxy::new(4097 * 8, "tiles_buf"); - let segments_buf = BufProxy::new(256 * 24, "segments_buf"); - recording.clear_all(tiles_buf); - recording.dispatch( - shaders.path_coarse, - (path_coarse_wgs, 1, 1), - [ - config_buf, - scene_buf, - tagmonoid_buf, - tiles_buf, - segments_buf, - ], - ); - recording.dispatch( - shaders.backdrop, - (config.height_in_tiles, 1, 1), - [config_buf, tiles_buf], - ); - let out_buf_size = config.width_in_tiles * config.height_in_tiles * 256; - let out_buf = BufProxy::new(out_buf_size as u64, "out_buf"); - recording.dispatch( - shaders.fine, - (config.width_in_tiles, config.height_in_tiles, 1), - [config_buf, tiles_buf, segments_buf, out_buf], - ); - - recording.download(out_buf); - (recording, out_buf) -} - pub fn render_full( scene: &Scene, shaders: &FullShaders, diff --git a/src/shaders.rs b/src/shaders.rs index 01c3b38..92d1bb9 100644 --- a/src/shaders.rs +++ b/src/shaders.rs @@ -56,14 +56,6 @@ macro_rules! shader { }}; } -pub struct Shaders { - pub pathtag_reduce: ShaderId, - pub pathtag_scan: ShaderId, - pub path_coarse: ShaderId, - pub backdrop: ShaderId, - pub fine: ShaderId, -} - // Shaders for the full pipeline pub struct FullShaders { pub pathtag_reduce: ShaderId, @@ -85,70 +77,6 @@ pub struct FullShaders { pub fine: ShaderId, } -pub fn init_shaders(device: &Device, engine: &mut Engine) -> Result { - let imports = SHARED_SHADERS - .iter() - .copied() - .collect::>(); - let empty = HashSet::new(); - let pathtag_reduce = engine.add_shader( - device, - "pathtag_reduce", - preprocess::preprocess(shader!("pathtag_reduce"), &empty, &imports).into(), - &[BindType::Uniform, BindType::BufReadOnly, BindType::Buffer], - )?; - let pathtag_scan = engine.add_shader( - device, - "pathtag_scan", - preprocess::preprocess(shader!("pathtag_scan"), &empty, &imports).into(), - &[ - BindType::Uniform, - BindType::BufReadOnly, - BindType::BufReadOnly, - BindType::Buffer, - ], - )?; - let path_coarse_config = HashSet::new(); - // path_coarse_config.add("cubics_out"); - - let path_coarse = engine.add_shader( - device, - "path_coarse", - preprocess::preprocess(shader!("path_coarse"), &path_coarse_config, &imports).into(), - &[ - BindType::Uniform, - BindType::BufReadOnly, - BindType::BufReadOnly, - BindType::Buffer, - BindType::Buffer, - ], - )?; - let backdrop = engine.add_shader( - device, - "backdrop", - preprocess::preprocess(shader!("backdrop"), &empty, &imports).into(), - &[BindType::Uniform, BindType::Buffer], - )?; - let fine = engine.add_shader( - device, - "fine", - preprocess::preprocess(shader!("fine"), &empty, &imports).into(), - &[ - BindType::Uniform, - BindType::BufReadOnly, - BindType::BufReadOnly, - BindType::Buffer, - ], - )?; - Ok(Shaders { - pathtag_reduce, - pathtag_scan, - path_coarse, - backdrop, - fine, - }) -} - pub fn full_shaders(device: &Device, engine: &mut Engine) -> Result { let imports = SHARED_SHADERS .iter()