mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04: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>
Description
No description provided
Languages
Rust
79.9%
WGSL
16.2%
HLSL
2%
GLSL
1.7%
JavaScript
0.2%