mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 14:31:08 +01:00
ee3ca89105aa3521a3ac7bd953332bd97dcc1ea3
690: Add `RenderEncoder` r=kvark a=0x182d4454fb211940
It seems like `RenderPass` and `RenderBundleEncoder` share many methods in common (`set_pipeline`, `draw_indexed`, etc). By creating a shared trait, it allows more reusable code. For instance:
```rust
impl RedCircle {
fn new(...) -> Self { .. }
fn draw<'a>(&'a self, encoder: &mut impl RenderEncoder<'a>) { .. }
}
```
This code would then work for both structs.
Moving the previous methods from their `impl`s to the trait's would break previous code, as to use these methods code would now have to import `RenderEncoder`. To avoid this, it is implemented by calling the direct methods.
It may be worth considering moving this to `wgpu::util`.
Co-authored-by: 0x182d4454fb211940 <nathanwoodformal@gmail.com>
Languages
Rust
78.5%
WGSL
13%
GLSL
3.1%
Metal
2.8%
HLSL
2.3%
Other
0.2%