idk?
This commit is contained in:
parent
b8b9bf40a3
commit
a297dd94da
|
|
@ -773,6 +773,9 @@ impl Pipeline {
|
|||
pub fn bind_point(&self) -> vk::PipelineBindPoint {
|
||||
self.bind_point
|
||||
}
|
||||
pub fn layout(&self) -> &Arc<PipelineLayout> {
|
||||
&self.layout
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod pipeline_cache {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
use crate::{
|
||||
device::DeviceOwned,
|
||||
pipeline::Pipeline,
|
||||
render_graph::recorder::{CommandRecorder, SideEffectMap},
|
||||
};
|
||||
|
||||
|
|
@ -318,18 +319,26 @@ impl Command for EndRendering {
|
|||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
}
|
||||
|
||||
pub struct BindPipeline;
|
||||
pub struct BindPipeline<'cmd>(pub &'cmd Pipeline);
|
||||
|
||||
impl Command for BindPipeline {
|
||||
impl<'cmd> Command for BindPipeline<'cmd> {
|
||||
fn side_effects(&self, _map: SideEffectMap) {
|
||||
// No resource access, but affects the pipeline state
|
||||
}
|
||||
|
||||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
fn apply(self, recorder: &mut CommandRecorder) {
|
||||
let cmd = recorder.cmd_buffer();
|
||||
let dev = &cmd.device().raw;
|
||||
|
||||
unsafe {
|
||||
dev.cmd_bind_pipeline(cmd.raw(), self.0.bind_point(), self.0.raw());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BindVertexBuffers {
|
||||
pub buffers: Vec<BufferSlice>,
|
||||
pub first_binding: u32,
|
||||
}
|
||||
|
||||
impl Command for BindVertexBuffers {
|
||||
|
|
@ -343,7 +352,26 @@ impl Command for BindVertexBuffers {
|
|||
}
|
||||
}
|
||||
|
||||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
fn apply(self, recorder: &mut CommandRecorder) {
|
||||
let cmd = recorder.cmd_buffer();
|
||||
let dev = &cmd.device().raw;
|
||||
|
||||
let buffers = self
|
||||
.buffers
|
||||
.iter()
|
||||
.map(|buffer| recorder.get_buffer_handle(buffer.id()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let offsets = self
|
||||
.buffers
|
||||
.iter()
|
||||
.map(|buffer| buffer.range.offset)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
unsafe {
|
||||
dev.cmd_bind_vertex_buffers(cmd.raw(), self.first_binding, &buffers, &offsets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BindIndexBuffer(pub BufferSlice, pub IndexFormat);
|
||||
|
|
@ -354,17 +382,50 @@ impl Command for BindIndexBuffer {
|
|||
.side_effect(map.reborrow(), vk::AccessFlags2::INDEX_READ, None);
|
||||
}
|
||||
|
||||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
fn apply(self, recorder: &mut CommandRecorder) {
|
||||
let cmd = recorder.cmd_buffer();
|
||||
let dev = &cmd.device().raw;
|
||||
|
||||
let buffer = recorder.get_buffer_handle(self.0.id());
|
||||
let index_type = match self.1 {
|
||||
IndexFormat::Uint8 => vk::IndexType::UINT8_KHR,
|
||||
IndexFormat::Uint16 => vk::IndexType::UINT16,
|
||||
IndexFormat::Uint32 => vk::IndexType::UINT32,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
dev.cmd_bind_index_buffer(cmd.raw(), buffer, self.0.range.offset, index_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BindDescriptorSets;
|
||||
pub struct BindDescriptorSets {
|
||||
pub first_set: u32,
|
||||
pub pipeline_layout: vk::PipelineLayout,
|
||||
pub bind_point: vk::PipelineBindPoint,
|
||||
pub sets: Vec<vk::DescriptorSet>,
|
||||
}
|
||||
|
||||
impl Command for BindDescriptorSets {
|
||||
fn side_effects(&self, _map: SideEffectMap) {
|
||||
// No resource access, but affects the descriptor set state
|
||||
}
|
||||
|
||||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
fn apply(self, recorder: &mut CommandRecorder) {
|
||||
let cmd = recorder.cmd_buffer();
|
||||
let dev = &cmd.device().raw;
|
||||
|
||||
unsafe {
|
||||
dev.cmd_bind_descriptor_sets(
|
||||
cmd.raw(),
|
||||
self.bind_point,
|
||||
self.pipeline_layout,
|
||||
self.first_set,
|
||||
&self.sets,
|
||||
&[],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SetViewport {
|
||||
|
|
@ -399,14 +460,32 @@ impl Command for SetScissor {
|
|||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
}
|
||||
|
||||
pub struct PushConstants;
|
||||
pub struct PushConstants {
|
||||
pub pipeline_layout: vk::PipelineLayout,
|
||||
pub stage_flags: vk::ShaderStageFlags,
|
||||
pub offset: u32,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Command for PushConstants {
|
||||
fn side_effects(&self, _map: SideEffectMap) {
|
||||
// No resource access, but affects the push constant state
|
||||
}
|
||||
|
||||
fn apply(self, _recorder: &mut CommandRecorder) {}
|
||||
fn apply(self, recorder: &mut CommandRecorder) {
|
||||
let cmd = recorder.cmd_buffer();
|
||||
let dev = &cmd.device().raw;
|
||||
|
||||
unsafe {
|
||||
dev.cmd_push_constants(
|
||||
cmd.raw(),
|
||||
self.pipeline_layout,
|
||||
self.stage_flags,
|
||||
self.offset,
|
||||
&self.data,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DrawData {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
marker::PhantomData,
|
||||
mem::{MaybeUninit, size_of},
|
||||
ptr::NonNull,
|
||||
};
|
||||
|
|
@ -115,7 +116,10 @@ impl<'a> RenderPass<'a> {
|
|||
self.cmd_list.push_inner(super::commands::EndRendering);
|
||||
}
|
||||
|
||||
pub fn push<C: Command + InsideRenderPass>(&mut self, command: C) {
|
||||
pub fn push<'c, C: Command + InsideRenderPass + 'c>(&mut self, command: C)
|
||||
where
|
||||
'c: 'a,
|
||||
{
|
||||
self.cmd_list.push_inner(command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,9 +258,6 @@ mod impls {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Pipeline;
|
||||
pub struct DescriptorSet;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct ResourceId(pub u32);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue