Skip to content

Commit

Permalink
Add some of the missing methods to TrackedRenderPass (#3401)
Browse files Browse the repository at this point in the history
# Objective

Add missing methods to `TrackedRenderPass`

- `set_push_constants`
- `set_viewport`
- `insert_debug_marker`
- `push_debug_group`
- `pop_debug_group`
- `set_blend_constant`

https://docs.rs/wgpu/0.12.0/wgpu/struct.RenderPass.html

I need `set_push_constants` but started adding the others as I noticed they were also missing. The `draw indirect` family of methods are still missing as are the `timestamp query` methods.
  • Loading branch information
aloucks committed Dec 20, 2021
1 parent 5479047 commit c04dfc1
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions crates/bevy_render/src/render_phase/draw_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use crate::render_resource::{
BindGroup, BindGroupId, BufferId, BufferSlice, RenderPipeline, RenderPipelineId,
use crate::{
prelude::Color,
render_resource::{
BindGroup, BindGroupId, BufferId, BufferSlice, RenderPipeline, RenderPipelineId,
ShaderStages,
},
};
use bevy_utils::tracing::debug;
use std::ops::Range;
Expand Down Expand Up @@ -235,4 +239,54 @@ impl<'a> TrackedRenderPass<'a> {
debug!("set_scissor_rect: {} {} {} {}", x, y, width, height);
self.pass.set_scissor_rect(x, y, width, height);
}

/// Set push constant data.
///
/// Features::PUSH_CONSTANTS must be enabled on the device in order to call these functions.
pub fn set_push_constants(&mut self, stages: ShaderStages, offset: u32, data: &[u8]) {
debug!(
"set push constants: {:?} offset: {} data.len: {}",
stages,
offset,
data.len()
);
self.pass.set_push_constants(stages, offset, data)
}

pub fn set_viewport(
&mut self,
x: f32,
y: f32,
width: f32,
height: f32,
min_depth: f32,
max_depth: f32,
) {
debug!(
"set viewport: {} {} {} {} {} {}",
x, y, width, height, min_depth, max_depth
);
self.pass
.set_viewport(x, y, width, height, min_depth, max_depth)
}

pub fn insert_debug_marker(&mut self, label: &str) {
debug!("insert debug marker: {}", label);
self.pass.insert_debug_marker(label)
}

pub fn push_debug_group(&mut self, label: &str) {
debug!("push_debug_group marker: {}", label);
self.pass.push_debug_group(label)
}

pub fn pop_debug_group(&mut self) {
debug!("pop_debug_group");
self.pass.pop_debug_group()
}

pub fn set_blend_constant(&mut self, color: Color) {
debug!("set blend constant: {:?}", color);
self.pass.set_blend_constant(wgpu::Color::from(color))
}
}

0 comments on commit c04dfc1

Please sign in to comment.