starting render commands
This commit is contained in:
parent
75cb3456aa
commit
3438dfde84
|
|
@ -670,10 +670,10 @@ impl SamplerCache {
|
||||||
pub fn get_sampler(&mut self, desc: pipeline::SamplerDesc) -> VkResult<vk::Sampler> {
|
pub fn get_sampler(&mut self, desc: pipeline::SamplerDesc) -> VkResult<vk::Sampler> {
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
let entry = match self.samplers.entry(desc) {
|
let entry = match self.samplers.entry(desc) {
|
||||||
Entry::Occupied(entry) => entry.get().handle(),
|
Entry::Occupied(entry) => entry.get().raw(),
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
let sampler = pipeline::Sampler::new(self.device.clone(), entry.key())?;
|
let sampler = pipeline::Sampler::new(self.device.clone(), entry.key())?;
|
||||||
entry.insert(sampler).handle()
|
entry.insert(sampler).raw()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -350,8 +350,6 @@ impl DescriptorSetLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::device::DeviceOwned;
|
|
||||||
|
|
||||||
impl<T: AsRef<DeviceInner>> ExternallyManagedObject<T> for vk::PipelineLayout {
|
impl<T: AsRef<DeviceInner>> ExternallyManagedObject<T> for vk::PipelineLayout {
|
||||||
unsafe fn destroy(self, device: &T) {
|
unsafe fn destroy(self, device: &T) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
@ -491,6 +489,10 @@ impl Sampler {
|
||||||
sampler: DeviceObject::new(device, handle),
|
sampler: DeviceObject::new(device, handle),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw(&self) -> vk::Sampler {
|
||||||
|
*self.sampler
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: AsRef<DeviceInner>> ExternallyManagedObject<T> for vk::ShaderModule {
|
impl<T: AsRef<DeviceInner>> ExternallyManagedObject<T> for vk::ShaderModule {
|
||||||
|
|
|
||||||
152
crates/renderer/src/render_graph/commands.rs
Normal file
152
crates/renderer/src/render_graph/commands.rs
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use super::resources::*;
|
||||||
|
|
||||||
|
pub struct CopyBuffers {
|
||||||
|
pub src: Read<BufferSlice>,
|
||||||
|
pub dst: Write<BufferSlice>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CopyTextures {
|
||||||
|
pub src: Read<TextureRegion>,
|
||||||
|
pub dst: Write<TextureRegion>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ClearTexture {
|
||||||
|
pub dst: Write<TextureRegion>,
|
||||||
|
pub clear_value: [f32; 4],
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CopyBufferToTexture {
|
||||||
|
pub src: Read<BufferSlice>,
|
||||||
|
pub dst: Write<TextureRegion>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CopyTextureToBuffer {
|
||||||
|
pub src: Read<TextureRegion>,
|
||||||
|
pub dst: Write<BufferSlice>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Copy<T: Resource, U: Resource> {
|
||||||
|
pub src: Read<T>,
|
||||||
|
pub dst: Write<U>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct UpdateBuffer {
|
||||||
|
pub dst: Write<BufferSlice>,
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct UpdateTexture {
|
||||||
|
pub dst: Write<TextureRegion>,
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Update<T: Resource> {
|
||||||
|
pub dst: Write<T>,
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct RenderPass {
|
||||||
|
pub color_attachments: Vec<Write<TextureRegion>>,
|
||||||
|
pub depth_attachment: Option<Write<TextureRegion>>,
|
||||||
|
pub stencil_attachment: Option<Write<TextureRegion>>,
|
||||||
|
pub area: (u32, u32),
|
||||||
|
pub layers: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct BindPipeline(pub Pipeline);
|
||||||
|
pub struct BindVertexBuffers {
|
||||||
|
pub buffers: Vec<Read<BufferSlice>>,
|
||||||
|
}
|
||||||
|
pub struct BindIndexBuffer(pub Read<BufferSlice>, pub IndexFormat);
|
||||||
|
pub struct BindDescriptorSets {
|
||||||
|
pub sets: Vec<DescriptorSet>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SetViewport {
|
||||||
|
pub x: f32,
|
||||||
|
pub y: f32,
|
||||||
|
pub width: f32,
|
||||||
|
pub height: f32,
|
||||||
|
pub min_depth: f32,
|
||||||
|
pub max_depth: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SetScissor {
|
||||||
|
pub x: u32,
|
||||||
|
pub y: u32,
|
||||||
|
pub width: u32,
|
||||||
|
pub height: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct PushConstants {
|
||||||
|
pub data: Box<[u8]>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DrawData {
|
||||||
|
pub vertex_count: u32,
|
||||||
|
pub instance_count: u32,
|
||||||
|
pub first_vertex: u32,
|
||||||
|
pub first_instance: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DrawIndexedData {
|
||||||
|
pub index_count: u32,
|
||||||
|
pub instance_count: u32,
|
||||||
|
pub first_index: u32,
|
||||||
|
pub vertex_offset: i32,
|
||||||
|
pub first_instance: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DrawIndirectData {
|
||||||
|
pub indirect_buffer: Read<BufferSlice>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DrawIndexedIndirectData {
|
||||||
|
pub indirect_buffer: Read<BufferSlice>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub enum IndexFormat {
|
||||||
|
Uint8,
|
||||||
|
Uint16,
|
||||||
|
Uint32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Draw<T: IsDrawData> {
|
||||||
|
pub data: T,
|
||||||
|
pub vertex_buffers: Vec<Read<BufferSlice>>,
|
||||||
|
pub index_buffer: Option<(Read<BufferSlice>, IndexFormat)>,
|
||||||
|
pub count_buffer: Option<Read<BufferSlice>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Dispatch;
|
||||||
|
|
||||||
|
mod sealed {
|
||||||
|
pub trait IsDrawData {}
|
||||||
|
pub trait InsideRenderPass {}
|
||||||
|
pub trait OutsideRenderPass {}
|
||||||
|
}
|
||||||
|
use sealed::*;
|
||||||
|
|
||||||
|
impl IsDrawData for DrawData {}
|
||||||
|
impl IsDrawData for DrawIndexedData {}
|
||||||
|
impl IsDrawData for DrawIndirectData {}
|
||||||
|
impl IsDrawData for DrawIndexedIndirectData {}
|
||||||
|
|
||||||
|
impl InsideRenderPass for BindPipeline {}
|
||||||
|
impl OutsideRenderPass for BindPipeline {}
|
||||||
|
impl InsideRenderPass for BindVertexBuffers {}
|
||||||
|
impl OutsideRenderPass for BindVertexBuffers {}
|
||||||
|
impl InsideRenderPass for BindIndexBuffer {}
|
||||||
|
impl OutsideRenderPass for BindIndexBuffer {}
|
||||||
|
impl InsideRenderPass for BindDescriptorSets {}
|
||||||
|
impl OutsideRenderPass for BindDescriptorSets {}
|
||||||
|
impl OutsideRenderPass for PushConstants {}
|
||||||
|
|
||||||
|
impl InsideRenderPass for SetViewport {}
|
||||||
|
impl InsideRenderPass for SetScissor {}
|
||||||
|
impl InsideRenderPass for PushConstants {}
|
||||||
|
impl<T: IsDrawData> InsideRenderPass for Draw<T> {}
|
||||||
|
impl<T: IsDrawData> InsideRenderPass for T {}
|
||||||
1320
crates/renderer/src/render_graph/legacy.rs
Normal file
1320
crates/renderer/src/render_graph/legacy.rs
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2
crates/renderer/src/render_graph/recorder.rs
Normal file
2
crates/renderer/src/render_graph/recorder.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
struct CommandRecorder;
|
||||||
|
struct RenderPassRecorder;
|
||||||
34
crates/renderer/src/render_graph/resources.rs
Normal file
34
crates/renderer/src/render_graph/resources.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
use crate::images::MipRange;
|
||||||
|
|
||||||
|
pub trait Resource: Sized {}
|
||||||
|
|
||||||
|
mod impls {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
impl Resource for Buffer {}
|
||||||
|
impl Resource for Texture {}
|
||||||
|
impl Resource for BufferSlice {}
|
||||||
|
impl Resource for TextureRegion {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Pipeline;
|
||||||
|
pub struct DescriptorSet;
|
||||||
|
|
||||||
|
pub struct Buffer;
|
||||||
|
pub struct Texture;
|
||||||
|
pub struct BufferSlice {
|
||||||
|
pub buffer: Buffer,
|
||||||
|
pub offset: u64,
|
||||||
|
pub size: u64,
|
||||||
|
}
|
||||||
|
pub struct TextureRegion {
|
||||||
|
pub texture: Texture,
|
||||||
|
pub mip_levels: MipRange,
|
||||||
|
pub array_layers: MipRange,
|
||||||
|
pub origin: (u32, u32, u32),
|
||||||
|
pub extent: (u32, u32, u32),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Read<T>(pub T);
|
||||||
|
pub struct Write<T>(pub T);
|
||||||
|
pub struct ReadWrite<T>(pub T);
|
||||||
Loading…
Reference in a new issue