more command stuff

This commit is contained in:
janis 2026-04-12 20:23:45 +02:00
parent dde3093536
commit b8b9bf40a3
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8
5 changed files with 40 additions and 32 deletions

View file

@ -2,6 +2,7 @@
negative_impls, negative_impls,
map_try_insert, map_try_insert,
debug_closure_helpers, debug_closure_helpers,
core_io_borrowed_buf,
slice_partition_dedup slice_partition_dedup
)] )]

View file

@ -40,8 +40,8 @@ use super::resources::*;
// } // }
pub struct Copy<T: Resource, U: Resource> { pub struct Copy<T: Resource, U: Resource> {
pub src: Read<T>, pub src: T,
pub dst: Write<U>, pub dst: U,
} }
impl<T: Resource, U: Resource> Copy<T, U> { impl<T: Resource, U: Resource> Copy<T, U> {
fn side_effects_inner(&self, mut map: SideEffectMap) { fn side_effects_inner(&self, mut map: SideEffectMap) {
@ -273,9 +273,9 @@ impl Command for UpdateBuffer {
} }
pub struct BeginRendering { pub struct BeginRendering {
pub color_attachments: Vec<Write<TextureRegion>>, pub color_attachments: Vec<TextureRegion>,
pub depth_attachment: Option<Write<TextureRegion>>, pub depth_attachment: Option<TextureRegion>,
pub stencil_attachment: Option<Write<TextureRegion>>, pub stencil_attachment: Option<TextureRegion>,
pub area: (u32, u32), pub area: (u32, u32),
pub layers: u32, pub layers: u32,
} }
@ -318,7 +318,7 @@ impl Command for EndRendering {
fn apply(self, _recorder: &mut CommandRecorder) {} fn apply(self, _recorder: &mut CommandRecorder) {}
} }
pub struct BindPipeline(pub Pipeline); pub struct BindPipeline;
impl Command for BindPipeline { impl Command for BindPipeline {
fn side_effects(&self, _map: SideEffectMap) { fn side_effects(&self, _map: SideEffectMap) {
@ -329,7 +329,7 @@ impl Command for BindPipeline {
} }
pub struct BindVertexBuffers { pub struct BindVertexBuffers {
pub buffers: Vec<Read<BufferSlice>>, pub buffers: Vec<BufferSlice>,
} }
impl Command for BindVertexBuffers { impl Command for BindVertexBuffers {
@ -346,7 +346,7 @@ impl Command for BindVertexBuffers {
fn apply(self, _recorder: &mut CommandRecorder) {} fn apply(self, _recorder: &mut CommandRecorder) {}
} }
pub struct BindIndexBuffer(pub Read<BufferSlice>, pub IndexFormat); pub struct BindIndexBuffer(pub BufferSlice, pub IndexFormat);
impl Command for BindIndexBuffer { impl Command for BindIndexBuffer {
fn side_effects(&self, mut map: SideEffectMap) { fn side_effects(&self, mut map: SideEffectMap) {
@ -357,9 +357,7 @@ impl Command for BindIndexBuffer {
fn apply(self, _recorder: &mut CommandRecorder) {} fn apply(self, _recorder: &mut CommandRecorder) {}
} }
pub struct BindDescriptorSets { pub struct BindDescriptorSets;
pub sets: Vec<DescriptorSet>,
}
impl Command for BindDescriptorSets { impl Command for BindDescriptorSets {
fn side_effects(&self, _map: SideEffectMap) { fn side_effects(&self, _map: SideEffectMap) {
@ -401,9 +399,7 @@ impl Command for SetScissor {
fn apply(self, _recorder: &mut CommandRecorder) {} fn apply(self, _recorder: &mut CommandRecorder) {}
} }
pub struct PushConstants { pub struct PushConstants;
pub data: Box<[u8]>,
}
impl Command for PushConstants { impl Command for PushConstants {
fn side_effects(&self, _map: SideEffectMap) { fn side_effects(&self, _map: SideEffectMap) {
@ -429,11 +425,15 @@ pub struct DrawIndexedData {
} }
pub struct DrawIndirectData { pub struct DrawIndirectData {
pub indirect_buffer: Read<BufferSlice>, pub indirect_buffer: BufferSlice,
pub count: u32,
pub stride: u32,
} }
pub struct DrawIndexedIndirectData { pub struct DrawIndexedIndirectData {
pub indirect_buffer: Read<BufferSlice>, pub indirect_buffer: BufferSlice,
pub count: u32,
pub stride: u32,
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -445,9 +445,8 @@ pub enum IndexFormat {
pub struct Draw<T: IsDrawData> { pub struct Draw<T: IsDrawData> {
pub data: T, pub data: T,
pub vertex_buffers: Vec<Read<BufferSlice>>, pub vertex_buffers: Vec<BufferSlice>,
pub index_buffer: Option<(Read<BufferSlice>, IndexFormat)>, pub index_buffer: Option<(BufferSlice, IndexFormat)>,
pub count_buffer: Option<Read<BufferSlice>>,
} }
impl<T: IsDrawData> Command for Draw<T> { impl<T: IsDrawData> Command for Draw<T> {
@ -467,13 +466,6 @@ impl<T: IsDrawData> Command for Draw<T> {
None, None,
); );
} }
if let Some(count_buffer) = &self.count_buffer {
count_buffer.side_effect(
map.reborrow(),
vk::AccessFlags2::VERTEX_ATTRIBUTE_READ,
None,
);
}
} }
fn apply(self, _recorder: &mut CommandRecorder) {} fn apply(self, _recorder: &mut CommandRecorder) {}

View file

@ -4,5 +4,6 @@ mod legacy;
pub use legacy::*; pub use legacy::*;
mod commands; mod commands;
mod graph_builder;
mod recorder; mod recorder;
mod resources; mod resources;

View file

@ -105,6 +105,7 @@ pub struct CommandList {
num_commands: u32, num_commands: u32,
} }
#[must_use]
pub struct RenderPass<'a> { pub struct RenderPass<'a> {
cmd_list: &'a mut CommandList, cmd_list: &'a mut CommandList,
} }
@ -131,9 +132,9 @@ impl CommandList {
pub fn begin_rendering( pub fn begin_rendering(
&mut self, &mut self,
color_attachments: Vec<Write<TextureRegion>>, color_attachments: Vec<TextureRegion>,
depth_attachment: Option<Write<TextureRegion>>, depth_attachment: Option<TextureRegion>,
stencil_attachment: Option<Write<TextureRegion>>, stencil_attachment: Option<TextureRegion>,
area: (u32, u32), area: (u32, u32),
layers: u32, layers: u32,
) -> RenderPass<'_> { ) -> RenderPass<'_> {

View file

@ -262,7 +262,7 @@ pub struct Pipeline;
pub struct DescriptorSet; pub struct DescriptorSet;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ResourceId(u32); pub struct ResourceId(pub u32);
#[derive(Debug, Default, Clone, Copy)] #[derive(Debug, Default, Clone, Copy)]
pub struct ResourceAccess { pub struct ResourceAccess {
@ -497,8 +497,21 @@ impl TextureRange {
} }
} }
pub struct Buffer(ResourceId); pub struct Buffer(pub ResourceId);
pub struct Texture(ResourceId);
impl Buffer {
pub fn full_slice(self) -> BufferSlice {
BufferSlice {
buffer: self,
range: BufferRange {
offset: 0,
size: u64::MAX,
},
}
}
}
pub struct Texture(pub ResourceId);
pub struct BufferSlice { pub struct BufferSlice {
pub buffer: Buffer, pub buffer: Buffer,