Compare commits
No commits in common. "3438dfde842c98716c35b4ebd6eeceee7600bcf2" and "4f95f3a928825b2caaee87216aba69c6b729ec16" have entirely different histories.
3438dfde84
...
4f95f3a928
|
|
@ -670,10 +670,10 @@ impl SamplerCache {
|
|||
pub fn get_sampler(&mut self, desc: pipeline::SamplerDesc) -> VkResult<vk::Sampler> {
|
||||
use std::collections::hash_map::Entry;
|
||||
let entry = match self.samplers.entry(desc) {
|
||||
Entry::Occupied(entry) => entry.get().raw(),
|
||||
Entry::Occupied(entry) => entry.get().handle(),
|
||||
Entry::Vacant(entry) => {
|
||||
let sampler = pipeline::Sampler::new(self.device.clone(), entry.key())?;
|
||||
entry.insert(sampler).raw()
|
||||
entry.insert(sampler).handle()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use ash::{ext, prelude::*, vk};
|
|||
use parking_lot::Mutex;
|
||||
|
||||
use crate::{
|
||||
define_device_owned_handle,
|
||||
device::{
|
||||
Device, DeviceHandle, DeviceInner, DeviceObject, asdf::traits::ExternallyManagedObject,
|
||||
},
|
||||
|
|
@ -350,6 +351,8 @@ impl DescriptorSetLayout {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::device::DeviceOwned;
|
||||
|
||||
impl<T: AsRef<DeviceInner>> ExternallyManagedObject<T> for vk::PipelineLayout {
|
||||
unsafe fn destroy(self, device: &T) {
|
||||
unsafe {
|
||||
|
|
@ -447,22 +450,13 @@ impl std::hash::Hash for SamplerDesc {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> ExternallyManagedObject<T> for vk::Sampler
|
||||
where
|
||||
T: AsRef<DeviceInner>,
|
||||
{
|
||||
unsafe fn destroy(self, device: &T) {
|
||||
unsafe {
|
||||
device.as_ref().raw.destroy_sampler(self, None);
|
||||
}
|
||||
define_device_owned_handle! {
|
||||
#[derive(Debug)]
|
||||
pub Sampler(vk::Sampler) {} => |this| unsafe {
|
||||
this.device().dev().destroy_sampler(this.handle(), None);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Sampler {
|
||||
sampler: DeviceObject<vk::Sampler>,
|
||||
}
|
||||
|
||||
impl Sampler {
|
||||
pub fn new(device: Device, desc: &SamplerDesc) -> VkResult<Self> {
|
||||
let info = &vk::SamplerCreateInfo::default()
|
||||
|
|
@ -485,13 +479,7 @@ impl Sampler {
|
|||
|
||||
let handle = unsafe { device.dev().create_sampler(info, None)? };
|
||||
|
||||
Ok(Self {
|
||||
sampler: DeviceObject::new(device, handle),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn raw(&self) -> vk::Sampler {
|
||||
*self.sampler
|
||||
Self::construct(device, handle, None)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,152 +0,0 @@
|
|||
#![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 {}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
mod legacy;
|
||||
pub use legacy::*;
|
||||
|
||||
mod commands;
|
||||
mod recorder;
|
||||
mod resources;
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
struct CommandRecorder;
|
||||
struct RenderPassRecorder;
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
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