Repository navigation
Stop recording the unused Hi-Z pyramid (#269) #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8623310
fix(render): stop recording the unused Hi-Z pyramid
cursoragent f56b2fa
fix(render): rebind Hi-Z on enable and restore alloc spread 4
cursoragent 596eed6
fix(render): correct Hi-Z contracts and run the fallback alloc gate
cursoragent 2ce0da5
fix(render): cap streamed image reads and bound decode shutdown
cursoragent 36757da
fix(render): share the image cap and keep fifo cleanup from blocking
cursoragent c666937
fix(render): enable tokio io-util on the render crate
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(render): rebind Hi-Z on enable and restore alloc spread 4
The gate sat on the measured high sample and allowed a spread of 6. Five lavapipe runs with validation on, and five with it off, each recorded [119, 116, 115, 116, 115, 115]. Spread inside a run is 4. The ceiling is 130, eleven above that sample and still under one extra pass. set_sample_hiz(true) drops any pyramid so the next draw_into copies that frame's depth view, including when the size is unchanged. The trace and phase-plan decision 2 describe that gate. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
- Loading branch information
commit f56b2fa46c78ee85f5962cc395c62ab0852bfbec
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| //! Enabling `sample_hiz` rebuilds the pyramid against that frame's depth view. | ||
| //! | ||
| //! The copy bind group is fixed at `HizPyramid` creation. A later `draw_into` | ||
| //! with a different view of the same size must not keep the view captured | ||
| //! earlier. | ||
|
|
||
| use astraweave_render::Renderer; | ||
|
|
||
| fn color_target(device: &wgpu::Device) -> wgpu::TextureView { | ||
| let target = device.create_texture(&wgpu::TextureDescriptor { | ||
| label: Some("hiz rebind color"), | ||
| size: wgpu::Extent3d { | ||
| width: 64, | ||
| height: 64, | ||
| depth_or_array_layers: 1, | ||
| }, | ||
| mip_level_count: 1, | ||
| sample_count: 1, | ||
| dimension: wgpu::TextureDimension::D2, | ||
| format: wgpu::TextureFormat::Rgba8UnormSrgb, | ||
| usage: wgpu::TextureUsages::RENDER_ATTACHMENT, | ||
| view_formats: &[], | ||
| }); | ||
| target.create_view(&wgpu::TextureViewDescriptor::default()) | ||
| } | ||
|
|
||
| fn depth_target(device: &wgpu::Device, label: &str) -> (wgpu::Texture, wgpu::TextureView) { | ||
| let depth = device.create_texture(&wgpu::TextureDescriptor { | ||
| label: Some(label), | ||
| size: wgpu::Extent3d { | ||
| width: 64, | ||
| height: 64, | ||
| depth_or_array_layers: 1, | ||
| }, | ||
| mip_level_count: 1, | ||
| sample_count: 1, | ||
| dimension: wgpu::TextureDimension::D2, | ||
| format: wgpu::TextureFormat::Depth32Float, | ||
| usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING, | ||
| view_formats: &[], | ||
| }); | ||
| let view = depth.create_view(&wgpu::TextureViewDescriptor::default()); | ||
| (depth, view) | ||
| } | ||
|
|
||
| fn draw(renderer: &mut Renderer, color: &wgpu::TextureView, depth: Option<&wgpu::TextureView>) { | ||
| let device = renderer.device().clone(); | ||
| let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { | ||
| label: Some("hiz rebind"), | ||
| }); | ||
| renderer | ||
| .draw_into(color, depth, &mut encoder) | ||
| .expect("draw_into"); | ||
| drop(encoder); | ||
| } | ||
|
|
||
| #[test] | ||
| fn enabling_sample_hiz_rebinds_to_the_current_depth_view() { | ||
| pollster::block_on(async { | ||
| let mut renderer = Renderer::new_headless(64, 64) | ||
| .await | ||
| .expect("headless renderer"); | ||
| if astraweave_render::gpu_fault::skip_without_depth_texture_load( | ||
| renderer.device(), | ||
| "enabling_sample_hiz_rebinds_to_the_current_depth_view", | ||
| ) { | ||
| return; | ||
| } | ||
| let device = renderer.device().clone(); | ||
| let color = color_target(&device); | ||
| let (_depth_a, view_a) = depth_target(&device, "depth a"); | ||
| let (_depth_b, view_b) = depth_target(&device, "depth b"); | ||
|
|
||
| draw(&mut renderer, &color, Some(&view_a)); | ||
| assert!( | ||
| renderer.hiz_pyramid().is_none(), | ||
| "sample_hiz stays off until set, so no pyramid is captured at creation" | ||
| ); | ||
|
|
||
| renderer.set_sample_hiz(true); | ||
| draw(&mut renderer, &color, Some(&view_a)); | ||
| let pyramid = renderer | ||
| .hiz_pyramid() | ||
| .expect("enabling sample_hiz builds a pyramid"); | ||
| assert!( | ||
| pyramid.copies_from(&view_a), | ||
| "the first enabled frame copies the depth view from that draw_into" | ||
| ); | ||
| assert!(!pyramid.copies_from(&view_b)); | ||
|
|
||
| draw(&mut renderer, &color, Some(&view_b)); | ||
| let pyramid = renderer | ||
| .hiz_pyramid() | ||
| .expect("a same-size view still rebuilds"); | ||
| assert!( | ||
| pyramid.copies_from(&view_b), | ||
| "a different depth view of the same size replaces the copy source" | ||
| ); | ||
| assert!(!pyramid.copies_from(&view_a)); | ||
|
|
||
| renderer.set_sample_hiz(false); | ||
| draw(&mut renderer, &color, Some(&view_a)); | ||
| assert!( | ||
| renderer.hiz_pyramid().is_none(), | ||
| "turning sample_hiz off drops the pyramid" | ||
| ); | ||
|
|
||
| renderer.set_sample_hiz(true); | ||
| draw(&mut renderer, &color, Some(&view_a)); | ||
| let pyramid = renderer | ||
| .hiz_pyramid() | ||
| .expect("enabling again builds against the current view"); | ||
| assert!(pyramid.copies_from(&view_a)); | ||
| assert!(!pyramid.copies_from(&view_b)); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.