fmt: run cargo fmt
This commit is contained in:
parent
3691f6579c
commit
05ec73a11c
|
@ -21,7 +21,7 @@ pub type libra_d3d11_filter_chain_t =
|
|||
/// A handle to a Vulkan filter chain.
|
||||
#[cfg(feature = "runtime-vulkan")]
|
||||
pub type libra_vk_filter_chain_t =
|
||||
Option<NonNull<librashader::runtime::vk::capi::FilterChainVulkan>>;
|
||||
Option<NonNull<librashader::runtime::vk::capi::FilterChainVulkan>>;
|
||||
|
||||
/// Defines the output viewport for a rendered frame.
|
||||
#[repr(C)]
|
||||
|
|
|
@ -28,7 +28,10 @@ pub enum LibrashaderError {
|
|||
#[cfg(feature = "runtime-opengl")]
|
||||
#[error("There was an error in the OpenGL filter chain.")]
|
||||
OpenGlFilterError(#[from] librashader::runtime::gl::error::FilterChainError),
|
||||
#[cfg(any(feature = "docsrs", all(target_os = "windows", feature = "runtime-d3d11")))]
|
||||
#[cfg(any(
|
||||
feature = "docsrs",
|
||||
all(target_os = "windows", feature = "runtime-d3d11")
|
||||
))]
|
||||
#[error("There was an error in the D3D11 filter chain.")]
|
||||
D3D11FilterError(#[from] librashader::runtime::d3d11::error::FilterChainError),
|
||||
#[cfg(feature = "runtime-vulkan")]
|
||||
|
@ -111,7 +114,7 @@ pub extern "C" fn libra_error_free(error: *mut libra_error_t) -> i32 {
|
|||
|
||||
/// Function pointer definition for libra_error_write
|
||||
pub type PFN_libra_error_write =
|
||||
extern "C" fn(error: libra_error_t, out: *mut MaybeUninit<*mut c_char>) -> i32;
|
||||
extern "C" fn(error: libra_error_t, out: *mut MaybeUninit<*mut c_char>) -> i32;
|
||||
#[no_mangle]
|
||||
/// Writes the error message into `out`
|
||||
///
|
||||
|
@ -174,13 +177,14 @@ impl LibrashaderError {
|
|||
LibrashaderError::PreprocessError(_) => LIBRA_ERRNO::PREPROCESS_ERROR,
|
||||
LibrashaderError::ShaderCompileError(_) | LibrashaderError::ShaderReflectError(_) => {
|
||||
LIBRA_ERRNO::REFLECT_ERROR
|
||||
},
|
||||
LibrashaderError::UnknownShaderParameter(_) => {
|
||||
LIBRA_ERRNO::SHADER_PARAMETER_ERROR
|
||||
}
|
||||
LibrashaderError::UnknownShaderParameter(_) => LIBRA_ERRNO::SHADER_PARAMETER_ERROR,
|
||||
#[cfg(feature = "runtime-opengl")]
|
||||
LibrashaderError::OpenGlFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
|
||||
#[cfg(any(feature = "docsrs", all(target_os = "windows", feature = "runtime-d3d11")))]
|
||||
#[cfg(any(
|
||||
feature = "docsrs",
|
||||
all(target_os = "windows", feature = "runtime-d3d11")
|
||||
))]
|
||||
LibrashaderError::D3D11FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
|
||||
#[cfg(feature = "runtime-vulkan")]
|
||||
LibrashaderError::VulkanFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! The librashader preset C API (`libra_preset_*`).
|
||||
use crate::ctypes::{libra_shader_preset_t};
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ctypes::libra_shader_preset_t;
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ffi::extern_fn;
|
||||
use librashader::presets::ShaderPreset;
|
||||
use std::ffi::{c_char, CStr, CString};
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use std::ffi::CStr;
|
||||
use crate::ctypes::{
|
||||
libra_d3d11_filter_chain_t, libra_shader_preset_t, libra_viewport_t,
|
||||
};
|
||||
use crate::ctypes::{libra_d3d11_filter_chain_t, libra_shader_preset_t, libra_viewport_t};
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ffi::extern_fn;
|
||||
use librashader::runtime::d3d11::{D3D11InputView, D3D11OutputView};
|
||||
use std::ffi::c_char;
|
||||
use std::ffi::CStr;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr::NonNull;
|
||||
use std::ffi::c_char;
|
||||
use std::slice;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Device, ID3D11RenderTargetView, ID3D11ShaderResourceView,
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
use crate::ctypes::{
|
||||
libra_gl_filter_chain_t, libra_shader_preset_t, libra_viewport_t,
|
||||
};
|
||||
use crate::ctypes::{libra_gl_filter_chain_t, libra_shader_preset_t, libra_viewport_t};
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ffi::extern_fn;
|
||||
use librashader::runtime::gl::{Framebuffer, GLImage};
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::{c_char, c_void, CString};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr::NonNull;
|
||||
use std::slice;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub use librashader::runtime::gl::capi::options::FilterChainOptionsGL;
|
||||
pub use librashader::runtime::gl::capi::options::FrameOptionsGL;
|
||||
use librashader::runtime::{Size, Viewport};
|
||||
use librashader::runtime::FilterChainParameters;
|
||||
use librashader::runtime::{Size, Viewport};
|
||||
|
||||
/// A GL function loader that librashader needs to be initialized with.
|
||||
pub type libra_gl_loader_t = unsafe extern "system" fn(*const c_char) -> *const c_void;
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#[cfg(feature = "runtime-opengl")]
|
||||
pub mod gl;
|
||||
|
||||
#[cfg(any(feature = "docsrs", all(target_os = "windows", feature = "runtime-d3d11")))]
|
||||
#[cfg(any(
|
||||
feature = "docsrs",
|
||||
all(target_os = "windows", feature = "runtime-d3d11")
|
||||
))]
|
||||
pub mod d3d11;
|
||||
|
||||
#[cfg(feature = "runtime-vulkan")]
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
use std::ffi::{c_char, c_void};
|
||||
use crate::ctypes::{
|
||||
libra_vk_filter_chain_t, libra_shader_preset_t, libra_viewport_t,
|
||||
};
|
||||
use crate::ctypes::{libra_shader_preset_t, libra_viewport_t, libra_vk_filter_chain_t};
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ffi::extern_fn;
|
||||
use librashader::runtime::vk::{VulkanImage, VulkanInstance};
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::{c_char, c_void};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr::NonNull;
|
||||
use std::slice;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub use librashader::runtime::vk::capi::options::FilterChainOptionsVulkan;
|
||||
pub use librashader::runtime::vk::capi::options::FrameOptionsVulkan;
|
||||
use librashader::runtime::{Size, Viewport};
|
||||
use librashader::runtime::FilterChainParameters;
|
||||
use librashader::runtime::{Size, Viewport};
|
||||
|
||||
use ash::vk;
|
||||
|
||||
pub use ash::vk::PFN_vkGetInstanceProcAddr;
|
||||
|
||||
/// A Vulkan instance function loader that the Vulkan filter chain needs to be initialized with.
|
||||
pub type libra_PFN_vkGetInstanceProcAddr = unsafe extern "system" fn(instance: *mut c_void, p_name: *const c_char);
|
||||
|
||||
pub type libra_PFN_vkGetInstanceProcAddr =
|
||||
unsafe extern "system" fn(instance: *mut c_void, p_name: *const c_char);
|
||||
|
||||
/// Vulkan parameters for the source image.
|
||||
#[repr(C)]
|
||||
|
@ -49,7 +47,7 @@ pub struct libra_device_vk_t {
|
|||
/// for the device attached to the instance that will perform rendering.
|
||||
pub device: vk::Device,
|
||||
/// The entry loader for the Vulkan library.
|
||||
pub entry: vk::PFN_vkGetInstanceProcAddr
|
||||
pub entry: vk::PFN_vkGetInstanceProcAddr,
|
||||
}
|
||||
|
||||
impl From<libra_image_vk_t> for VulkanImage {
|
||||
|
@ -165,7 +163,6 @@ extern_fn! {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
extern_fn! {
|
||||
/// Sets a parameter for the filter chain.
|
||||
///
|
||||
|
|
|
@ -9,4 +9,4 @@ pub struct Viewport<'a, T> {
|
|||
pub mvp: Option<&'a [f32; 16]>,
|
||||
/// The output handle to render the final image to.
|
||||
pub output: T,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::texture::{D3D11InputView, LutTexture, InputTexture};
|
||||
use crate::texture::{D3D11InputView, InputTexture, LutTexture};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
|
@ -24,7 +24,7 @@ use crate::quad_render::DrawQuad;
|
|||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::util::d3d11_compile_bound_shader;
|
||||
use crate::{D3D11OutputView, error, util};
|
||||
use crate::{error, util, D3D11OutputView};
|
||||
use librashader_runtime::uniforms::UniformStorage;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Buffer, ID3D11Device, ID3D11DeviceContext, D3D11_BIND_CONSTANT_BUFFER, D3D11_BUFFER_DESC,
|
||||
|
|
|
@ -11,15 +11,15 @@ use librashader_reflect::reflect::semantics::{
|
|||
use librashader_reflect::reflect::ShaderReflection;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use librashader_runtime::binding::{BindSemantics, TextureInput};
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Buffer, ID3D11InputLayout, ID3D11PixelShader, ID3D11SamplerState,
|
||||
ID3D11ShaderResourceView, ID3D11VertexShader, D3D11_MAP_WRITE_DISCARD,
|
||||
};
|
||||
use librashader_runtime::binding::{BindSemantics, TextureInput};
|
||||
|
||||
use crate::{D3D11OutputView, error};
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::{error, D3D11OutputView};
|
||||
use librashader_runtime::uniforms::{UniformStorage, UniformStorageAccess};
|
||||
|
||||
pub struct ConstantBufferBinding {
|
||||
|
@ -60,14 +60,20 @@ impl TextureInput for InputTexture {
|
|||
impl BindSemantics for FilterPass {
|
||||
type InputTexture = InputTexture;
|
||||
type SamplerSet = SamplerSet;
|
||||
type DescriptorSet<'a> = (&'a mut [Option<ID3D11ShaderResourceView>; 16], &'a mut [Option<ID3D11SamplerState>; 16]);
|
||||
type DescriptorSet<'a> = (
|
||||
&'a mut [Option<ID3D11ShaderResourceView>; 16],
|
||||
&'a mut [Option<ID3D11SamplerState>; 16],
|
||||
);
|
||||
type DeviceContext = ();
|
||||
type UniformOffset = MemberOffset;
|
||||
|
||||
fn bind_texture<'a>(
|
||||
descriptors: &mut Self::DescriptorSet<'a>, samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding, texture: &Self::InputTexture,
|
||||
_device: &Self::DeviceContext) {
|
||||
descriptors: &mut Self::DescriptorSet<'a>,
|
||||
samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding,
|
||||
texture: &Self::InputTexture,
|
||||
_device: &Self::DeviceContext,
|
||||
) {
|
||||
let (texture_binding, sampler_binding) = descriptors;
|
||||
texture_binding[binding.binding as usize] = Some(texture.view.handle.clone());
|
||||
sampler_binding[binding.binding as usize] =
|
||||
|
@ -110,7 +116,10 @@ impl FilterPass {
|
|||
frame_direction: i32,
|
||||
fb_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
mut descriptors: (&'a mut [Option<ID3D11ShaderResourceView>; 16], &'a mut [Option<ID3D11SamplerState>; 16]),
|
||||
mut descriptors: (
|
||||
&'a mut [Option<ID3D11ShaderResourceView>; 16],
|
||||
&'a mut [Option<ID3D11SamplerState>; 16],
|
||||
),
|
||||
original: &InputTexture,
|
||||
source: &InputTexture,
|
||||
) {
|
||||
|
@ -128,16 +137,14 @@ impl FilterPass {
|
|||
source,
|
||||
&self.uniform_bindings,
|
||||
&self.reflection.meta.texture_meta,
|
||||
parent.output_textures[0..pass_index].iter()
|
||||
parent.output_textures[0..pass_index]
|
||||
.iter()
|
||||
.map(|o| o.as_ref()),
|
||||
parent.feedback_textures.iter()
|
||||
.map(|o| o.as_ref()),
|
||||
parent.history_textures.iter()
|
||||
.map(|o| o.as_ref()),
|
||||
parent.luts.iter()
|
||||
.map(|(u, i)| (*u, i.as_ref())),
|
||||
parent.feedback_textures.iter().map(|o| o.as_ref()),
|
||||
parent.history_textures.iter().map(|o| o.as_ref()),
|
||||
parent.luts.iter().map(|(u, i)| (*u, i.as_ref())),
|
||||
&self.source.parameters,
|
||||
&parent.config.parameters
|
||||
&parent.config.parameters,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -229,10 +229,10 @@ pub mod d3d11_hello_triangle {
|
|||
|
||||
use crate::options::FilterChainOptionsD3D11;
|
||||
use crate::texture::D3D11InputView;
|
||||
use crate::D3D11OutputView;
|
||||
use librashader_common::{Size, Viewport};
|
||||
use std::slice;
|
||||
use std::time::Instant;
|
||||
use crate::D3D11OutputView;
|
||||
|
||||
pub struct Sample {
|
||||
pub dxgi_factory: IDXGIFactory4,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::framebuffer::OutputFramebuffer;
|
||||
use windows::Win32::Graphics::Direct3D11::D3D11_VIEWPORT;
|
||||
use librashader_common::Viewport;
|
||||
use crate::D3D11OutputView;
|
||||
use librashader_common::Viewport;
|
||||
use windows::Win32::Graphics::Direct3D11::D3D11_VIEWPORT;
|
||||
|
||||
#[rustfmt::skip]
|
||||
static DEFAULT_MVP: &[f32; 16] = &[
|
||||
|
|
|
@ -2,18 +2,18 @@ use librashader_common::{FilterMode, Size, WrapMode};
|
|||
use librashader_runtime::image::Image;
|
||||
use windows::Win32::Graphics::Direct3D::D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Device, ID3D11DeviceContext, ID3D11ShaderResourceView, ID3D11RenderTargetView, ID3D11Texture2D, D3D11_BIND_FLAG,
|
||||
D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE, D3D11_BOX, D3D11_CPU_ACCESS_FLAG,
|
||||
D3D11_CPU_ACCESS_WRITE, D3D11_RESOURCE_MISC_FLAG, D3D11_RESOURCE_MISC_GENERATE_MIPS,
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC, D3D11_SHADER_RESOURCE_VIEW_DESC_0, D3D11_SUBRESOURCE_DATA,
|
||||
D3D11_TEX2D_SRV, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DYNAMIC, D3D11_USAGE_STAGING,
|
||||
ID3D11Device, ID3D11DeviceContext, ID3D11RenderTargetView, ID3D11ShaderResourceView,
|
||||
ID3D11Texture2D, D3D11_BIND_FLAG, D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE,
|
||||
D3D11_BOX, D3D11_CPU_ACCESS_FLAG, D3D11_CPU_ACCESS_WRITE, D3D11_RESOURCE_MISC_FLAG,
|
||||
D3D11_RESOURCE_MISC_GENERATE_MIPS, D3D11_SHADER_RESOURCE_VIEW_DESC,
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC_0, D3D11_SUBRESOURCE_DATA, D3D11_TEX2D_SRV,
|
||||
D3D11_TEXTURE2D_DESC, D3D11_USAGE_DYNAMIC, D3D11_USAGE_STAGING,
|
||||
};
|
||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::framebuffer::OwnedFramebuffer;
|
||||
|
||||
|
||||
/// An image view for use as a shader resource.
|
||||
///
|
||||
/// Contains an `ID3D11ShaderResourceView`, and a size.
|
||||
|
|
|
@ -29,7 +29,7 @@ pub enum FilterChainError {
|
|||
#[error("opengl could not link program")]
|
||||
GLLinkError,
|
||||
#[error("opengl could not compile program")]
|
||||
GlCompileError
|
||||
GlCompileError,
|
||||
}
|
||||
|
||||
/// Result type for OpenGL filter chains.
|
||||
|
|
|
@ -227,7 +227,8 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
// todo: split this out.
|
||||
let (program, ubo_location) = unsafe {
|
||||
let vertex = util::gl_compile_shader(gl::VERTEX_SHADER, glsl.vertex.as_str())?;
|
||||
let fragment = util::gl_compile_shader(gl::FRAGMENT_SHADER, glsl.fragment.as_str())?;
|
||||
let fragment =
|
||||
util::gl_compile_shader(gl::FRAGMENT_SHADER, glsl.fragment.as_str())?;
|
||||
|
||||
let program = gl::CreateProgram();
|
||||
gl::AttachShader(program, vertex);
|
||||
|
@ -304,21 +305,30 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
for param in reflection.meta.parameter_meta.values() {
|
||||
uniform_bindings.insert(
|
||||
UniformBinding::Parameter(param.id.clone()),
|
||||
UniformOffset::new(Self::reflect_uniform_location(program, param), param.offset),
|
||||
UniformOffset::new(
|
||||
Self::reflect_uniform_location(program, param),
|
||||
param.offset,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
for (semantics, param) in &reflection.meta.unique_meta {
|
||||
uniform_bindings.insert(
|
||||
UniformBinding::SemanticVariable(*semantics),
|
||||
UniformOffset::new(Self::reflect_uniform_location(program, param), param.offset),
|
||||
UniformOffset::new(
|
||||
Self::reflect_uniform_location(program, param),
|
||||
param.offset,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
for (semantics, param) in &reflection.meta.texture_size_meta {
|
||||
uniform_bindings.insert(
|
||||
UniformBinding::TextureSize(*semantics),
|
||||
UniformOffset::new(Self::reflect_uniform_location(program, param), param.offset),
|
||||
UniformOffset::new(
|
||||
Self::reflect_uniform_location(program, param),
|
||||
param.offset,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
use std::panic::catch_unwind;
|
||||
use std::path::Path;
|
||||
|
||||
|
@ -14,7 +13,7 @@ mod inner;
|
|||
mod parameters;
|
||||
|
||||
pub(crate) use filter_impl::FilterCommon;
|
||||
use librashader_common::{Viewport};
|
||||
use librashader_common::Viewport;
|
||||
|
||||
/// An OpenGL filter chain.
|
||||
pub struct FilterChainGL {
|
||||
|
|
|
@ -6,30 +6,29 @@ use librashader_reflect::reflect::ShaderReflection;
|
|||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::ShaderPassConfig;
|
||||
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics};
|
||||
use rustc_hash::FxHashMap;
|
||||
use librashader_reflect::reflect::semantics::{
|
||||
MemberOffset, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics,
|
||||
};
|
||||
use librashader_runtime::binding::{BindSemantics, ContextOffset, TextureInput};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::binding::{GlUniformBinder, GlUniformStorage, UniformLocation, VariableLocation};
|
||||
use crate::filter_chain::FilterCommon;
|
||||
use crate::Framebuffer;
|
||||
use crate::gl::{BindTexture, GLInterface, UboRing};
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::Framebuffer;
|
||||
|
||||
use crate::texture::InputTexture;
|
||||
|
||||
pub struct UniformOffset {
|
||||
pub location: VariableLocation,
|
||||
pub offset: MemberOffset
|
||||
pub offset: MemberOffset,
|
||||
}
|
||||
|
||||
impl UniformOffset {
|
||||
pub fn new(location: VariableLocation, offset: MemberOffset) -> Self {
|
||||
Self {
|
||||
location,
|
||||
offset
|
||||
}
|
||||
Self { location, offset }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,9 +68,12 @@ impl<T: GLInterface> BindSemantics<GlUniformBinder, UniformLocation<GLint>> for
|
|||
type UniformOffset = UniformOffset;
|
||||
|
||||
fn bind_texture<'a>(
|
||||
_descriptors: &mut Self::DescriptorSet<'a>, samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding, texture: &Self::InputTexture,
|
||||
_device: &Self::DeviceContext) {
|
||||
_descriptors: &mut Self::DescriptorSet<'a>,
|
||||
samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding,
|
||||
texture: &Self::InputTexture,
|
||||
_device: &Self::DeviceContext,
|
||||
) {
|
||||
T::BindTexture::bind_texture(&samplers, binding, texture);
|
||||
}
|
||||
}
|
||||
|
@ -186,16 +188,14 @@ impl<T: GLInterface> FilterPass<T> {
|
|||
source,
|
||||
&self.uniform_bindings,
|
||||
&self.reflection.meta.texture_meta,
|
||||
parent.output_textures[0..pass_index].iter()
|
||||
parent.output_textures[0..pass_index]
|
||||
.iter()
|
||||
.map(|o| o.bound()),
|
||||
parent.feedback_textures.iter()
|
||||
.map(|o| o.bound()),
|
||||
parent.history_textures.iter()
|
||||
.map(|o| o.bound()),
|
||||
parent.luts.iter()
|
||||
.map(|(u, i)| (*u, i)),
|
||||
parent.feedback_textures.iter().map(|o| o.bound()),
|
||||
parent.history_textures.iter().map(|o| o.bound()),
|
||||
parent.luts.iter().map(|(u, i)| (*u, i)),
|
||||
&self.source.parameters,
|
||||
&parent.config.parameters
|
||||
&parent.config.parameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use gl::types::{GLenum, GLuint};
|
|||
use librashader_common::{FilterMode, ImageFormat, Size, Viewport, WrapMode};
|
||||
use librashader_presets::Scale2D;
|
||||
|
||||
|
||||
/// A handle to an OpenGL FBO and its backing texture with format and size information.
|
||||
///
|
||||
/// Generally for use as render targets.
|
||||
|
|
|
@ -8,10 +8,10 @@ use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
|
|||
use librashader_common::{Size, Viewport};
|
||||
|
||||
use crate::filter_chain::FilterChainGL;
|
||||
use crate::Framebuffer;
|
||||
use crate::framebuffer::GLImage;
|
||||
use crate::gl::gl3::CompatibilityGL;
|
||||
use crate::gl::{FramebufferInterface, GLInterface};
|
||||
use crate::Framebuffer;
|
||||
|
||||
const WIDTH: u32 = 800;
|
||||
const HEIGHT: u32 = 600;
|
||||
|
|
|
@ -8,10 +8,10 @@ use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
|
|||
use librashader_common::{Size, Viewport};
|
||||
|
||||
use crate::filter_chain::FilterChainGL;
|
||||
use crate::Framebuffer;
|
||||
use crate::framebuffer::GLImage;
|
||||
use crate::gl::gl46::DirectStateAccessGL;
|
||||
use crate::gl::{FramebufferInterface, GLInterface};
|
||||
use crate::Framebuffer;
|
||||
|
||||
const WIDTH: u32 = 800;
|
||||
const HEIGHT: u32 = 600;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use librashader_common::Viewport;
|
||||
use crate::gl::Framebuffer;
|
||||
use librashader_common::Viewport;
|
||||
|
||||
#[rustfmt::skip]
|
||||
static DEFAULT_MVP: &[f32; 16] = &[
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use gl::types::GLuint;
|
||||
use crate::framebuffer::GLImage;
|
||||
use gl::types::GLuint;
|
||||
use librashader_common::{FilterMode, WrapMode};
|
||||
|
||||
#[derive(Default, Debug, Copy, Clone)]
|
||||
|
@ -29,4 +29,4 @@ impl AsRef<InputTexture> for InputTexture {
|
|||
fn as_ref(&self) -> &InputTexture {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use gl::types::{GLenum, GLuint};
|
||||
|
||||
use librashader_reflect::back::cross::GlslVersion;
|
||||
use crate::error;
|
||||
use crate::error::FilterChainError;
|
||||
use librashader_reflect::back::cross::GlslVersion;
|
||||
|
||||
pub unsafe fn gl_compile_shader(stage: GLenum, source: &str) -> error::Result<GLuint> {
|
||||
let shader = gl::CreateShader(stage);
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::error::FilterChainError;
|
|||
use crate::filter_pass::FilterPass;
|
||||
use crate::framebuffer::OutputImage;
|
||||
use crate::luts::LutTexture;
|
||||
use crate::options::{FilterChainOptionsVulkan, FrameOptionsVulkan};
|
||||
use crate::queue_selection::get_graphics_queue;
|
||||
use crate::render_target::{RenderTarget, DEFAULT_MVP};
|
||||
use crate::samplers::SamplerSet;
|
||||
|
@ -27,7 +28,6 @@ use rustc_hash::FxHashMap;
|
|||
use std::collections::VecDeque;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use crate::options::{FilterChainOptionsVulkan, FrameOptionsVulkan};
|
||||
|
||||
/// A Vulkan device and metadata that is required by the shader runtime.
|
||||
pub struct VulkanObjects {
|
||||
|
@ -78,7 +78,7 @@ impl TryFrom<VulkanInstance> for VulkanObjects {
|
|||
instance.get_physical_device_memory_properties(vulkan.physical_device);
|
||||
|
||||
Ok(VulkanObjects {
|
||||
device: Arc::new(device),
|
||||
device: Arc::new(device),
|
||||
queue,
|
||||
pipeline_cache,
|
||||
memory_properties,
|
||||
|
@ -91,11 +91,14 @@ impl TryFrom<VulkanInstance> for VulkanObjects {
|
|||
impl TryFrom<(vk::PhysicalDevice, ash::Instance, Arc<ash::Device>)> for VulkanObjects {
|
||||
type Error = FilterChainError;
|
||||
|
||||
fn try_from(value: (vk::PhysicalDevice, ash::Instance, Arc<ash::Device>)) -> error::Result<Self> {
|
||||
fn try_from(
|
||||
value: (vk::PhysicalDevice, ash::Instance, Arc<ash::Device>),
|
||||
) -> error::Result<Self> {
|
||||
unsafe {
|
||||
let device = value.2;
|
||||
|
||||
let pipeline_cache = device.create_pipeline_cache(&vk::PipelineCacheCreateInfo::default(), None)?;
|
||||
let pipeline_cache =
|
||||
device.create_pipeline_cache(&vk::PipelineCacheCreateInfo::default(), None)?;
|
||||
|
||||
let queue = get_graphics_queue(&value.1, &device, value.0);
|
||||
|
||||
|
@ -245,7 +248,9 @@ impl FilterChainVulkan {
|
|||
feedback_textures.resize_with(filters.len(), || None);
|
||||
|
||||
let mut intermediates = Vec::new();
|
||||
intermediates.resize_with(frames_in_flight as usize, || FrameResiduals::new(&device.device));
|
||||
intermediates.resize_with(frames_in_flight as usize, || {
|
||||
FrameResiduals::new(&device.device)
|
||||
});
|
||||
|
||||
Ok(FilterChainVulkan {
|
||||
common: FilterCommon {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use std::sync::Arc;
|
||||
use crate::{error, VulkanImage};
|
||||
use crate::filter_chain::FilterCommon;
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::InputImage;
|
||||
use crate::ubo_ring::VkUboRing;
|
||||
use crate::vulkan_state::VulkanGraphicsPipeline;
|
||||
use crate::{error, VulkanImage};
|
||||
use ash::vk;
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
|
@ -14,9 +13,12 @@ use librashader_reflect::reflect::semantics::{
|
|||
BindingStage, MemberOffset, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics,
|
||||
};
|
||||
use librashader_reflect::reflect::ShaderReflection;
|
||||
use librashader_runtime::uniforms::{BindUniform, NoUniformBinder, UniformStorage, UniformStorageAccess};
|
||||
use rustc_hash::FxHashMap;
|
||||
use librashader_runtime::binding::{BindSemantics, TextureInput};
|
||||
use librashader_runtime::uniforms::{
|
||||
BindUniform, NoUniformBinder, UniformStorage, UniformStorageAccess,
|
||||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct FilterPass {
|
||||
pub device: Arc<ash::Device>,
|
||||
|
@ -45,8 +47,12 @@ impl BindSemantics for FilterPass {
|
|||
type UniformOffset = MemberOffset;
|
||||
|
||||
fn bind_texture<'a>(
|
||||
descriptors: &mut Self::DescriptorSet<'a>, samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding, texture: &Self::InputTexture, device: &Self::DeviceContext) {
|
||||
descriptors: &mut Self::DescriptorSet<'a>,
|
||||
samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding,
|
||||
texture: &Self::InputTexture,
|
||||
device: &Self::DeviceContext,
|
||||
) {
|
||||
let sampler = samplers.get(texture.wrap_mode, texture.filter_mode, texture.mip_filter);
|
||||
let image_info = [vk::DescriptorImageInfo::builder()
|
||||
.sampler(sampler.handle)
|
||||
|
@ -244,16 +250,14 @@ impl FilterPass {
|
|||
source,
|
||||
&self.uniform_bindings,
|
||||
&self.reflection.meta.texture_meta,
|
||||
parent.output_inputs[0..pass_index].iter()
|
||||
parent.output_inputs[0..pass_index]
|
||||
.iter()
|
||||
.map(|o| o.as_ref()),
|
||||
parent.feedback_inputs.iter()
|
||||
.map(|o| o.as_ref()),
|
||||
parent.history_textures.iter()
|
||||
.map(|o| o.as_ref()),
|
||||
parent.luts.iter()
|
||||
.map(|(u, i)| (*u, i.as_ref())),
|
||||
parent.feedback_inputs.iter().map(|o| o.as_ref()),
|
||||
parent.history_textures.iter().map(|o| o.as_ref()),
|
||||
parent.luts.iter().map(|(u, i)| (*u, i.as_ref())),
|
||||
&self.source.parameters,
|
||||
&parent.config.parameters
|
||||
&parent.config.parameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
use crate::filter_chain::VulkanObjects;
|
||||
use crate::texture::VulkanImage;
|
||||
use crate::{error, util};
|
||||
use ash::vk;
|
||||
use librashader_common::Size;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct OutputImage {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
use crate::hello_triangle::physicaldevice::find_queue_family;
|
||||
use crate::hello_triangle::vulkan_base::VulkanBase;
|
||||
use ash::prelude::VkResult;
|
||||
use ash::vk;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct VulkanCommandPool {
|
||||
pool: vk::CommandPool,
|
||||
|
|
|
@ -20,11 +20,11 @@ use crate::texture::VulkanImage;
|
|||
use crate::util;
|
||||
use ash::vk;
|
||||
use ash::vk::{Handle, RenderingInfo};
|
||||
use librashader_common::Viewport;
|
||||
use std::ffi::CString;
|
||||
use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
||||
use winit::event_loop::{ControlFlow, EventLoop, EventLoopBuilder};
|
||||
use winit::platform::windows::EventLoopBuilderExtWindows;
|
||||
use librashader_common::Viewport;
|
||||
|
||||
// Constants
|
||||
const WINDOW_TITLE: &'static str = "librashader Vulkan";
|
||||
|
@ -210,7 +210,7 @@ impl VulkanWindow {
|
|||
// vk::QUEUE_FAMILY_IGNORED
|
||||
// );
|
||||
|
||||
filter
|
||||
filter
|
||||
.frame(
|
||||
&VulkanImage {
|
||||
size: vulkan.swapchain.extent.into(),
|
||||
|
|
|
@ -109,11 +109,14 @@ impl VulkanSwapchain {
|
|||
|
||||
let alloc_info = vk::MemoryAllocateInfo::builder()
|
||||
.allocation_size(mem_reqs.size)
|
||||
.memory_type_index(find_vulkan_memory_type(
|
||||
&base.mem_props,
|
||||
mem_reqs.memory_type_bits,
|
||||
vk::MemoryPropertyFlags::DEVICE_LOCAL,
|
||||
).unwrap())
|
||||
.memory_type_index(
|
||||
find_vulkan_memory_type(
|
||||
&base.mem_props,
|
||||
mem_reqs.memory_type_bits,
|
||||
vk::MemoryPropertyFlags::DEVICE_LOCAL,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
.build();
|
||||
|
||||
// todo: optimize by reusing existing memory.
|
||||
|
|
|
@ -20,8 +20,8 @@ mod vulkan_primitives;
|
|||
mod vulkan_state;
|
||||
|
||||
pub use filter_chain::FilterChainVulkan;
|
||||
pub use filter_chain::VulkanObjects;
|
||||
pub use filter_chain::VulkanInstance;
|
||||
pub use filter_chain::VulkanObjects;
|
||||
pub use texture::VulkanImage;
|
||||
|
||||
pub mod error;
|
||||
|
|
|
@ -254,4 +254,4 @@ impl AsRef<InputImage> for LutTexture {
|
|||
fn as_ref(&self) -> &InputImage {
|
||||
&self.image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,3 @@ pub struct FilterChainOptionsVulkan {
|
|||
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
||||
pub force_no_mipmaps: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
use crate::error;
|
||||
use ash::vk;
|
||||
use librashader_common::{FilterMode, WrapMode};
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct VulkanSampler {
|
||||
pub handle: vk::Sampler,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
use crate::filter_chain::VulkanObjects;
|
||||
use crate::util::find_vulkan_memory_type;
|
||||
use crate::vulkan_primitives::VulkanImageMemory;
|
||||
use crate::{error, util};
|
||||
use ash::vk;
|
||||
use std::sync::Arc;
|
||||
|
||||
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
||||
use librashader_presets::Scale2D;
|
||||
|
@ -532,4 +532,4 @@ impl AsRef<InputImage> for InputImage {
|
|||
fn as_ref(&self) -> &InputImage {
|
||||
&self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
use crate::error;
|
||||
use crate::vulkan_primitives::VulkanBuffer;
|
||||
use ash::vk;
|
||||
use librashader_runtime::ringbuffer::{BoxRingBuffer, RingBuffer};
|
||||
use librashader_runtime::uniforms::UniformStorageAccess;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct VkUboRing {
|
||||
ring: BoxRingBuffer<VulkanBuffer>,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use ash::vk;
|
||||
|
||||
use librashader_reflect::reflect::semantics::BindingStage;
|
||||
use crate::error;
|
||||
use crate::error::FilterChainError;
|
||||
use librashader_reflect::reflect::semantics::BindingStage;
|
||||
|
||||
pub fn binding_stage_to_vulkan_stage(stage_mask: BindingStage) -> vk::ShaderStageFlags {
|
||||
let mut mask = vk::ShaderStageFlags::default();
|
||||
|
@ -33,7 +33,11 @@ pub fn find_vulkan_memory_type(
|
|||
if host_reqs == vk::MemoryPropertyFlags::empty() {
|
||||
Err(FilterChainError::VulkanMemoryError(device_reqs))
|
||||
} else {
|
||||
Ok(find_vulkan_memory_type(props, device_reqs, vk::MemoryPropertyFlags::empty())?)
|
||||
Ok(find_vulkan_memory_type(
|
||||
props,
|
||||
device_reqs,
|
||||
vk::MemoryPropertyFlags::empty(),
|
||||
)?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use std::collections::HashMap;
|
||||
use std::hash::BuildHasher;
|
||||
use crate::uniforms::{BindUniform, NoUniformBinder, UniformStorage};
|
||||
use librashader_common::Size;
|
||||
use librashader_preprocess::ShaderParameter;
|
||||
use librashader_reflect::reflect::semantics::{MemberOffset, Semantic, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics};
|
||||
use crate::uniforms::{BindUniform, NoUniformBinder, UniformStorage};
|
||||
use librashader_reflect::reflect::semantics::{
|
||||
MemberOffset, Semantic, TextureBinding, TextureSemantics, UniformBinding, UniqueSemantics,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::hash::BuildHasher;
|
||||
|
||||
/// Trait for input textures used during uniform binding,
|
||||
pub trait TextureInput {
|
||||
|
@ -13,12 +15,12 @@ pub trait TextureInput {
|
|||
|
||||
/// A uniform member offset with context that needs to be resolved.
|
||||
pub trait ContextOffset<H, C>
|
||||
where
|
||||
H: BindUniform<C, f32>,
|
||||
H: BindUniform<C, u32>,
|
||||
H: BindUniform<C, i32>,
|
||||
H: for<'a> BindUniform<C, &'a [f32; 4]>,
|
||||
H: for<'a> BindUniform<C, &'a [f32; 16]>,
|
||||
where
|
||||
H: BindUniform<C, f32>,
|
||||
H: BindUniform<C, u32>,
|
||||
H: BindUniform<C, i32>,
|
||||
H: for<'a> BindUniform<C, &'a [f32; 4]>,
|
||||
H: for<'a> BindUniform<C, &'a [f32; 16]>,
|
||||
{
|
||||
/// Gets the `MemberOffset` part of the offset.
|
||||
fn offset(&self) -> MemberOffset;
|
||||
|
@ -28,12 +30,12 @@ pub trait ContextOffset<H, C>
|
|||
}
|
||||
|
||||
impl<H> ContextOffset<H, Option<()>> for MemberOffset
|
||||
where
|
||||
H: BindUniform<Option<()>, f32>,
|
||||
H: BindUniform<Option<()>, u32>,
|
||||
H: BindUniform<Option<()>, i32>,
|
||||
H: for<'a> BindUniform<Option<()>, &'a [f32; 4]>,
|
||||
H: for<'a> BindUniform<Option<()>, &'a [f32; 16]>,
|
||||
where
|
||||
H: BindUniform<Option<()>, f32>,
|
||||
H: BindUniform<Option<()>, u32>,
|
||||
H: BindUniform<Option<()>, i32>,
|
||||
H: for<'a> BindUniform<Option<()>, &'a [f32; 4]>,
|
||||
H: for<'a> BindUniform<Option<()>, &'a [f32; 16]>,
|
||||
{
|
||||
fn offset(&self) -> MemberOffset {
|
||||
*self
|
||||
|
@ -45,13 +47,13 @@ impl<H> ContextOffset<H, Option<()>> for MemberOffset
|
|||
}
|
||||
|
||||
/// Trait that abstracts binding of semantics to shader uniforms.
|
||||
pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
||||
where
|
||||
H: BindUniform<C, f32>,
|
||||
H: BindUniform<C, u32>,
|
||||
H: BindUniform<C, i32>,
|
||||
H: for<'b> BindUniform<C, &'b [f32; 4]>,
|
||||
H: for<'b> BindUniform<C, &'b [f32; 16]>
|
||||
pub trait BindSemantics<H = NoUniformBinder, C = Option<()>>
|
||||
where
|
||||
H: BindUniform<C, f32>,
|
||||
H: BindUniform<C, u32>,
|
||||
H: BindUniform<C, i32>,
|
||||
H: for<'b> BindUniform<C, &'b [f32; 4]>,
|
||||
H: for<'b> BindUniform<C, &'b [f32; 16]>,
|
||||
{
|
||||
/// The type of the input texture used for semantic binding.
|
||||
type InputTexture: TextureInput;
|
||||
|
@ -68,14 +70,13 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
/// The type of uniform offsets to use.
|
||||
type UniformOffset: ContextOffset<H, C>;
|
||||
|
||||
|
||||
/// Bind a texture to the input descriptor set
|
||||
fn bind_texture<'a>(
|
||||
descriptors: &mut Self::DescriptorSet<'a>,
|
||||
samplers: &Self::SamplerSet,
|
||||
binding: &TextureBinding,
|
||||
texture: &Self::InputTexture,
|
||||
device: &Self::DeviceContext
|
||||
device: &Self::DeviceContext,
|
||||
);
|
||||
|
||||
#[clippy::allow(too_many_arguments)]
|
||||
|
@ -100,8 +101,7 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
lookup_textures: impl Iterator<Item = (usize, impl AsRef<Self::InputTexture>)>,
|
||||
parameter_defaults: &[ShaderParameter],
|
||||
runtime_parameters: &HashMap<String, f32, impl BuildHasher>,
|
||||
)
|
||||
{
|
||||
) {
|
||||
// Bind MVP
|
||||
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::MVP.into()) {
|
||||
uniform_storage.bind_mat4(offset.offset(), mvp, offset.context());
|
||||
|
@ -113,90 +113,53 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
}
|
||||
|
||||
// bind FinalViewportSize
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&UniqueSemantics::FinalViewport.into())
|
||||
{
|
||||
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::FinalViewport.into()) {
|
||||
uniform_storage.bind_vec4(offset.offset(), viewport_size, offset.context());
|
||||
}
|
||||
|
||||
// bind FrameCount
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&UniqueSemantics::FrameCount.into())
|
||||
{
|
||||
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::FrameCount.into()) {
|
||||
uniform_storage.bind_scalar(offset.offset(), frame_count, offset.context());
|
||||
}
|
||||
|
||||
// bind FrameDirection
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&UniqueSemantics::FrameDirection.into())
|
||||
{
|
||||
uniform_storage
|
||||
.bind_scalar(offset.offset(), frame_direction, offset.context());
|
||||
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::FrameDirection.into()) {
|
||||
uniform_storage.bind_scalar(offset.offset(), frame_direction, offset.context());
|
||||
}
|
||||
|
||||
// bind Original sampler
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::Original.semantics(0))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
original,
|
||||
device
|
||||
);
|
||||
if let Some(binding) = texture_meta.get(&TextureSemantics::Original.semantics(0)) {
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, original, device);
|
||||
}
|
||||
|
||||
// bind OriginalSize
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&TextureSemantics::Original.semantics(0).into())
|
||||
if let Some(offset) = uniform_bindings.get(&TextureSemantics::Original.semantics(0).into())
|
||||
{
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), original.size(), offset.context());
|
||||
uniform_storage.bind_vec4(offset.offset(), original.size(), offset.context());
|
||||
}
|
||||
|
||||
// bind Source sampler
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::Source.semantics(0))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
source,
|
||||
device
|
||||
);
|
||||
if let Some(binding) = texture_meta.get(&TextureSemantics::Source.semantics(0)) {
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, source, device);
|
||||
}
|
||||
|
||||
// bind SourcelSize
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&TextureSemantics::Source.semantics(0).into())
|
||||
{
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), source.size(), offset.context());
|
||||
if let Some(offset) = uniform_bindings.get(&TextureSemantics::Source.semantics(0).into()) {
|
||||
uniform_storage.bind_vec4(offset.offset(), source.size(), offset.context());
|
||||
}
|
||||
|
||||
// OriginalHistory0 aliases OriginalHistory
|
||||
|
||||
// bind OriginalHistory0 sampler
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::OriginalHistory.semantics(0))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
original,
|
||||
device
|
||||
);
|
||||
if let Some(binding) = texture_meta.get(&TextureSemantics::OriginalHistory.semantics(0)) {
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, original, device);
|
||||
}
|
||||
|
||||
// bind OriginalHistory0Size
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&TextureSemantics::OriginalHistory.semantics(0).into())
|
||||
if let Some(offset) =
|
||||
uniform_bindings.get(&TextureSemantics::OriginalHistory.semantics(0).into())
|
||||
{
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), original.size(), offset.context());
|
||||
uniform_storage.bind_vec4(offset.offset(), original.size(), offset.context());
|
||||
}
|
||||
|
||||
// bind OriginalHistory1-..
|
||||
|
@ -207,16 +170,10 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
|
||||
let history = history.as_ref();
|
||||
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::OriginalHistory.semantics(index + 1))
|
||||
if let Some(binding) =
|
||||
texture_meta.get(&TextureSemantics::OriginalHistory.semantics(index + 1))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
history,
|
||||
device
|
||||
);
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, history, device);
|
||||
}
|
||||
|
||||
if let Some(offset) = uniform_bindings.get(
|
||||
|
@ -224,8 +181,7 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
.semantics(index + 1)
|
||||
.into(),
|
||||
) {
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), history.size(), offset.context());
|
||||
uniform_storage.bind_vec4(offset.offset(), history.size(), offset.context());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,25 +195,15 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
|
||||
let output = output.as_ref();
|
||||
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::PassOutput.semantics(index))
|
||||
if let Some(binding) = texture_meta.get(&TextureSemantics::PassOutput.semantics(index))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
output,
|
||||
device
|
||||
);
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, output, device);
|
||||
}
|
||||
|
||||
if let Some(offset) = uniform_bindings.get(
|
||||
&TextureSemantics::PassOutput
|
||||
.semantics(index)
|
||||
.into(),
|
||||
) {
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), output.size(), offset.context());
|
||||
if let Some(offset) =
|
||||
uniform_bindings.get(&TextureSemantics::PassOutput.semantics(index).into())
|
||||
{
|
||||
uniform_storage.bind_vec4(offset.offset(), output.size(), offset.context());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,31 +215,21 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
|
||||
let feedback = output.as_ref();
|
||||
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::PassFeedback.semantics(index))
|
||||
if let Some(binding) =
|
||||
texture_meta.get(&TextureSemantics::PassFeedback.semantics(index))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
feedback,
|
||||
device
|
||||
);
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, feedback, device);
|
||||
}
|
||||
|
||||
if let Some(offset) = uniform_bindings.get(
|
||||
&TextureSemantics::PassFeedback
|
||||
.semantics(index)
|
||||
.into(),
|
||||
) {
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), feedback.size(), offset.context());
|
||||
if let Some(offset) =
|
||||
uniform_bindings.get(&TextureSemantics::PassFeedback.semantics(index).into())
|
||||
{
|
||||
uniform_storage.bind_vec4(offset.offset(), feedback.size(), offset.context());
|
||||
}
|
||||
}
|
||||
|
||||
// bind User parameters
|
||||
for (id, offset) in
|
||||
uniform_bindings
|
||||
for (id, offset) in uniform_bindings
|
||||
.iter()
|
||||
.filter_map(|(binding, value)| match binding {
|
||||
UniformBinding::Parameter(id) => Some((id, value)),
|
||||
|
@ -302,7 +238,8 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
{
|
||||
let id = id.as_str();
|
||||
|
||||
let default = parameter_defaults.iter()
|
||||
let default = parameter_defaults
|
||||
.iter()
|
||||
.find(|&p| p.id == id)
|
||||
.map(|f| f.initial)
|
||||
.unwrap_or(0f32);
|
||||
|
@ -315,24 +252,15 @@ pub trait BindSemantics<H=NoUniformBinder, C=Option<()>>
|
|||
// bind luts
|
||||
for (index, lut) in lookup_textures {
|
||||
let lut = lut.as_ref();
|
||||
if let Some(binding) = texture_meta
|
||||
.get(&TextureSemantics::User.semantics(index))
|
||||
{
|
||||
Self::bind_texture(
|
||||
descriptor_set,
|
||||
sampler_set,
|
||||
binding,
|
||||
lut,
|
||||
device
|
||||
);
|
||||
if let Some(binding) = texture_meta.get(&TextureSemantics::User.semantics(index)) {
|
||||
Self::bind_texture(descriptor_set, sampler_set, binding, lut, device);
|
||||
}
|
||||
|
||||
if let Some(offset) = uniform_bindings
|
||||
.get(&TextureSemantics::User.semantics(index).into())
|
||||
if let Some(offset) =
|
||||
uniform_bindings.get(&TextureSemantics::User.semantics(index).into())
|
||||
{
|
||||
uniform_storage
|
||||
.bind_vec4(offset.offset(), lut.size(), offset.context());
|
||||
uniform_storage.bind_vec4(offset.offset(), lut.size(), offset.context());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,9 +69,9 @@ pub mod preprocess {
|
|||
pub mod reflect {
|
||||
/// Supported shader compiler targets.
|
||||
pub mod targets {
|
||||
pub use librashader_reflect::back::targets::SPIRV;
|
||||
pub use librashader_reflect::back::targets::GLSL;
|
||||
pub use librashader_reflect::back::targets::HLSL;
|
||||
pub use librashader_reflect::back::targets::SPIRV;
|
||||
}
|
||||
|
||||
pub use librashader_reflect::error::*;
|
||||
|
@ -94,8 +94,8 @@ pub mod reflect {
|
|||
/// Shader runtimes to execute a filter chain on a GPU surface.
|
||||
#[cfg(feature = "runtime")]
|
||||
pub mod runtime {
|
||||
pub use librashader_common::{Size, Viewport};
|
||||
pub use librashader_runtime::parameters::FilterChainParameters;
|
||||
pub use librashader_common::{Viewport, Size};
|
||||
|
||||
#[cfg(feature = "gl")]
|
||||
/// Shader runtime for OpenGL 3.3+.
|
||||
|
@ -104,13 +104,9 @@ pub mod runtime {
|
|||
/// initialized with [`gl::load_with`](https://docs.rs/gl/0.14.0/gl/fn.load_with.html).
|
||||
pub mod gl {
|
||||
pub use librashader_runtime_gl::{
|
||||
options::{
|
||||
FilterChainOptionsGL as FilterChainOptions,
|
||||
FrameOptionsGL as FrameOptions,
|
||||
},
|
||||
FilterChainGL as FilterChain,
|
||||
Framebuffer, GLImage,
|
||||
error
|
||||
error,
|
||||
options::{FilterChainOptionsGL as FilterChainOptions, FrameOptionsGL as FrameOptions},
|
||||
FilterChainGL as FilterChain, Framebuffer, GLImage,
|
||||
};
|
||||
|
||||
#[doc(hidden)]
|
||||
|
@ -126,13 +122,11 @@ pub mod runtime {
|
|||
/// Shader runtime for Direct3D 11.
|
||||
pub mod d3d11 {
|
||||
pub use librashader_runtime_d3d11::{
|
||||
error,
|
||||
options::{
|
||||
FilterChainOptionsD3D11 as FilterChainOptions,
|
||||
FrameOptionsD3D11 as FrameOptions,
|
||||
FilterChainOptionsD3D11 as FilterChainOptions, FrameOptionsD3D11 as FrameOptions,
|
||||
},
|
||||
FilterChainD3D11 as FilterChain,
|
||||
D3D11InputView, D3D11OutputView,
|
||||
error
|
||||
D3D11InputView, D3D11OutputView, FilterChainD3D11 as FilterChain,
|
||||
};
|
||||
|
||||
#[doc(hidden)]
|
||||
|
@ -148,13 +142,11 @@ pub mod runtime {
|
|||
/// Shader runtime for Vulkan 1.3+.
|
||||
pub mod vk {
|
||||
pub use librashader_runtime_vk::{
|
||||
error,
|
||||
options::{
|
||||
FilterChainOptionsVulkan as FilterChainOptions,
|
||||
FrameOptionsVulkan as FrameOptions,
|
||||
FilterChainOptionsVulkan as FilterChainOptions, FrameOptionsVulkan as FrameOptions,
|
||||
},
|
||||
FilterChainVulkan as FilterChain,
|
||||
VulkanImage, VulkanObjects, VulkanInstance,
|
||||
error
|
||||
FilterChainVulkan as FilterChain, VulkanImage, VulkanInstance, VulkanObjects,
|
||||
};
|
||||
|
||||
#[doc(hidden)]
|
||||
|
|
Loading…
Reference in a new issue