Skip to content

Add bring-your-own-encoder methods everywhere - #496

Closed
mkeeter wants to merge 1 commit into
mainfrom
bring-your-own-encoder-redux
Closed

mkeeter wants to merge 1 commit into
mainfrom
bring-your-own-encoder-redux

Conversation

@mkeeter

@mkeeter mkeeter commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

These are a helpful building block for egui_wgpu integration on the main thread.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical batched-encoding correctness issues and a compatibility-breaking API rename remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 7 High severity · 1 Medium severity

Open (8)
What changed in this PR

Adds caller-supplied wgpu::CommandEncoder APIs across pixel, voxel, and effects rendering paths.

Changes:

  • Adds encoder-based rendering and post-processing methods.
  • Refactors existing submit helpers to delegate to encoding APIs.
  • Updates crate API documentation.
File Summary
fidget-wgpu/​src/​voxel/​mod.rs Adds voxel encoding support; workspace reuse can corrupt batched dispatches, and renaming encode_with_vars introduces an API break.
fidget-wgpu/​src/​voxel/​effects/​mod.rs Adds encoder-based voxel effects; reusable workspace configuration is unsafe across batched encodes.
fidget-wgpu/​src/​pixel/​mod.rs Adds pixel encoding support; reused workspaces can cause earlier dispatches to read later data.
fidget-wgpu/​src/​pixel/​effects/​mod.rs Adds encoder-based pixel effects; reusable workspace configuration and buffers are unsafe across batched encodes.
fidget-wgpu/​src/​lib.rs Documents the expanded API layers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +245 to +250
pub fn encode_merge(
&self,
image: &FlexBuffer<PixelBufferTag>,
remove_nans: bool,
buf: &mut MergeWorkspace,
encoder: &mut wgpu::CommandEncoder,
Comment on lines +401 to +408
pub fn encode_color(
&self,
merge: &mut MergeWorkspace,
settings: ColorSettings,
shape: &ShapeColorBuffers,
bufs: &mut ColorWorkspace,
vars: &ShapeVars<f32>,
encoder: &mut wgpu::CommandEncoder,
Comment on lines +1117 to +1123
pub fn encode(
&self,
shape: &RenderShape,
vars: &ShapeVars<f32>,
workspace: &mut Workspace,
settings: &RenderConfig,
encoder: &mut wgpu::CommandEncoder,
Comment on lines +578 to +583
pub fn encode_merge(
&self,
image: &FlexBuffer<GeomBufferTag>,
settings: MergeSettings,
buf: &mut MergeWorkspace,
encoder: &mut wgpu::CommandEncoder,
Comment on lines +677 to +682
pub fn encode_shade(
&self,
image: &MergeWorkspace,
ssao: Option<&SsaoWorkspace>,
buf: &mut ShadeWorkspace,
encoder: &mut wgpu::CommandEncoder,
Comment on lines +871 to +875
pub fn encode_ssao(
&self,
image: &MergeWorkspace,
buf: &mut SsaoWorkspace,
encoder: &mut wgpu::CommandEncoder,
Comment on lines +935 to +943
pub fn encode_color(
&self,
merge: &MergeWorkspace,
world_to_model: &nalgebra::Matrix4<f32>,
shape: &ShapeColorBuffers,
bufs: &mut ColorWorkspace,
vars: &ShapeVars<f32>,
out: &mut ShadeWorkspace,
encoder: &mut wgpu::CommandEncoder,
///
/// See [`submit`](Self::submit) for additional details.
pub fn encode_with_vars(
pub fn encode(
@mkeeter

mkeeter commented Sep 26, 2026

Copy link
Copy Markdown
Owner Author

The bot has got a point – this makes it hard to chain multiple operations (e.g. merges) which use the same config buffer, because all of the copies will be queued first, then all of the commands will be submitted (using the last data in the config buffer).

@mkeeter mkeeter closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants