chore: general clean up and format
This commit is contained in:
parent
40b9f08234
commit
43bd53a92b
73
Cargo.lock
generated
73
Cargo.lock
generated
|
@ -609,6 +609,19 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glfw"
|
||||||
|
version = "0.49.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c70971598fc996224a36fe95256e90335242c00da647f7b0a0b125136613c54b"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"glfw-sys",
|
||||||
|
"objc",
|
||||||
|
"raw-window-handle 0.5.0",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glfw-sys"
|
name = "glfw-sys"
|
||||||
version = "4.0.0+3.3.5"
|
version = "4.0.0+3.3.5"
|
||||||
|
@ -767,6 +780,7 @@ dependencies = [
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"librashader-runtime-d3d11",
|
"librashader-runtime-d3d11",
|
||||||
"librashader-runtime-gl",
|
"librashader-runtime-gl",
|
||||||
|
"librashader-runtime-vk",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -864,7 +878,7 @@ version = "0.1.0-alpha.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"gl",
|
"gl",
|
||||||
"glfw",
|
"glfw 0.47.0",
|
||||||
"librashader-common",
|
"librashader-common",
|
||||||
"librashader-preprocess",
|
"librashader-preprocess",
|
||||||
"librashader-presets",
|
"librashader-presets",
|
||||||
|
@ -882,13 +896,12 @@ dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"ash-window",
|
"ash-window",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"glfw",
|
"glfw 0.49.1",
|
||||||
"librashader-common",
|
"librashader-common",
|
||||||
"librashader-preprocess",
|
"librashader-preprocess",
|
||||||
"librashader-presets",
|
"librashader-presets",
|
||||||
"librashader-reflect",
|
"librashader-reflect",
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"num",
|
|
||||||
"raw-window-handle 0.5.0",
|
"raw-window-handle 0.5.0",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"spirv_cross",
|
"spirv_cross",
|
||||||
|
@ -1115,40 +1128,6 @@ dependencies = [
|
||||||
"nom",
|
"nom",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
|
|
||||||
dependencies = [
|
|
||||||
"num-bigint",
|
|
||||||
"num-complex",
|
|
||||||
"num-integer",
|
|
||||||
"num-iter",
|
|
||||||
"num-rational",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-bigint"
|
|
||||||
version = "0.4.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-complex"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
|
@ -1159,17 +1138,6 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-iter"
|
|
||||||
version = "0.1.43"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-rational"
|
name = "num-rational"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
@ -1177,7 +1145,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-bigint",
|
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
@ -1534,9 +1501,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shaderc"
|
name = "shaderc"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "80e6fe602a861622769530a23bc40bfba31adbf186d0c8412e83f5519c5d6bee"
|
checksum = "77a410ea26a220ceaef964dd71054ccd63cc97fd54393014c09046e795127824"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"shaderc-sys",
|
"shaderc-sys",
|
||||||
|
@ -1544,9 +1511,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shaderc-sys"
|
name = "shaderc-sys"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3794498651f8173d0afbc0bb8aca45ced111098227e755dde4c0ef2888c8d0bf"
|
checksum = "a281c39df7d8a0a97e9430409abb466ff4bd046875c4d97591935042bbffc898"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cmake",
|
"cmake",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::ctypes::{
|
||||||
};
|
};
|
||||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||||
use crate::ffi::ffi_body;
|
use crate::ffi::ffi_body;
|
||||||
use librashader::runtime::d3d11::{DxImageView, Viewport};
|
use librashader::runtime::d3d11::{D3D11ImageView, Viewport};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
@ -26,14 +26,14 @@ pub struct libra_source_image_d3d11_t {
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<libra_source_image_d3d11_t> for DxImageView {
|
impl TryFrom<libra_source_image_d3d11_t> for D3D11ImageView {
|
||||||
type Error = LibrashaderError;
|
type Error = LibrashaderError;
|
||||||
|
|
||||||
fn try_from(value: libra_source_image_d3d11_t) -> Result<Self, Self::Error> {
|
fn try_from(value: libra_source_image_d3d11_t) -> Result<Self, Self::Error> {
|
||||||
let handle = value.handle;
|
let handle = value.handle;
|
||||||
assert_non_null!(noexport handle);
|
assert_non_null!(noexport handle);
|
||||||
|
|
||||||
Ok(DxImageView {
|
Ok(D3D11ImageView {
|
||||||
handle: unsafe { (&*handle).clone() },
|
handle: unsafe { (&*handle).clone() },
|
||||||
size: Size::new(value.width, value.height),
|
size: Size::new(value.width, value.height),
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
shaderc = { version = "0.8.0", features = [] }
|
shaderc = { version = "0.8.1", features = [] }
|
||||||
spirv_cross = { version = "0.23.1", features = [ "glsl", "hlsl" ] }
|
spirv_cross = { version = "0.23.1", features = [ "glsl", "hlsl" ] }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::texture::{DxImageView, LutTexture, Texture};
|
use crate::texture::{D3D11ImageView, LutTexture, Texture};
|
||||||
use librashader_common::{ImageFormat, Size};
|
use librashader_common::{ImageFormat, Size};
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||||
|
@ -365,7 +365,7 @@ impl FilterChainD3D11 {
|
||||||
Ok((framebuffers, history_textures.into_boxed_slice()))
|
Ok((framebuffers, history_textures.into_boxed_slice()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_history(&mut self, input: &DxImageView) -> error::Result<()> {
|
fn push_history(&mut self, input: &D3D11ImageView) -> error::Result<()> {
|
||||||
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
||||||
back.copy_from(input)?;
|
back.copy_from(input)?;
|
||||||
self.history_framebuffers.push_front(back)
|
self.history_framebuffers.push_front(back)
|
||||||
|
@ -465,7 +465,7 @@ impl FilterChainD3D11 {
|
||||||
/// Process a frame with the input image.
|
/// Process a frame with the input image.
|
||||||
pub fn frame(
|
pub fn frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: DxImageView,
|
input: D3D11ImageView,
|
||||||
viewport: &Viewport,
|
viewport: &Viewport,
|
||||||
frame_count: usize,
|
frame_count: usize,
|
||||||
options: Option<&FrameOptionsD3D11>,
|
options: Option<&FrameOptionsD3D11>,
|
||||||
|
@ -562,7 +562,7 @@ impl FilterChainD3D11 {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
source = Texture {
|
source = Texture {
|
||||||
view: DxImageView {
|
view: D3D11ImageView {
|
||||||
handle: target.create_shader_resource_view()?,
|
handle: target.create_shader_resource_view()?,
|
||||||
size,
|
size,
|
||||||
},
|
},
|
||||||
|
@ -615,7 +615,7 @@ impl FilterChainD3D11 {
|
||||||
|
|
||||||
impl librashader_runtime::filter_chain::FilterChain for FilterChainD3D11 {
|
impl librashader_runtime::filter_chain::FilterChain for FilterChainD3D11 {
|
||||||
type Error = FilterChainError;
|
type Error = FilterChainError;
|
||||||
type Input<'a> = DxImageView;
|
type Input<'a> = D3D11ImageView;
|
||||||
type Viewport<'a> = Viewport<'a>;
|
type Viewport<'a> = Viewport<'a>;
|
||||||
type FrameOptions = FrameOptionsD3D11;
|
type FrameOptions = FrameOptionsD3D11;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::texture::{DxImageView, Texture};
|
use crate::texture::{D3D11ImageView, Texture};
|
||||||
use crate::util::d3d11_get_closest_format;
|
use crate::util::d3d11_get_closest_format;
|
||||||
use librashader_common::{ImageFormat, Size};
|
use librashader_common::{ImageFormat, Size};
|
||||||
use librashader_presets::Scale2D;
|
use librashader_presets::Scale2D;
|
||||||
|
@ -152,7 +152,7 @@ impl OwnedFramebuffer {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_from(&mut self, image: &DxImageView) -> error::Result<()> {
|
pub fn copy_from(&mut self, image: &D3D11ImageView) -> error::Result<()> {
|
||||||
let original_resource: ID3D11Texture2D = unsafe {
|
let original_resource: ID3D11Texture2D = unsafe {
|
||||||
let mut resource = None;
|
let mut resource = None;
|
||||||
image.handle.GetResource(&mut resource);
|
image.handle.GetResource(&mut resource);
|
||||||
|
|
|
@ -228,7 +228,7 @@ pub mod d3d11_hello_triangle {
|
||||||
use crate::filter_chain::FilterChainD3D11;
|
use crate::filter_chain::FilterChainD3D11;
|
||||||
|
|
||||||
use crate::options::FilterChainOptionsD3D11;
|
use crate::options::FilterChainOptionsD3D11;
|
||||||
use crate::texture::DxImageView;
|
use crate::texture::D3D11ImageView;
|
||||||
use crate::viewport::Viewport;
|
use crate::viewport::Viewport;
|
||||||
use librashader_common::Size;
|
use librashader_common::Size;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
@ -492,7 +492,7 @@ pub mod d3d11_hello_triangle {
|
||||||
|
|
||||||
self.filter
|
self.filter
|
||||||
.frame(
|
.frame(
|
||||||
DxImageView {
|
D3D11ImageView {
|
||||||
handle: srv,
|
handle: srv,
|
||||||
size: Size {
|
size: Size {
|
||||||
width: tex2d_desc.Width,
|
width: tex2d_desc.Width,
|
||||||
|
|
|
@ -18,7 +18,7 @@ mod util;
|
||||||
mod viewport;
|
mod viewport;
|
||||||
|
|
||||||
pub use filter_chain::FilterChainD3D11;
|
pub use filter_chain::FilterChainD3D11;
|
||||||
pub use texture::DxImageView;
|
pub use texture::D3D11ImageView;
|
||||||
pub use viewport::Viewport;
|
pub use viewport::Viewport;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -14,13 +14,13 @@ use crate::error::Result;
|
||||||
use crate::framebuffer::OwnedFramebuffer;
|
use crate::framebuffer::OwnedFramebuffer;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DxImageView {
|
pub struct D3D11ImageView {
|
||||||
pub handle: ID3D11ShaderResourceView,
|
pub handle: ID3D11ShaderResourceView,
|
||||||
pub size: Size<u32>,
|
pub size: Size<u32>,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct Texture {
|
pub(crate) struct Texture {
|
||||||
pub view: DxImageView,
|
pub view: D3D11ImageView,
|
||||||
pub filter: FilterMode,
|
pub filter: FilterMode,
|
||||||
pub wrap_mode: WrapMode,
|
pub wrap_mode: WrapMode,
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ impl Texture {
|
||||||
filter: FilterMode,
|
filter: FilterMode,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Texture {
|
Ok(Texture {
|
||||||
view: DxImageView {
|
view: D3D11ImageView {
|
||||||
handle: fbo.create_shader_resource_view()?,
|
handle: fbo.create_shader_resource_view()?,
|
||||||
size: fbo.size,
|
size: fbo.size,
|
||||||
},
|
},
|
||||||
|
@ -167,7 +167,7 @@ impl LutTexture {
|
||||||
// staging,
|
// staging,
|
||||||
desc,
|
desc,
|
||||||
image: Texture {
|
image: Texture {
|
||||||
view: DxImageView {
|
view: D3D11ImageView {
|
||||||
handle: srv,
|
handle: srv,
|
||||||
size: source.size,
|
size: source.size,
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,10 +25,9 @@ bytemuck = "1.12.3"
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
ash = { version = "0.37.1+1.3.235", features = ["linked", "debug"] }
|
ash = { version = "0.37.1+1.3.235", features = ["linked", "debug"] }
|
||||||
|
|
||||||
num = "0.4.0"
|
[dev-dependencies]
|
||||||
glfw = "0.47.0"
|
glfw = "0.49.0"
|
||||||
winit = "0.27.5"
|
winit = "0.27.5"
|
||||||
raw-window-handle = "0.5"
|
raw-window-handle = "0.5"
|
||||||
ash-window = "0.12.0"
|
ash-window = "0.12.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
|
|
|
@ -11,11 +11,6 @@ pub(crate) static VBO_DEFAULT_FINAL: &[f32; 16] = &[
|
||||||
1.0, 1.0, 1.0, 1.0,
|
1.0, 1.0, 1.0, 1.0,
|
||||||
];
|
];
|
||||||
|
|
||||||
pub enum VboType {
|
|
||||||
Offscreen,
|
|
||||||
Final,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct DrawQuad {
|
pub struct DrawQuad {
|
||||||
buffer: VulkanBuffer,
|
buffer: VulkanBuffer,
|
||||||
device: ash::Device,
|
device: ash::Device,
|
||||||
|
@ -45,7 +40,7 @@ impl DrawQuad {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_vbo(&self, cmd: vk::CommandBuffer, vbo: VboType) {
|
pub fn bind_vbo(&self, cmd: vk::CommandBuffer) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.device
|
self.device
|
||||||
.cmd_bind_vertex_buffers(cmd, 0, &[self.buffer.handle], &[0])
|
.cmd_bind_vertex_buffers(cmd, 0, &[self.buffer.handle], &[0])
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::draw_quad::DrawQuad;
|
use crate::draw_quad::DrawQuad;
|
||||||
|
use crate::error::FilterChainError;
|
||||||
use crate::filter_pass::FilterPass;
|
use crate::filter_pass::FilterPass;
|
||||||
use crate::framebuffer::OutputImage;
|
use crate::framebuffer::OutputImage;
|
||||||
use crate::luts::LutTexture;
|
use crate::luts::LutTexture;
|
||||||
|
use crate::queue_selection::get_graphics_queue;
|
||||||
use crate::render_target::{RenderTarget, DEFAULT_MVP};
|
use crate::render_target::{RenderTarget, DEFAULT_MVP};
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::{InputImage, OwnedImage, VulkanImage};
|
use crate::texture::{InputImage, OwnedImage, VulkanImage};
|
||||||
|
@ -26,17 +28,12 @@ use librashader_runtime::uniforms::UniformStorage;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use crate::error::FilterChainError;
|
|
||||||
use crate::queue_selection::get_graphics_queue;
|
|
||||||
|
|
||||||
pub struct Vulkan {
|
pub struct Vulkan {
|
||||||
// physical_device: vk::PhysicalDevice,
|
|
||||||
pub(crate) device: ash::Device,
|
pub(crate) device: ash::Device,
|
||||||
// instance: ash::Instance,
|
pub(crate) memory_properties: vk::PhysicalDeviceMemoryProperties,
|
||||||
queue: vk::Queue,
|
queue: vk::Queue,
|
||||||
pipeline_cache: vk::PipelineCache,
|
pipeline_cache: vk::PipelineCache,
|
||||||
pub(crate) memory_properties: vk::PhysicalDeviceMemoryProperties,
|
|
||||||
// debug: DebugUtils,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShaderPassMeta = (
|
type ShaderPassMeta = (
|
||||||
|
@ -67,11 +64,10 @@ impl TryFrom<VulkanInfo> for Vulkan {
|
||||||
|
|
||||||
let device = ash::Device::load(instance.fp_v1_0(), vulkan.device);
|
let device = ash::Device::load(instance.fp_v1_0(), vulkan.device);
|
||||||
|
|
||||||
let pipeline_cache = unsafe {
|
let pipeline_cache =
|
||||||
device.create_pipeline_cache(&vk::PipelineCacheCreateInfo::default(), None)?
|
device.create_pipeline_cache(&vk::PipelineCacheCreateInfo::default(), None)?;
|
||||||
};
|
|
||||||
|
|
||||||
let debug = DebugUtils::new(
|
let _debug = DebugUtils::new(
|
||||||
&ash::Entry::from_static_fn(vk::StaticFn {
|
&ash::Entry::from_static_fn(vk::StaticFn {
|
||||||
get_instance_proc_addr: vulkan.get_instance_proc_addr,
|
get_instance_proc_addr: vulkan.get_instance_proc_addr,
|
||||||
}),
|
}),
|
||||||
|
@ -79,11 +75,11 @@ impl TryFrom<VulkanInfo> for Vulkan {
|
||||||
);
|
);
|
||||||
|
|
||||||
let queue = get_graphics_queue(&instance, &device, vulkan.physical_device);
|
let queue = get_graphics_queue(&instance, &device, vulkan.physical_device);
|
||||||
let memory_properties = instance.get_physical_device_memory_properties(vulkan.physical_device);
|
let memory_properties =
|
||||||
|
instance.get_physical_device_memory_properties(vulkan.physical_device);
|
||||||
|
|
||||||
Ok(Vulkan {
|
Ok(Vulkan {
|
||||||
device,
|
device,
|
||||||
// instance,
|
|
||||||
queue,
|
queue,
|
||||||
pipeline_cache,
|
pipeline_cache,
|
||||||
memory_properties,
|
memory_properties,
|
||||||
|
@ -93,22 +89,10 @@ impl TryFrom<VulkanInfo> for Vulkan {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl
|
impl TryFrom<(vk::PhysicalDevice, ash::Instance, ash::Device)> for Vulkan {
|
||||||
TryFrom<(
|
|
||||||
vk::PhysicalDevice,
|
|
||||||
ash::Instance,
|
|
||||||
ash::Device,
|
|
||||||
)> for Vulkan
|
|
||||||
{
|
|
||||||
type Error = FilterChainError;
|
type Error = FilterChainError;
|
||||||
|
|
||||||
fn try_from(
|
fn try_from(value: (vk::PhysicalDevice, ash::Instance, ash::Device)) -> error::Result<Self> {
|
||||||
value: (
|
|
||||||
vk::PhysicalDevice,
|
|
||||||
ash::Instance,
|
|
||||||
ash::Device,
|
|
||||||
),
|
|
||||||
) -> error::Result<Self> {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let device = value.2;
|
let device = value.2;
|
||||||
|
|
||||||
|
@ -174,14 +158,9 @@ impl FilterChainFrameIntermediates {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn dispose_outputs(&mut self, output_framebuffer: OutputImage) {
|
pub(crate) fn dispose_outputs(&mut self, output_framebuffer: OutputImage) {
|
||||||
// self.framebuffers.push(output_framebuffer.framebuffer);
|
|
||||||
self.image_views.push(output_framebuffer.image_view);
|
self.image_views.push(output_framebuffer.image_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn dispose_image_views(&mut self, image_view: vk::ImageView) {
|
|
||||||
self.image_views.push(image_view)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn dispose_owned(&mut self, owned: OwnedImage) {
|
pub(crate) fn dispose_owned(&mut self, owned: OwnedImage) {
|
||||||
self.owned.push(owned)
|
self.owned.push(owned)
|
||||||
}
|
}
|
||||||
|
@ -216,7 +195,7 @@ impl FilterChainVulkan {
|
||||||
pub fn load_from_preset(
|
pub fn load_from_preset(
|
||||||
vulkan: impl TryInto<Vulkan, Error = FilterChainError>,
|
vulkan: impl TryInto<Vulkan, Error = FilterChainError>,
|
||||||
preset: ShaderPreset,
|
preset: ShaderPreset,
|
||||||
options: Option<&FilterChainOptionsVulkan>,
|
_options: Option<&FilterChainOptionsVulkan>,
|
||||||
) -> error::Result<FilterChainVulkan> {
|
) -> error::Result<FilterChainVulkan> {
|
||||||
let (passes, semantics) = FilterChainVulkan::load_preset(preset.shaders, &preset.textures)?;
|
let (passes, semantics) = FilterChainVulkan::load_preset(preset.shaders, &preset.textures)?;
|
||||||
let device = vulkan.try_into()?;
|
let device = vulkan.try_into()?;
|
||||||
|
@ -339,7 +318,7 @@ impl FilterChainVulkan {
|
||||||
let frames_in_flight = std::cmp::max(1, frames_in_flight);
|
let frames_in_flight = std::cmp::max(1, frames_in_flight);
|
||||||
|
|
||||||
// initialize passes
|
// initialize passes
|
||||||
for (index, (config, mut source, mut reflect)) in passes.into_iter().enumerate() {
|
for (index, (config, source, mut reflect)) in passes.into_iter().enumerate() {
|
||||||
let reflection = reflect.reflect(index, semantics)?;
|
let reflection = reflect.reflect(index, semantics)?;
|
||||||
let spirv_words = reflect.compile(None)?;
|
let spirv_words = reflect.compile(None)?;
|
||||||
|
|
||||||
|
@ -389,14 +368,14 @@ impl FilterChainVulkan {
|
||||||
filters.push(FilterPass {
|
filters.push(FilterPass {
|
||||||
device: vulkan.device.clone(),
|
device: vulkan.device.clone(),
|
||||||
reflection,
|
reflection,
|
||||||
compiled: spirv_words,
|
// compiled: spirv_words,
|
||||||
uniform_storage,
|
uniform_storage,
|
||||||
uniform_bindings,
|
uniform_bindings,
|
||||||
source,
|
source,
|
||||||
config,
|
config,
|
||||||
graphics_pipeline,
|
graphics_pipeline,
|
||||||
ubo_ring,
|
ubo_ring,
|
||||||
frames_in_flight
|
frames_in_flight,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,12 +435,9 @@ impl FilterChainVulkan {
|
||||||
.queue_submit(vulkan.queue, &submits, vk::Fence::null())?;
|
.queue_submit(vulkan.queue, &submits, vk::Fence::null())?;
|
||||||
vulkan.device.queue_wait_idle(vulkan.queue)?;
|
vulkan.device.queue_wait_idle(vulkan.queue)?;
|
||||||
|
|
||||||
vulkan
|
vulkan.device.free_command_buffers(command_pool, &buffers);
|
||||||
.device
|
|
||||||
.free_command_buffers(command_pool, &buffers);
|
|
||||||
|
|
||||||
vulkan.device
|
vulkan.device.destroy_command_pool(command_pool, None);
|
||||||
.destroy_command_pool(command_pool, None);
|
|
||||||
}
|
}
|
||||||
Ok(luts)
|
Ok(luts)
|
||||||
}
|
}
|
||||||
|
@ -589,7 +565,7 @@ impl FilterChainVulkan {
|
||||||
viewport: &Viewport,
|
viewport: &Viewport,
|
||||||
input: &VulkanImage,
|
input: &VulkanImage,
|
||||||
cmd: vk::CommandBuffer,
|
cmd: vk::CommandBuffer,
|
||||||
options: Option<()>,
|
_options: Option<()>,
|
||||||
) -> error::Result<FilterChainFrameIntermediates> {
|
) -> error::Result<FilterChainFrameIntermediates> {
|
||||||
// limit number of passes to those enabled.
|
// limit number of passes to those enabled.
|
||||||
let passes = &mut self.passes[0..self.common.config.passes_enabled];
|
let passes = &mut self.passes[0..self.common.config.passes_enabled];
|
||||||
|
@ -698,10 +674,7 @@ impl FilterChainVulkan {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
y: 0.0,
|
y: 0.0,
|
||||||
mvp: DEFAULT_MVP,
|
mvp: DEFAULT_MVP,
|
||||||
output: OutputImage::new(
|
output: OutputImage::new(&self.vulkan, target.image.clone())?,
|
||||||
&self.vulkan,
|
|
||||||
target.image.clone(),
|
|
||||||
)?,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pass.draw(
|
pass.draw(
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
use crate::draw_quad::VboType;
|
use crate::error;
|
||||||
use crate::filter_chain::FilterCommon;
|
use crate::filter_chain::FilterCommon;
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::samplers::{SamplerSet, VulkanSampler};
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::InputImage;
|
use crate::texture::InputImage;
|
||||||
use crate::ubo_ring::VkUboRing;
|
use crate::ubo_ring::VkUboRing;
|
||||||
use crate::viewport::Viewport;
|
use crate::viewport::Viewport;
|
||||||
use crate::vulkan_state::VulkanGraphicsPipeline;
|
use crate::vulkan_state::VulkanGraphicsPipeline;
|
||||||
use crate::{error, util};
|
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use librashader_common::{ImageFormat, Size};
|
use librashader_common::{ImageFormat, Size};
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
use librashader_presets::ShaderPassConfig;
|
||||||
use librashader_reflect::back::ShaderCompilerOutput;
|
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{
|
||||||
BindingStage, MemberOffset, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics,
|
BindingStage, MemberOffset, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics,
|
||||||
};
|
};
|
||||||
|
@ -22,7 +20,7 @@ use rustc_hash::FxHashMap;
|
||||||
pub struct FilterPass {
|
pub struct FilterPass {
|
||||||
pub device: ash::Device,
|
pub device: ash::Device,
|
||||||
pub reflection: ShaderReflection,
|
pub reflection: ShaderReflection,
|
||||||
pub(crate) compiled: ShaderCompilerOutput<Vec<u32>>,
|
// pub(crate) compiled: ShaderCompilerOutput<Vec<u32>>,
|
||||||
pub(crate) uniform_storage: UniformStorage,
|
pub(crate) uniform_storage: UniformStorage,
|
||||||
pub uniform_bindings: FxHashMap<UniformBinding, MemberOffset>,
|
pub uniform_bindings: FxHashMap<UniformBinding, MemberOffset>,
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
|
@ -83,7 +81,8 @@ impl FilterPass {
|
||||||
source: &InputImage,
|
source: &InputImage,
|
||||||
output: &RenderTarget,
|
output: &RenderTarget,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
let descriptor = *&self.graphics_pipeline.layout.descriptor_sets[(frame_count % self.frames_in_flight) as usize];
|
let descriptor = *&self.graphics_pipeline.layout.descriptor_sets
|
||||||
|
[(frame_count % self.frames_in_flight) as usize];
|
||||||
|
|
||||||
self.build_semantics(
|
self.build_semantics(
|
||||||
pass_index,
|
pass_index,
|
||||||
|
@ -158,7 +157,7 @@ impl FilterPass {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.draw_quad.bind_vbo(cmd, VboType::Final);
|
parent.draw_quad.bind_vbo(cmd);
|
||||||
|
|
||||||
parent.device.cmd_set_scissor(
|
parent.device.cmd_set_scissor(
|
||||||
cmd,
|
cmd,
|
||||||
|
@ -183,7 +182,7 @@ impl FilterPass {
|
||||||
|
|
||||||
fn build_semantics(
|
fn build_semantics(
|
||||||
&mut self,
|
&mut self,
|
||||||
pass_index: usize,
|
_pass_index: usize,
|
||||||
parent: &FilterCommon,
|
parent: &FilterCommon,
|
||||||
mvp: &[f32; 16],
|
mvp: &[f32; 16],
|
||||||
frame_count: u32,
|
frame_count: u32,
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl OutputImage {
|
||||||
.a(vk::ComponentSwizzle::A)
|
.a(vk::ComponentSwizzle::A)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let mut view_info = vk::ImageViewCreateInfo::builder()
|
let view_info = vk::ImageViewCreateInfo::builder()
|
||||||
.view_type(vk::ImageViewType::TYPE_2D)
|
.view_type(vk::ImageViewType::TYPE_2D)
|
||||||
.format(image.format)
|
.format(image.format)
|
||||||
.image(image.image.clone())
|
.image(image.image.clone())
|
||||||
|
|
|
@ -137,7 +137,6 @@ impl VulkanWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_frame(frame: usize, vulkan: &VulkanDraw, filter: &mut FilterChainVulkan) {
|
fn draw_frame(frame: usize, vulkan: &VulkanDraw, filter: &mut FilterChainVulkan) {
|
||||||
|
|
||||||
let index = frame % MAX_FRAMES_IN_FLIGHT;
|
let index = frame % MAX_FRAMES_IN_FLIGHT;
|
||||||
let in_flight = [vulkan.sync.in_flight[index]];
|
let in_flight = [vulkan.sync.in_flight[index]];
|
||||||
let image_available = [vulkan.sync.image_available[index]];
|
let image_available = [vulkan.sync.image_available[index]];
|
||||||
|
@ -149,11 +148,7 @@ impl VulkanWindow {
|
||||||
.device
|
.device
|
||||||
.wait_for_fences(&in_flight, true, u64::MAX)
|
.wait_for_fences(&in_flight, true, u64::MAX)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
vulkan
|
vulkan.base.device.reset_fences(&in_flight).unwrap();
|
||||||
.base
|
|
||||||
.device
|
|
||||||
.reset_fences(&in_flight)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let (swapchain_index, _) = vulkan
|
let (swapchain_index, _) = vulkan
|
||||||
.swapchain
|
.swapchain
|
||||||
|
@ -326,11 +321,7 @@ impl VulkanWindow {
|
||||||
vulkan
|
vulkan
|
||||||
.base
|
.base
|
||||||
.device
|
.device
|
||||||
.queue_submit(
|
.queue_submit(vulkan.base.graphics_queue, &submit_info, in_flight[0])
|
||||||
vulkan.base.graphics_queue,
|
|
||||||
&submit_info,
|
|
||||||
in_flight[0],
|
|
||||||
)
|
|
||||||
.expect("failed to submit queue");
|
.expect("failed to submit queue");
|
||||||
|
|
||||||
let swapchain_index = [swapchain_index];
|
let swapchain_index = [swapchain_index];
|
||||||
|
@ -347,7 +338,6 @@ impl VulkanWindow {
|
||||||
.queue_present(vulkan.base.graphics_queue, &present_info)
|
.queue_present(vulkan.base.graphics_queue, &present_info)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
||||||
vulkan.base.device.device_wait_idle().unwrap();
|
vulkan.base.device.device_wait_idle().unwrap();
|
||||||
drop(intermediates)
|
drop(intermediates)
|
||||||
}
|
}
|
||||||
|
@ -407,7 +397,8 @@ pub fn main(vulkan: VulkanBase, filter_chain: FilterChainVulkan) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let swapchain_command_pool = VulkanCommandPool::new(&vulkan, MAX_FRAMES_IN_FLIGHT as u32).unwrap();
|
let swapchain_command_pool =
|
||||||
|
VulkanCommandPool::new(&vulkan, MAX_FRAMES_IN_FLIGHT as u32).unwrap();
|
||||||
let render_command_pool = VulkanCommandPool::new(&vulkan, MAX_FRAMES_IN_FLIGHT as u32).unwrap();
|
let render_command_pool = VulkanCommandPool::new(&vulkan, MAX_FRAMES_IN_FLIGHT as u32).unwrap();
|
||||||
|
|
||||||
let sync = SyncObjects::new(&vulkan.device, MAX_FRAMES_IN_FLIGHT).unwrap();
|
let sync = SyncObjects::new(&vulkan.device, MAX_FRAMES_IN_FLIGHT).unwrap();
|
||||||
|
|
|
@ -15,14 +15,18 @@ impl SyncObjects {
|
||||||
let mut in_flight = Vec::new();
|
let mut in_flight = Vec::new();
|
||||||
|
|
||||||
for _ in 0..frames_in_flight {
|
for _ in 0..frames_in_flight {
|
||||||
image_available.push(device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?);
|
image_available
|
||||||
render_finished.push(device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?);
|
.push(device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?);
|
||||||
in_flight.push(device.create_fence(
|
render_finished
|
||||||
|
.push(device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?);
|
||||||
|
in_flight.push(
|
||||||
|
device.create_fence(
|
||||||
&vk::FenceCreateInfo::builder()
|
&vk::FenceCreateInfo::builder()
|
||||||
.flags(vk::FenceCreateFlags::SIGNALED)
|
.flags(vk::FenceCreateFlags::SIGNALED)
|
||||||
.build(),
|
.build(),
|
||||||
None,
|
None,
|
||||||
)?)
|
)?,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(SyncObjects {
|
Ok(SyncObjects {
|
||||||
|
|
|
@ -2,13 +2,13 @@ use ash::vk;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
|
use crate::error::FilterChainError;
|
||||||
use crate::filter_chain::Vulkan;
|
use crate::filter_chain::Vulkan;
|
||||||
use crate::hello_triangle::debug::VulkanDebug;
|
use crate::hello_triangle::debug::VulkanDebug;
|
||||||
use crate::hello_triangle::physicaldevice::{find_queue_family, pick_physical_device};
|
use crate::hello_triangle::physicaldevice::{find_queue_family, pick_physical_device};
|
||||||
use crate::hello_triangle::surface::VulkanSurface;
|
use crate::hello_triangle::surface::VulkanSurface;
|
||||||
use ash::prelude::VkResult;
|
use ash::prelude::VkResult;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use crate::error::FilterChainError;
|
|
||||||
|
|
||||||
const WINDOW_TITLE: &'static [u8] = b"librashader Vulkan\0";
|
const WINDOW_TITLE: &'static [u8] = b"librashader Vulkan\0";
|
||||||
const KHRONOS_VALIDATION: &'static [u8] = b"VK_LAYER_KHRONOS_validation\0";
|
const KHRONOS_VALIDATION: &'static [u8] = b"VK_LAYER_KHRONOS_validation\0";
|
||||||
|
@ -41,9 +41,7 @@ impl VulkanBase {
|
||||||
ash::extensions::ext::DebugUtils::name().as_ptr(),
|
ash::extensions::ext::DebugUtils::name().as_ptr(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let layers = unsafe {
|
let layers = unsafe { [KHRONOS_VALIDATION.as_ptr().cast()] };
|
||||||
[KHRONOS_VALIDATION.as_ptr().cast()]
|
|
||||||
};
|
|
||||||
|
|
||||||
let create_info = vk::InstanceCreateInfo::builder()
|
let create_info = vk::InstanceCreateInfo::builder()
|
||||||
.application_info(&app_info)
|
.application_info(&app_info)
|
||||||
|
@ -79,9 +77,7 @@ impl VulkanBase {
|
||||||
instance: &ash::Instance,
|
instance: &ash::Instance,
|
||||||
physical_device: &vk::PhysicalDevice,
|
physical_device: &vk::PhysicalDevice,
|
||||||
) -> VkResult<(ash::Device, vk::Queue)> {
|
) -> VkResult<(ash::Device, vk::Queue)> {
|
||||||
let debug = [unsafe {
|
let debug = [unsafe { CStr::from_bytes_with_nul_unchecked(KHRONOS_VALIDATION).as_ptr() }];
|
||||||
CStr::from_bytes_with_nul_unchecked(KHRONOS_VALIDATION).as_ptr()
|
|
||||||
}];
|
|
||||||
|
|
||||||
let indices = find_queue_family(&instance, *physical_device);
|
let indices = find_queue_family(&instance, *physical_device);
|
||||||
let queue_info = [vk::DeviceQueueCreateInfo::builder()
|
let queue_info = [vk::DeviceQueueCreateInfo::builder()
|
||||||
|
|
|
@ -9,6 +9,8 @@ mod framebuffer;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod hello_triangle;
|
mod hello_triangle;
|
||||||
mod luts;
|
mod luts;
|
||||||
|
mod parameters;
|
||||||
|
mod queue_selection;
|
||||||
mod render_target;
|
mod render_target;
|
||||||
mod samplers;
|
mod samplers;
|
||||||
mod texture;
|
mod texture;
|
||||||
|
@ -17,10 +19,12 @@ mod util;
|
||||||
mod viewport;
|
mod viewport;
|
||||||
mod vulkan_primitives;
|
mod vulkan_primitives;
|
||||||
mod vulkan_state;
|
mod vulkan_state;
|
||||||
mod queue_selection;
|
|
||||||
|
|
||||||
pub use filter_chain::FilterChainFrameIntermediates;
|
pub use filter_chain::FilterChainFrameIntermediates;
|
||||||
pub use filter_chain::FilterChainVulkan;
|
pub use filter_chain::FilterChainVulkan;
|
||||||
|
pub use filter_chain::Vulkan;
|
||||||
|
pub use filter_chain::VulkanInfo;
|
||||||
|
pub use texture::VulkanImage;
|
||||||
pub use viewport::Viewport;
|
pub use viewport::Viewport;
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
@ -29,7 +33,7 @@ pub mod options;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::filter_chain::{FilterChainVulkan, Vulkan};
|
use crate::filter_chain::FilterChainVulkan;
|
||||||
use crate::hello_triangle::vulkan_base::VulkanBase;
|
use crate::hello_triangle::vulkan_base::VulkanBase;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl LutTexture {
|
||||||
.a(vk::ComponentSwizzle::A)
|
.a(vk::ComponentSwizzle::A)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let mut view_info = vk::ImageViewCreateInfo::builder()
|
let view_info = vk::ImageViewCreateInfo::builder()
|
||||||
.view_type(vk::ImageViewType::TYPE_2D)
|
.view_type(vk::ImageViewType::TYPE_2D)
|
||||||
.format(vk::Format::B8G8R8A8_UNORM)
|
.format(vk::Format::B8G8R8A8_UNORM)
|
||||||
.image(texture.clone())
|
.image(texture.clone())
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
40
librashader-runtime-vk/src/parameters.rs
Normal file
40
librashader-runtime-vk/src/parameters.rs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
use crate::FilterChainVulkan;
|
||||||
|
use librashader_runtime::parameters::FilterChainParameters;
|
||||||
|
use std::collections::hash_map::Iter;
|
||||||
|
|
||||||
|
impl FilterChainParameters for FilterChainVulkan {
|
||||||
|
fn get_enabled_pass_count(&self) -> usize {
|
||||||
|
self.common.config.passes_enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_enabled_pass_count(&mut self, count: usize) {
|
||||||
|
self.common.config.passes_enabled = count
|
||||||
|
}
|
||||||
|
|
||||||
|
fn enumerate_parameters(&self) -> Iter<String, f32> {
|
||||||
|
self.common.config.parameters.iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_parameter(&self, parameter: &str) -> Option<f32> {
|
||||||
|
self.common
|
||||||
|
.config
|
||||||
|
.parameters
|
||||||
|
.get::<str>(parameter.as_ref())
|
||||||
|
.copied()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {
|
||||||
|
if let Some(value) = self
|
||||||
|
.common
|
||||||
|
.config
|
||||||
|
.parameters
|
||||||
|
.get_mut::<str>(parameter.as_ref())
|
||||||
|
{
|
||||||
|
let old = *value;
|
||||||
|
*value = new_value;
|
||||||
|
Some(old)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,14 +11,18 @@ fn find_graphics_queue_family(
|
||||||
if queue_family.queue_count > 0
|
if queue_family.queue_count > 0
|
||||||
&& queue_family.queue_flags.contains(vk::QueueFlags::GRAPHICS)
|
&& queue_family.queue_flags.contains(vk::QueueFlags::GRAPHICS)
|
||||||
{
|
{
|
||||||
return index as u32
|
return index as u32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_graphics_queue(instance: &ash::Instance, device: &ash::Device, physical_device: vk::PhysicalDevice) -> vk::Queue {
|
pub fn get_graphics_queue(
|
||||||
|
instance: &ash::Instance,
|
||||||
|
device: &ash::Device,
|
||||||
|
physical_device: vk::PhysicalDevice,
|
||||||
|
) -> vk::Queue {
|
||||||
let queue_family = find_graphics_queue_family(instance, physical_device);
|
let queue_family = find_graphics_queue_family(instance, physical_device);
|
||||||
unsafe { device.get_device_queue(queue_family, 0) }
|
unsafe { device.get_device_queue(queue_family, 0) }
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::framebuffer::OutputImage;
|
use crate::framebuffer::OutputImage;
|
||||||
use ash::vk;
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub(crate) static DEFAULT_MVP: &[f32; 16] = &[
|
pub(crate) static DEFAULT_MVP: &[f32; 16] = &[
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl OwnedImage {
|
||||||
.a(vk::ComponentSwizzle::A)
|
.a(vk::ComponentSwizzle::A)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let mut view_info = vk::ImageViewCreateInfo::builder()
|
let view_info = vk::ImageViewCreateInfo::builder()
|
||||||
.view_type(vk::ImageViewType::TYPE_2D)
|
.view_type(vk::ImageViewType::TYPE_2D)
|
||||||
.format(format.into())
|
.format(format.into())
|
||||||
.image(image.clone())
|
.image(image.clone())
|
||||||
|
@ -145,7 +145,7 @@ impl OwnedImage {
|
||||||
{
|
{
|
||||||
let max_levels = if mipmap { u32::MAX } else { 1 };
|
let max_levels = if mipmap { u32::MAX } else { 1 };
|
||||||
|
|
||||||
let mut new = OwnedImage::new_internal(
|
let new = OwnedImage::new_internal(
|
||||||
self.device.clone(),
|
self.device.clone(),
|
||||||
self.mem_props,
|
self.mem_props,
|
||||||
size,
|
size,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::vulkan_primitives::VulkanBuffer;
|
use crate::vulkan_primitives::VulkanBuffer;
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use librashader_runtime::ringbuffer::{BoxRingBuffer, InlineRingBuffer, RingBuffer};
|
use librashader_runtime::ringbuffer::{BoxRingBuffer, RingBuffer};
|
||||||
use librashader_runtime::uniforms::UniformStorageAccess;
|
use librashader_runtime::uniforms::UniformStorageAccess;
|
||||||
|
|
||||||
pub struct VkUboRing {
|
pub struct VkUboRing {
|
||||||
|
@ -40,7 +40,7 @@ impl VkUboRing {
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
// todo: write directly to allocated buffer.
|
// todo: write directly to allocated buffer.
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut buffer = self.ring.current_mut();
|
let buffer = self.ring.current_mut();
|
||||||
let mut map = buffer.map()?;
|
let mut map = buffer.map()?;
|
||||||
map.copy_from(0, storage.ubo_slice())
|
map.copy_from(0, storage.ubo_slice())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::error;
|
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use ash::vk::{AccessFlags, Extent3D, ImageAspectFlags};
|
|
||||||
use librashader_common::Size;
|
|
||||||
use librashader_reflect::reflect::semantics::BindingStage;
|
use librashader_reflect::reflect::semantics::BindingStage;
|
||||||
|
|
||||||
pub fn binding_stage_to_vulkan_stage(stage_mask: BindingStage) -> vk::ShaderStageFlags {
|
pub fn binding_stage_to_vulkan_stage(stage_mask: BindingStage) -> vk::ShaderStageFlags {
|
||||||
|
|
|
@ -86,15 +86,6 @@ impl VulkanBuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn copy_from(&mut self, buffer: &[u8]) -> error::Result<()> {
|
|
||||||
let dst = self
|
|
||||||
.device
|
|
||||||
.map_memory(self.memory, 0, self.size, vk::MemoryMapFlags::empty())?;
|
|
||||||
std::ptr::copy_nonoverlapping(buffer.as_ptr(), dst.cast(), buffer.len());
|
|
||||||
self.device.unmap_memory(self.memory);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map(&mut self) -> error::Result<VulkanBufferMapHandle> {
|
pub fn map(&mut self) -> error::Result<VulkanBufferMapHandle> {
|
||||||
let dst = unsafe {
|
let dst = unsafe {
|
||||||
self.device
|
self.device
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{error, util};
|
use crate::{error, util};
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use librashader_common::ImageFormat;
|
|
||||||
use librashader_reflect::back::ShaderCompilerOutput;
|
use librashader_reflect::back::ShaderCompilerOutput;
|
||||||
use librashader_reflect::reflect::semantics::{TextureBinding, UboReflection};
|
use librashader_reflect::reflect::semantics::{TextureBinding, UboReflection};
|
||||||
use librashader_reflect::reflect::ShaderReflection;
|
use librashader_reflect::reflect::ShaderReflection;
|
||||||
|
@ -101,7 +101,7 @@ impl PipelineLayoutObjects {
|
||||||
descriptors.add_ubo_binding(reflection.ubo.as_ref());
|
descriptors.add_ubo_binding(reflection.ubo.as_ref());
|
||||||
descriptors.add_texture_bindings(reflection.meta.texture_meta.values());
|
descriptors.add_texture_bindings(reflection.meta.texture_meta.values());
|
||||||
|
|
||||||
let mut descriptor_set_layout = [descriptors.create_descriptor_set_layout(device)?];
|
let descriptor_set_layout = [descriptors.create_descriptor_set_layout(device)?];
|
||||||
|
|
||||||
let pipeline_create_info =
|
let pipeline_create_info =
|
||||||
vk::PipelineLayoutCreateInfo::builder().set_layouts(&descriptor_set_layout);
|
vk::PipelineLayoutCreateInfo::builder().set_layouts(&descriptor_set_layout);
|
||||||
|
@ -126,12 +126,7 @@ impl PipelineLayoutObjects {
|
||||||
.pool_sizes(&descriptors.pool_sizes)
|
.pool_sizes(&descriptors.pool_sizes)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let pool = unsafe {
|
let pool = unsafe { device.create_descriptor_pool(&pool_info, None)? };
|
||||||
device.create_descriptor_pool(
|
|
||||||
&pool_info,
|
|
||||||
None,
|
|
||||||
)?
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut descriptor_sets = Vec::new();
|
let mut descriptor_sets = Vec::new();
|
||||||
let alloc_info = vk::DescriptorSetAllocateInfo::builder()
|
let alloc_info = vk::DescriptorSetAllocateInfo::builder()
|
||||||
|
|
|
@ -16,16 +16,18 @@ description = "RetroArch shaders for all."
|
||||||
librashader-common = { path = "../librashader-common", version = "0.1.0-alpha.4" }
|
librashader-common = { path = "../librashader-common", version = "0.1.0-alpha.4" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.1.0-alpha.4" }
|
librashader-presets = { path = "../librashader-presets", version = "0.1.0-alpha.4" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.0-alpha.4" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.0-alpha.4" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.4" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.4", features = ["standalone"] }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.1.0-alpha.4" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.1.0-alpha.4" }
|
||||||
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.1.0-alpha.4" }
|
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.1.0-alpha.4" }
|
||||||
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.1.0-alpha.4" }
|
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.1.0-alpha.4" }
|
||||||
|
librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.1.0-alpha.4" }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["gl", "d3d11", "reflect", "preprocess", "presets" ]
|
default = ["gl", "d3d11", "vk", "reflect", "preprocess", "presets" ]
|
||||||
gl = [ "runtime", "librashader-common/opengl" ]
|
gl = [ "runtime", "librashader-common/opengl" ]
|
||||||
d3d11 = [ "runtime", "librashader-common/d3d11" ]
|
d3d11 = [ "runtime", "librashader-common/d3d11" ]
|
||||||
|
vk = ["runtime", "librashader-common/vulkan" ]
|
||||||
runtime = []
|
runtime = []
|
||||||
reflect = []
|
reflect = []
|
||||||
preprocess = []
|
preprocess = []
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
//! |-------------|------------|---------------------------|
|
//! |-------------|------------|---------------------------|
|
||||||
//! | OpenGL 3.3+ | ✔ | `gl` |
|
//! | OpenGL 3.3+ | ✔ | `gl` |
|
||||||
//! | OpenGL 4.6 | ✔ | `gl` |
|
//! | OpenGL 4.6 | ✔ | `gl` |
|
||||||
//! | Vulkan | 🚧 | `vk` |
|
//! | Vulkan | ✔ | `vk` |
|
||||||
//! | Direct3D 11 | ✔ | `d3d11` |
|
//! | Direct3D 11 | ✔ | `d3d11` |
|
||||||
//! | Direct3D 12 | 🚧 | `d3d12` |
|
//! | Direct3D 12 | 🚧 | `d3d12` |
|
||||||
//! | OpenGL 2 | ❌ | |
|
//! | OpenGL 2 | ❌ | |
|
||||||
|
@ -104,14 +104,16 @@ pub mod runtime {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "d3d11")]
|
#[cfg(feature = "d3d11")]
|
||||||
/// Shader runtime for Direct3D11
|
/// Shader runtime for Direct3D 11.
|
||||||
pub mod d3d11 {
|
pub mod d3d11 {
|
||||||
pub use librashader_runtime_d3d11::*;
|
pub use librashader_runtime_d3d11::*;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "vk")]
|
#[cfg(feature = "vk")]
|
||||||
/// Shader compiler targets and runtime for Vulkan.
|
/// Shader runtime for Vulkan 1.3+.
|
||||||
pub mod vk {}
|
pub mod vk {
|
||||||
|
pub use librashader_runtime_vk::*;
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod helper {
|
pub mod helper {
|
||||||
|
|
Loading…
Reference in a new issue