Struct bevy::render::render_phase::TrackedRenderPass
pub struct TrackedRenderPass<'a> { /* private fields */ }
Expand description
A [RenderPass
], which tracks the current pipeline state to skip redundant operations.
It is used to set the current RenderPipeline
, BindGroup
s and Buffer
s.
After all requirements are specified, draw calls can be issued.
Implementations§
§impl<'a> TrackedRenderPass<'a>
impl<'a> TrackedRenderPass<'a>
pub fn new(device: &RenderDevice, pass: RenderPass<'a>) -> TrackedRenderPass<'a>
pub fn new(device: &RenderDevice, pass: RenderPass<'a>) -> TrackedRenderPass<'a>
Tracks the supplied render pass.
pub fn wgpu_pass(&mut self) -> &mut RenderPass<'a>
pub fn wgpu_pass(&mut self) -> &mut RenderPass<'a>
Returns the wgpu [RenderPass
].
pub fn set_render_pipeline(&mut self, pipeline: &'a RenderPipeline)
pub fn set_render_pipeline(&mut self, pipeline: &'a RenderPipeline)
Sets the active RenderPipeline
.
Subsequent draw calls will exhibit the behavior defined by the pipeline
.
Examples found in repository?
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
fn run(
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(view_target, _post_process_settings): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
// Get the pipeline resource that contains the global data we need
// to create the render pipeline
let post_process_pipeline = world.resource::<PostProcessPipeline>();
// The pipeline cache is a cache of all previously created pipelines.
// It is required to avoid creating a new pipeline each frame,
// which is expensive due to shader compilation.
let pipeline_cache = world.resource::<PipelineCache>();
// Get the pipeline from the cache
let Some(pipeline) = pipeline_cache.get_render_pipeline(post_process_pipeline.pipeline_id)
else {
return Ok(());
};
// Get the settings uniform binding
let settings_uniforms = world.resource::<ComponentUniforms<PostProcessSettings>>();
let Some(settings_binding) = settings_uniforms.uniforms().binding() else {
return Ok(());
};
// This will start a new "post process write", obtaining two texture
// views from the view target - a `source` and a `destination`.
// `source` is the "current" main texture and you _must_ write into
// `destination` because calling `post_process_write()` on the
// [`ViewTarget`] will internally flip the [`ViewTarget`]'s main
// texture to the `destination` texture. Failing to do so will cause
// the current main texture information to be lost.
let post_process = view_target.post_process_write();
// The bind_group gets created each frame.
//
// Normally, you would create a bind_group in the Queue set,
// but this doesn't work with the post_process_write().
// The reason it doesn't work is because each post_process_write will alternate the source/destination.
// The only way to have the correct source/destination for the bind_group
// is to make sure you get it during the node execution.
let bind_group = render_context.render_device().create_bind_group(
"post_process_bind_group",
&post_process_pipeline.layout,
// It's important for this to match the BindGroupLayout defined in the PostProcessPipeline
&BindGroupEntries::sequential((
// Make sure to use the source view
post_process.source,
// Use the sampler created for the pipeline
&post_process_pipeline.sampler,
// Set the settings binding
settings_binding.clone(),
)),
);
// Begin the render pass
let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some("post_process_pass"),
color_attachments: &[Some(RenderPassColorAttachment {
// We need to specify the post process destination view here
// to make sure we write to the appropriate texture.
view: post_process.destination,
resolve_target: None,
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
// This is mostly just wgpu boilerplate for drawing a fullscreen triangle,
// using the pipeline/bind_group created above
render_pass.set_render_pipeline(pipeline);
render_pass.set_bind_group(0, &bind_group, &[]);
render_pass.draw(0..3, 0..1);
Ok(())
}
pub fn set_bind_group(
&mut self,
index: usize,
bind_group: &'a BindGroup,
dynamic_uniform_indices: &[u32]
)
pub fn set_bind_group( &mut self, index: usize, bind_group: &'a BindGroup, dynamic_uniform_indices: &[u32] )
Sets the active bind group for a given bind group index. The bind group layout
in the active pipeline when any draw()
function is called must match the layout of
this bind group.
If the bind group have dynamic offsets, provide them in binding order.
These offsets have to be aligned to WgpuLimits::min_uniform_buffer_offset_alignment
or WgpuLimits::min_storage_buffer_offset_alignment
appropriately.
Examples found in repository?
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
fn run(
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(view_target, _post_process_settings): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
// Get the pipeline resource that contains the global data we need
// to create the render pipeline
let post_process_pipeline = world.resource::<PostProcessPipeline>();
// The pipeline cache is a cache of all previously created pipelines.
// It is required to avoid creating a new pipeline each frame,
// which is expensive due to shader compilation.
let pipeline_cache = world.resource::<PipelineCache>();
// Get the pipeline from the cache
let Some(pipeline) = pipeline_cache.get_render_pipeline(post_process_pipeline.pipeline_id)
else {
return Ok(());
};
// Get the settings uniform binding
let settings_uniforms = world.resource::<ComponentUniforms<PostProcessSettings>>();
let Some(settings_binding) = settings_uniforms.uniforms().binding() else {
return Ok(());
};
// This will start a new "post process write", obtaining two texture
// views from the view target - a `source` and a `destination`.
// `source` is the "current" main texture and you _must_ write into
// `destination` because calling `post_process_write()` on the
// [`ViewTarget`] will internally flip the [`ViewTarget`]'s main
// texture to the `destination` texture. Failing to do so will cause
// the current main texture information to be lost.
let post_process = view_target.post_process_write();
// The bind_group gets created each frame.
//
// Normally, you would create a bind_group in the Queue set,
// but this doesn't work with the post_process_write().
// The reason it doesn't work is because each post_process_write will alternate the source/destination.
// The only way to have the correct source/destination for the bind_group
// is to make sure you get it during the node execution.
let bind_group = render_context.render_device().create_bind_group(
"post_process_bind_group",
&post_process_pipeline.layout,
// It's important for this to match the BindGroupLayout defined in the PostProcessPipeline
&BindGroupEntries::sequential((
// Make sure to use the source view
post_process.source,
// Use the sampler created for the pipeline
&post_process_pipeline.sampler,
// Set the settings binding
settings_binding.clone(),
)),
);
// Begin the render pass
let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some("post_process_pass"),
color_attachments: &[Some(RenderPassColorAttachment {
// We need to specify the post process destination view here
// to make sure we write to the appropriate texture.
view: post_process.destination,
resolve_target: None,
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
// This is mostly just wgpu boilerplate for drawing a fullscreen triangle,
// using the pipeline/bind_group created above
render_pass.set_render_pipeline(pipeline);
render_pass.set_bind_group(0, &bind_group, &[]);
render_pass.draw(0..3, 0..1);
Ok(())
}
pub fn set_vertex_buffer(
&mut self,
slot_index: usize,
buffer_slice: BufferSlice<'a>
)
pub fn set_vertex_buffer( &mut self, slot_index: usize, buffer_slice: BufferSlice<'a> )
Assign a vertex buffer to a slot.
Subsequent calls to draw
and draw_indexed
on this
TrackedRenderPass
will use buffer
as one of the source vertex buffers.
The slot_index
refers to the index of the matching descriptor in
VertexState::buffers
.
Examples found in repository?
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
fn render<'w>(
item: &P,
_view: (),
instance_buffer: Option<&'w InstanceBuffer>,
(meshes, render_mesh_instances): SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(item.entity())
else {
return RenderCommandResult::Failure;
};
let Some(gpu_mesh) = meshes.into_inner().get(mesh_instance.mesh_asset_id) else {
return RenderCommandResult::Failure;
};
let Some(instance_buffer) = instance_buffer else {
return RenderCommandResult::Failure;
};
pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
pass.set_vertex_buffer(1, instance_buffer.buffer.slice(..));
match &gpu_mesh.buffer_info {
GpuBufferInfo::Indexed {
buffer,
index_format,
count,
} => {
pass.set_index_buffer(buffer.slice(..), 0, *index_format);
pass.draw_indexed(0..*count, 0, 0..instance_buffer.length as u32);
}
GpuBufferInfo::NonIndexed => {
pass.draw(0..gpu_mesh.vertex_count, 0..instance_buffer.length as u32);
}
}
RenderCommandResult::Success
}
pub fn set_index_buffer(
&mut self,
buffer_slice: BufferSlice<'a>,
offset: u64,
index_format: IndexFormat
)
pub fn set_index_buffer( &mut self, buffer_slice: BufferSlice<'a>, offset: u64, index_format: IndexFormat )
Sets the active index buffer.
Subsequent calls to TrackedRenderPass::draw_indexed
will use the buffer referenced by
buffer_slice
as the source index buffer.
Examples found in repository?
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
fn render<'w>(
item: &P,
_view: (),
instance_buffer: Option<&'w InstanceBuffer>,
(meshes, render_mesh_instances): SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(item.entity())
else {
return RenderCommandResult::Failure;
};
let Some(gpu_mesh) = meshes.into_inner().get(mesh_instance.mesh_asset_id) else {
return RenderCommandResult::Failure;
};
let Some(instance_buffer) = instance_buffer else {
return RenderCommandResult::Failure;
};
pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
pass.set_vertex_buffer(1, instance_buffer.buffer.slice(..));
match &gpu_mesh.buffer_info {
GpuBufferInfo::Indexed {
buffer,
index_format,
count,
} => {
pass.set_index_buffer(buffer.slice(..), 0, *index_format);
pass.draw_indexed(0..*count, 0, 0..instance_buffer.length as u32);
}
GpuBufferInfo::NonIndexed => {
pass.draw(0..gpu_mesh.vertex_count, 0..instance_buffer.length as u32);
}
}
RenderCommandResult::Success
}
pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>)
pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>)
Draws primitives from the active vertex buffer(s).
The active vertex buffer(s) can be set with TrackedRenderPass::set_vertex_buffer
.
Examples found in repository?
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
fn render<'w>(
item: &P,
_view: (),
instance_buffer: Option<&'w InstanceBuffer>,
(meshes, render_mesh_instances): SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(item.entity())
else {
return RenderCommandResult::Failure;
};
let Some(gpu_mesh) = meshes.into_inner().get(mesh_instance.mesh_asset_id) else {
return RenderCommandResult::Failure;
};
let Some(instance_buffer) = instance_buffer else {
return RenderCommandResult::Failure;
};
pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
pass.set_vertex_buffer(1, instance_buffer.buffer.slice(..));
match &gpu_mesh.buffer_info {
GpuBufferInfo::Indexed {
buffer,
index_format,
count,
} => {
pass.set_index_buffer(buffer.slice(..), 0, *index_format);
pass.draw_indexed(0..*count, 0, 0..instance_buffer.length as u32);
}
GpuBufferInfo::NonIndexed => {
pass.draw(0..gpu_mesh.vertex_count, 0..instance_buffer.length as u32);
}
}
RenderCommandResult::Success
}
More examples
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
fn run(
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(view_target, _post_process_settings): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
// Get the pipeline resource that contains the global data we need
// to create the render pipeline
let post_process_pipeline = world.resource::<PostProcessPipeline>();
// The pipeline cache is a cache of all previously created pipelines.
// It is required to avoid creating a new pipeline each frame,
// which is expensive due to shader compilation.
let pipeline_cache = world.resource::<PipelineCache>();
// Get the pipeline from the cache
let Some(pipeline) = pipeline_cache.get_render_pipeline(post_process_pipeline.pipeline_id)
else {
return Ok(());
};
// Get the settings uniform binding
let settings_uniforms = world.resource::<ComponentUniforms<PostProcessSettings>>();
let Some(settings_binding) = settings_uniforms.uniforms().binding() else {
return Ok(());
};
// This will start a new "post process write", obtaining two texture
// views from the view target - a `source` and a `destination`.
// `source` is the "current" main texture and you _must_ write into
// `destination` because calling `post_process_write()` on the
// [`ViewTarget`] will internally flip the [`ViewTarget`]'s main
// texture to the `destination` texture. Failing to do so will cause
// the current main texture information to be lost.
let post_process = view_target.post_process_write();
// The bind_group gets created each frame.
//
// Normally, you would create a bind_group in the Queue set,
// but this doesn't work with the post_process_write().
// The reason it doesn't work is because each post_process_write will alternate the source/destination.
// The only way to have the correct source/destination for the bind_group
// is to make sure you get it during the node execution.
let bind_group = render_context.render_device().create_bind_group(
"post_process_bind_group",
&post_process_pipeline.layout,
// It's important for this to match the BindGroupLayout defined in the PostProcessPipeline
&BindGroupEntries::sequential((
// Make sure to use the source view
post_process.source,
// Use the sampler created for the pipeline
&post_process_pipeline.sampler,
// Set the settings binding
settings_binding.clone(),
)),
);
// Begin the render pass
let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some("post_process_pass"),
color_attachments: &[Some(RenderPassColorAttachment {
// We need to specify the post process destination view here
// to make sure we write to the appropriate texture.
view: post_process.destination,
resolve_target: None,
ops: Operations::default(),
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
// This is mostly just wgpu boilerplate for drawing a fullscreen triangle,
// using the pipeline/bind_group created above
render_pass.set_render_pipeline(pipeline);
render_pass.set_bind_group(0, &bind_group, &[]);
render_pass.draw(0..3, 0..1);
Ok(())
}
pub fn draw_indexed(
&mut self,
indices: Range<u32>,
base_vertex: i32,
instances: Range<u32>
)
pub fn draw_indexed( &mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32> )
Draws indexed primitives using the active index buffer and the active vertex buffer(s).
The active index buffer can be set with TrackedRenderPass::set_index_buffer
, while the
active vertex buffer(s) can be set with TrackedRenderPass::set_vertex_buffer
.
Examples found in repository?
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
fn render<'w>(
item: &P,
_view: (),
instance_buffer: Option<&'w InstanceBuffer>,
(meshes, render_mesh_instances): SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(item.entity())
else {
return RenderCommandResult::Failure;
};
let Some(gpu_mesh) = meshes.into_inner().get(mesh_instance.mesh_asset_id) else {
return RenderCommandResult::Failure;
};
let Some(instance_buffer) = instance_buffer else {
return RenderCommandResult::Failure;
};
pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
pass.set_vertex_buffer(1, instance_buffer.buffer.slice(..));
match &gpu_mesh.buffer_info {
GpuBufferInfo::Indexed {
buffer,
index_format,
count,
} => {
pass.set_index_buffer(buffer.slice(..), 0, *index_format);
pass.draw_indexed(0..*count, 0, 0..instance_buffer.length as u32);
}
GpuBufferInfo::NonIndexed => {
pass.draw(0..gpu_mesh.vertex_count, 0..instance_buffer.length as u32);
}
}
RenderCommandResult::Success
}
pub fn draw_indirect(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: u64
)
pub fn draw_indirect( &mut self, indirect_buffer: &'a Buffer, indirect_offset: u64 )
Draws primitives from the active vertex buffer(s) based on the contents of the
indirect_buffer
.
The active vertex buffers can be set with TrackedRenderPass::set_vertex_buffer
.
The structure expected in indirect_buffer
is the following:
#[repr(C)]
struct DrawIndirect {
vertex_count: u32, // The number of vertices to draw.
instance_count: u32, // The number of instances to draw.
first_vertex: u32, // The Index of the first vertex to draw.
first_instance: u32, // The instance ID of the first instance to draw.
// has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
}
pub fn draw_indexed_indirect(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: u64
)
pub fn draw_indexed_indirect( &mut self, indirect_buffer: &'a Buffer, indirect_offset: u64 )
Draws indexed primitives using the active index buffer and the active vertex buffers,
based on the contents of the indirect_buffer
.
The active index buffer can be set with TrackedRenderPass::set_index_buffer
, while the
active vertex buffers can be set with TrackedRenderPass::set_vertex_buffer
.
The structure expected in indirect_buffer
is the following:
#[repr(C)]
struct DrawIndexedIndirect {
vertex_count: u32, // The number of vertices to draw.
instance_count: u32, // The number of instances to draw.
first_index: u32, // The base index within the index buffer.
vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
first_instance: u32, // The instance ID of the first instance to draw.
// has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
}
pub fn multi_draw_indirect(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: u64,
count: u32
)
pub fn multi_draw_indirect( &mut self, indirect_buffer: &'a Buffer, indirect_offset: u64, count: u32 )
Dispatches multiple draw calls from the active vertex buffer(s) based on the contents of the
indirect_buffer
.count
draw calls are issued.
The active vertex buffers can be set with TrackedRenderPass::set_vertex_buffer
.
indirect_buffer
should contain count
tightly packed elements of the following structure:
#[repr(C)]
struct DrawIndirect {
vertex_count: u32, // The number of vertices to draw.
instance_count: u32, // The number of instances to draw.
first_vertex: u32, // The Index of the first vertex to draw.
first_instance: u32, // The instance ID of the first instance to draw.
// has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
}
pub fn multi_draw_indirect_count(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: u64,
count_buffer: &'a Buffer,
count_offset: u64,
max_count: u32
)
pub fn multi_draw_indirect_count( &mut self, indirect_buffer: &'a Buffer, indirect_offset: u64, count_buffer: &'a Buffer, count_offset: u64, max_count: u32 )
Dispatches multiple draw calls from the active vertex buffer(s) based on the contents of
the indirect_buffer
.
The count buffer is read to determine how many draws to issue.
The indirect buffer must be long enough to account for max_count
draws, however only
count
elements will be read, where count
is the value read from count_buffer
capped
at max_count
.
The active vertex buffers can be set with TrackedRenderPass::set_vertex_buffer
.
indirect_buffer
should contain count
tightly packed elements of the following structure:
#[repr(C)]
struct DrawIndirect {
vertex_count: u32, // The number of vertices to draw.
instance_count: u32, // The number of instances to draw.
first_vertex: u32, // The Index of the first vertex to draw.
first_instance: u32, // The instance ID of the first instance to draw.
// has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
}
pub fn multi_draw_indexed_indirect(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: u64,
count: u32
)
pub fn multi_draw_indexed_indirect( &mut self, indirect_buffer: &'a Buffer, indirect_offset: u64, count: u32 )
Dispatches multiple draw calls from the active index buffer and the active vertex buffers,
based on the contents of the indirect_buffer
. count
draw calls are issued.
The active index buffer can be set with TrackedRenderPass::set_index_buffer
, while the
active vertex buffers can be set with TrackedRenderPass::set_vertex_buffer
.
indirect_buffer
should contain count
tightly packed elements of the following structure:
#[repr(C)]
struct DrawIndexedIndirect {
vertex_count: u32, // The number of vertices to draw.
instance_count: u32, // The number of instances to draw.
first_index: u32, // The base index within the index buffer.
vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
first_instance: u32, // The instance ID of the first instance to draw.
// has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
}
pub fn multi_draw_indexed_indirect_count(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: u64,
count_buffer: &'a Buffer,
count_offset: u64,
max_count: u32
)
pub fn multi_draw_indexed_indirect_count( &mut self, indirect_buffer: &'a Buffer, indirect_offset: u64, count_buffer: &'a Buffer, count_offset: u64, max_count: u32 )
Dispatches multiple draw calls from the active index buffer and the active vertex buffers,
based on the contents of the indirect_buffer
.
The count buffer is read to determine how many draws to issue.
The indirect buffer must be long enough to account for max_count
draws, however only
count
elements will be read, where count
is the value read from count_buffer
capped
at max_count
.
The active index buffer can be set with TrackedRenderPass::set_index_buffer
, while the
active vertex buffers can be set with TrackedRenderPass::set_vertex_buffer
.
indirect_buffer
should contain count
tightly packed elements of the following structure:
#[repr(C)]
struct DrawIndexedIndirect {
vertex_count: u32, // The number of vertices to draw.
instance_count: u32, // The number of instances to draw.
first_index: u32, // The base index within the index buffer.
vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
first_instance: u32, // The instance ID of the first instance to draw.
// has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
}
pub fn set_stencil_reference(&mut self, reference: u32)
pub fn set_stencil_reference(&mut self, reference: u32)
Sets the stencil reference.
Subsequent stencil tests will test against this value.
pub fn set_scissor_rect(&mut self, x: u32, y: u32, width: u32, height: u32)
pub fn set_scissor_rect(&mut self, x: u32, y: u32, width: u32, height: u32)
Sets the scissor region.
Subsequent draw calls will discard any fragments that fall outside this region.
pub fn set_push_constants(
&mut self,
stages: ShaderStages,
offset: u32,
data: &[u8]
)
pub fn set_push_constants( &mut self, stages: ShaderStages, offset: u32, data: &[u8] )
Set push constant data.
Features::PUSH_CONSTANTS
must be enabled on the device in order to call these functions.
pub fn set_viewport(
&mut self,
x: f32,
y: f32,
width: f32,
height: f32,
min_depth: f32,
max_depth: f32
)
pub fn set_viewport( &mut self, x: f32, y: f32, width: f32, height: f32, min_depth: f32, max_depth: f32 )
Set the rendering viewport.
Subsequent draw calls will be projected into that viewport.
pub fn set_camera_viewport(&mut self, viewport: &Viewport)
pub fn set_camera_viewport(&mut self, viewport: &Viewport)
Set the rendering viewport to the given camera Viewport
.
Subsequent draw calls will be projected into that viewport.
pub fn insert_debug_marker(&mut self, label: &str)
pub fn insert_debug_marker(&mut self, label: &str)
Insert a single debug marker.
This is a GPU debugging feature. This has no effect on the rendering itself.
pub fn push_debug_group(&mut self, label: &str)
pub fn push_debug_group(&mut self, label: &str)
Start a new debug group.
Push a new debug group over the internal stack. Subsequent render commands and debug
markers are grouped into this new group, until pop_debug_group
is called.
pass.push_debug_group("Render the car");
// [setup pipeline etc...]
pass.draw(0..64, 0..1);
pass.pop_debug_group();
Note that push_debug_group
and pop_debug_group
must always be called in pairs.
This is a GPU debugging feature. This has no effect on the rendering itself.
pub fn pop_debug_group(&mut self)
pub fn pop_debug_group(&mut self)
End the current debug group.
Subsequent render commands and debug markers are not grouped anymore in this group, but in the previous one (if any) or the default top-level one if the debug group was the last one on the stack.
Note that push_debug_group
and pop_debug_group
must always be called in pairs.
This is a GPU debugging feature. This has no effect on the rendering itself.
pub fn set_blend_constant(&mut self, color: LinearRgba)
pub fn set_blend_constant(&mut self, color: LinearRgba)
Sets the blend color as used by some of the blending modes.
Subsequent blending tests will test against this value.
Auto Trait Implementations§
impl<'a> Freeze for TrackedRenderPass<'a>
impl<'a> !RefUnwindSafe for TrackedRenderPass<'a>
impl<'a> Send for TrackedRenderPass<'a>
impl<'a> Sync for TrackedRenderPass<'a>
impl<'a> Unpin for TrackedRenderPass<'a>
impl<'a> !UnwindSafe for TrackedRenderPass<'a>
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more