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