Skip to content

Commit

Permalink
Make StoreOp an enum instead of a bool (#4147)
Browse files Browse the repository at this point in the history
Co-authored-by: Connor Fitzgerald <[email protected]>
  • Loading branch information
Wumpf and cwfitzgerald authored Sep 18, 2023
1 parent 8adab25 commit 5071019
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 64 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ let render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {

By @Valaphee in [#3402](https://github.com/gfx-rs/wgpu/pull/3402)


#### Render pass store operation is now an enum

`wgpu::Operations::store` used to be an underdocumented boolean value,
causing misunderstandings of the effect of setting it to `false`.

The API now more closely resembles WebGPU which distinguishes between `store` and `discard`,
see [WebGPU spec on GPUStoreOp](https://gpuweb.github.io/gpuweb/#enumdef-gpustoreop).

```diff
// ...
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
- store: false,
+ store: wgpu::StoreOp::Discard,
}),
// ...
```

By @wumpf in [#4147](https://github.com/gfx-rs/wgpu/pull/4147)


### Added/New Features

- Add `gles_minor_version` field to `wgpu::InstanceDescriptor`. By @PJB3005 in [#3998](https://github.com/gfx-rs/wgpu/pull/3998)
Expand Down
2 changes: 1 addition & 1 deletion examples/boids/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl wgpu_example::framework::Example for Example {
// Not clearing here in order to test wgpu's zero texture initialization on a surface texture.
// Users should avoid loading uninitialized memory since this can cause additional overhead.
load: wgpu::LoadOp::Load,
store: true,
store: wgpu::StoreOp::Store,
},
})];
let render_pass_descriptor = wgpu::RenderPassDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion examples/bunnymark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(clear_color),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/capture/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async fn create_red_image_with_dimensions(
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::RED),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
4 changes: 2 additions & 2 deletions examples/conservative-raster/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand All @@ -290,7 +290,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/cube/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl wgpu_example::framework::Example for Example {
b: 0.3,
a: 1.0,
}),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-triangle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-windows/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Window, wgpu::Color)>) {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(viewport.desc.background),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
4 changes: 2 additions & 2 deletions examples/mipmap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down Expand Up @@ -490,7 +490,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(clear_color),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
4 changes: 2 additions & 2 deletions examples/msaa-line/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
store: wgpu::StoreOp::Store,
},
}
} else {
Expand All @@ -293,7 +293,7 @@ impl wgpu_example::framework::Example for Example {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
// Storing pre-resolve MSAA data is unnecessary if it isn't used later.
// On tile-based GPU, avoid store can reduce your app's memory footprint.
store: false,
store: wgpu::StoreOp::Discard,
},
}
};
Expand Down
6 changes: 3 additions & 3 deletions examples/shadow/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ impl wgpu_example::framework::Example for Example {
view: &light.target_view,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: true,
store: wgpu::StoreOp::Store,
}),
stencil_ops: None,
}),
Expand Down Expand Up @@ -810,14 +810,14 @@ impl wgpu_example::framework::Example for Example {
b: 0.3,
a: 1.0,
}),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &self.forward_depth,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: false,
store: wgpu::StoreOp::Discard,
}),
stencil_ops: None,
}),
Expand Down
4 changes: 2 additions & 2 deletions examples/skybox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,14 @@ impl wgpu_example::framework::Example for Skybox {
b: 0.3,
a: 1.0,
}),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &self.depth_view,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: false,
store: wgpu::StoreOp::Discard,
}),
stencil_ops: None,
}),
Expand Down
4 changes: 2 additions & 2 deletions examples/stencil-triangles/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ impl wgpu_example::framework::Example for Triangles {
b: 0.3,
a: 1.0,
}),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &depth_view,
depth_ops: None,
stencil_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(0),
store: true,
store: wgpu::StoreOp::Store,
}),
}),
timestamp_writes: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/texture-arrays/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/timestamp-queries/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ fn render_pass(
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
10 changes: 5 additions & 5 deletions examples/water/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(back_color),
store: true,
store: wgpu::StoreOp::Store,
},
})],
// We still need to use the depth buffer here
Expand All @@ -748,7 +748,7 @@ impl wgpu_example::framework::Example for Example {
view: &self.depth_buffer,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: true,
store: wgpu::StoreOp::Store,
}),
stencil_ops: None,
}),
Expand All @@ -768,14 +768,14 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(back_color),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &self.depth_buffer,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: true,
store: wgpu::StoreOp::Store,
}),
stencil_ops: None,
}),
Expand All @@ -797,7 +797,7 @@ impl wgpu_example::framework::Example for Example {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Load,
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/occlusion_query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn occlusion_query() {
view: &depth_texture_view,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: true,
store: wgpu::StoreOp::Store,
}),
stencil_ops: None,
}),
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/regression/issue_3457.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn pass_reset_vertex_buffer() {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK),
store: false,
store: StoreOp::Discard,
},
})],
depth_stencil_attachment: None,
Expand Down Expand Up @@ -175,7 +175,7 @@ fn pass_reset_vertex_buffer() {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK),
store: false,
store: StoreOp::Discard,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/scissor_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn scissor_test_impl(ctx: &TestingContext, scissor_rect: Rect, expected_data: [u
b: 0.0,
a: 0.0,
}),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/shader_primitive_index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fn pulling_common(
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
store: true,
store: wgpu::StoreOp::Store,
},
resolve_target: None,
view: &color_view,
Expand Down
18 changes: 9 additions & 9 deletions tests/tests/zero_init_texture_after_discard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ impl<'ctx> TestCase<'ctx> {
view: &texture.create_view(&TextureViewDescriptor::default()),
depth_ops: format.has_depth_aspect().then_some(Operations {
load: LoadOp::Clear(1.0),
store: true,
store: StoreOp::Store,
}),
stencil_ops: format.has_stencil_aspect().then_some(Operations {
load: LoadOp::Clear(0xFFFFFFFF),
store: true,
store: StoreOp::Store,
}),
}),
timestamp_writes: None,
Expand Down Expand Up @@ -230,7 +230,7 @@ impl<'ctx> TestCase<'ctx> {
resolve_target: None,
ops: Operations {
load: LoadOp::Load,
store: false, // discard!
store: StoreOp::Discard,
},
},
)],
Expand All @@ -239,11 +239,11 @@ impl<'ctx> TestCase<'ctx> {
view: &self.texture.create_view(&TextureViewDescriptor::default()),
depth_ops: self.format.has_depth_aspect().then_some(Operations {
load: LoadOp::Load,
store: false, // discard!
store: StoreOp::Discard,
}),
stencil_ops: self.format.has_stencil_aspect().then_some(Operations {
load: LoadOp::Load,
store: false, // discard!
store: StoreOp::Discard,
}),
},
),
Expand All @@ -264,11 +264,11 @@ impl<'ctx> TestCase<'ctx> {
view: &self.texture.create_view(&TextureViewDescriptor::default()),
depth_ops: Some(Operations {
load: LoadOp::Load,
store: false, // discard!
store: StoreOp::Discard,
}),
stencil_ops: self.format.has_stencil_aspect().then_some(Operations {
load: LoadOp::Clear(0),
store: true,
store: StoreOp::Store,
}),
},
),
Expand All @@ -289,11 +289,11 @@ impl<'ctx> TestCase<'ctx> {
view: &self.texture.create_view(&TextureViewDescriptor::default()),
depth_ops: self.format.has_depth_aspect().then_some(Operations {
load: LoadOp::Clear(0.0),
store: true,
store: StoreOp::Store,
}),
stencil_ops: Some(Operations {
load: LoadOp::Load,
store: false, // discard!
store: StoreOp::Discard,
}),
},
),
Expand Down
Loading

0 comments on commit 5071019

Please sign in to comment.