capi: resolve name conflicts due to conflicting struct names in each module
This commit is contained in:
parent
6782f08820
commit
45d03fbfb8
|
@ -7,11 +7,11 @@ pub type libra_shader_preset_t = Option<NonNull<ShaderPreset>>;
|
||||||
pub type libra_error_t = Option<NonNull<LibrashaderError>>;
|
pub type libra_error_t = Option<NonNull<LibrashaderError>>;
|
||||||
|
|
||||||
#[cfg(feature = "runtime-opengl")]
|
#[cfg(feature = "runtime-opengl")]
|
||||||
pub type libra_gl_filter_chain_t = Option<NonNull<librashader::runtime::gl::FilterChain>>;
|
pub type libra_gl_filter_chain_t = Option<NonNull<librashader::runtime::gl::capi::FilterChainGL>>;
|
||||||
|
|
||||||
#[cfg(feature = "runtime-d3d11")]
|
#[cfg(feature = "runtime-d3d11")]
|
||||||
pub type libra_d3d11_filter_chain_t =
|
pub type libra_d3d11_filter_chain_t =
|
||||||
Option<NonNull<librashader::runtime::d3d11::FilterChain>>;
|
Option<NonNull<librashader::runtime::d3d11::capi::FilterChainD3D11>>;
|
||||||
|
|
||||||
/// Parameters for the output viewport.
|
/// Parameters for the output viewport.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -11,8 +11,8 @@ use windows::Win32::Graphics::Direct3D11::{
|
||||||
ID3D11Device, ID3D11RenderTargetView, ID3D11ShaderResourceView,
|
ID3D11Device, ID3D11RenderTargetView, ID3D11ShaderResourceView,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use librashader::runtime::d3d11::options::FilterChainOptions;
|
pub use librashader::runtime::d3d11::capi::options::FilterChainOptionsD3D11;
|
||||||
pub use librashader::runtime::d3d11::options::FrameOptions;
|
pub use librashader::runtime::d3d11::capi::options::FrameOptionsD3D11;
|
||||||
|
|
||||||
use librashader::runtime::{Size, Viewport};
|
use librashader::runtime::{Size, Viewport};
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ extern_fn! {
|
||||||
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
|
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
|
||||||
fn libra_d3d11_filter_chain_create(
|
fn libra_d3d11_filter_chain_create(
|
||||||
preset: *mut libra_shader_preset_t,
|
preset: *mut libra_shader_preset_t,
|
||||||
options: *const FilterChainOptions,
|
options: *const FilterChainOptionsD3D11,
|
||||||
device: *const ID3D11Device,
|
device: *const ID3D11Device,
|
||||||
out: *mut MaybeUninit<libra_d3d11_filter_chain_t>
|
out: *mut MaybeUninit<libra_d3d11_filter_chain_t>
|
||||||
) {
|
) {
|
||||||
|
@ -71,7 +71,7 @@ extern_fn! {
|
||||||
Some(unsafe { &*options })
|
Some(unsafe { &*options })
|
||||||
};
|
};
|
||||||
|
|
||||||
let chain = librashader::runtime::d3d11::FilterChain::load_from_preset(
|
let chain = librashader::runtime::d3d11::capi::FilterChainD3D11::load_from_preset(
|
||||||
unsafe { &*device },
|
unsafe { &*device },
|
||||||
*preset,
|
*preset,
|
||||||
options,
|
options,
|
||||||
|
@ -102,7 +102,7 @@ extern_fn! {
|
||||||
viewport: libra_viewport_t,
|
viewport: libra_viewport_t,
|
||||||
out: *const ID3D11RenderTargetView,
|
out: *const ID3D11RenderTargetView,
|
||||||
mvp: *const f32,
|
mvp: *const f32,
|
||||||
opt: *const FrameOptions
|
opt: *const FrameOptionsD3D11
|
||||||
) mut |chain| {
|
) mut |chain| {
|
||||||
assert_some_ptr!(mut chain);
|
assert_some_ptr!(mut chain);
|
||||||
assert_non_null!(out);
|
assert_non_null!(out);
|
||||||
|
|
|
@ -9,8 +9,8 @@ use std::mem::MaybeUninit;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
pub use librashader::runtime::gl::options::FilterChainOptions;
|
pub use librashader::runtime::gl::capi::options::FilterChainOptionsGL;
|
||||||
pub use librashader::runtime::gl::options::FrameOptions;
|
pub use librashader::runtime::gl::capi::options::FrameOptionsGL;
|
||||||
use librashader::runtime::{Size, Viewport};
|
use librashader::runtime::{Size, Viewport};
|
||||||
|
|
||||||
/// A GL function loader that librashader needs to be initialized with.
|
/// A GL function loader that librashader needs to be initialized with.
|
||||||
|
@ -81,7 +81,7 @@ extern_fn! {
|
||||||
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
|
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
|
||||||
fn libra_gl_filter_chain_create(
|
fn libra_gl_filter_chain_create(
|
||||||
preset: *mut libra_shader_preset_t,
|
preset: *mut libra_shader_preset_t,
|
||||||
options: *const FilterChainOptions,
|
options: *const FilterChainOptionsGL,
|
||||||
out: *mut MaybeUninit<libra_gl_filter_chain_t>
|
out: *mut MaybeUninit<libra_gl_filter_chain_t>
|
||||||
) {
|
) {
|
||||||
assert_non_null!(preset);
|
assert_non_null!(preset);
|
||||||
|
@ -97,7 +97,7 @@ extern_fn! {
|
||||||
Some(unsafe { &*options })
|
Some(unsafe { &*options })
|
||||||
};
|
};
|
||||||
|
|
||||||
let chain = librashader::runtime::gl::FilterChain::load_from_preset(*preset, options)?;
|
let chain = librashader::runtime::gl::capi::FilterChainGL::load_from_preset(*preset, options)?;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
out.write(MaybeUninit::new(NonNull::new(Box::into_raw(Box::new(
|
out.write(MaybeUninit::new(NonNull::new(Box::into_raw(Box::new(
|
||||||
|
@ -124,7 +124,7 @@ extern_fn! {
|
||||||
viewport: libra_viewport_t,
|
viewport: libra_viewport_t,
|
||||||
out: libra_draw_framebuffer_gl_t,
|
out: libra_draw_framebuffer_gl_t,
|
||||||
mvp: *const f32,
|
mvp: *const f32,
|
||||||
opt: *const FrameOptions
|
opt: *const FrameOptionsGL
|
||||||
) mut |chain| {
|
) mut |chain| {
|
||||||
assert_some_ptr!(mut chain);
|
assert_some_ptr!(mut chain);
|
||||||
let image: GLImage = image.into();
|
let image: GLImage = image.into();
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::path::Path;
|
||||||
use crate::error::FilterChainError;
|
use crate::error::FilterChainError;
|
||||||
use crate::filter_pass::{ConstantBufferBinding, FilterPass};
|
use crate::filter_pass::{ConstantBufferBinding, FilterPass};
|
||||||
use crate::framebuffer::OwnedFramebuffer;
|
use crate::framebuffer::OwnedFramebuffer;
|
||||||
use crate::options::{FilterChainOptions, FrameOptions};
|
use crate::options::{FilterChainOptionsD3D11, FrameOptionsD3D11};
|
||||||
use crate::quad_render::DrawQuad;
|
use crate::quad_render::DrawQuad;
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
|
@ -47,7 +47,7 @@ type ShaderPassMeta = (
|
||||||
);
|
);
|
||||||
|
|
||||||
/// A Direct3D 11 filter chain.
|
/// A Direct3D 11 filter chain.
|
||||||
pub struct FilterChain {
|
pub struct FilterChainD3D11 {
|
||||||
pub(crate) common: FilterCommon,
|
pub(crate) common: FilterCommon,
|
||||||
pub(crate) passes: Vec<FilterPass>,
|
pub(crate) passes: Vec<FilterPass>,
|
||||||
pub(crate) output_framebuffers: Box<[OwnedFramebuffer]>,
|
pub(crate) output_framebuffers: Box<[OwnedFramebuffer]>,
|
||||||
|
@ -74,13 +74,13 @@ pub(crate) struct FilterCommon {
|
||||||
pub disable_mipmaps: bool,
|
pub disable_mipmaps: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FilterChain {
|
impl FilterChainD3D11 {
|
||||||
/// Load the shader preset at the given path into a filter chain.
|
/// Load the shader preset at the given path into a filter chain.
|
||||||
pub fn load_from_path(
|
pub fn load_from_path(
|
||||||
device: &ID3D11Device,
|
device: &ID3D11Device,
|
||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsD3D11>,
|
||||||
) -> error::Result<FilterChain> {
|
) -> error::Result<FilterChainD3D11> {
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse(path)?;
|
||||||
Self::load_from_preset(device, preset, options)
|
Self::load_from_preset(device, preset, options)
|
||||||
|
@ -90,16 +90,16 @@ impl FilterChain {
|
||||||
pub fn load_from_preset(
|
pub fn load_from_preset(
|
||||||
device: &ID3D11Device,
|
device: &ID3D11Device,
|
||||||
preset: ShaderPreset,
|
preset: ShaderPreset,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsD3D11>,
|
||||||
) -> error::Result<FilterChain> {
|
) -> error::Result<FilterChainD3D11> {
|
||||||
let (passes, semantics) = FilterChain::load_preset(preset.shaders, &preset.textures)?;
|
let (passes, semantics) = FilterChainD3D11::load_preset(preset.shaders, &preset.textures)?;
|
||||||
|
|
||||||
let use_deferred_context = options.map(|f| f.use_deferred_context).unwrap_or(false);
|
let use_deferred_context = options.map(|f| f.use_deferred_context).unwrap_or(false);
|
||||||
|
|
||||||
let samplers = SamplerSet::new(device)?;
|
let samplers = SamplerSet::new(device)?;
|
||||||
|
|
||||||
// initialize passes
|
// initialize passes
|
||||||
let filters = FilterChain::init_passes(device, passes, &semantics)?;
|
let filters = FilterChainD3D11::init_passes(device, passes, &semantics)?;
|
||||||
|
|
||||||
let mut immediate_context = None;
|
let mut immediate_context = None;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -154,15 +154,15 @@ impl FilterChain {
|
||||||
feedback_textures.resize_with(filters.len(), || None);
|
feedback_textures.resize_with(filters.len(), || None);
|
||||||
|
|
||||||
// load luts
|
// load luts
|
||||||
let luts = FilterChain::load_luts(device, ¤t_context, &preset.textures)?;
|
let luts = FilterChainD3D11::load_luts(device, ¤t_context, &preset.textures)?;
|
||||||
|
|
||||||
let (history_framebuffers, history_textures) =
|
let (history_framebuffers, history_textures) =
|
||||||
FilterChain::init_history(device, ¤t_context, &filters)?;
|
FilterChainD3D11::init_history(device, ¤t_context, &filters)?;
|
||||||
|
|
||||||
let draw_quad = DrawQuad::new(device, ¤t_context)?;
|
let draw_quad = DrawQuad::new(device, ¤t_context)?;
|
||||||
|
|
||||||
// todo: make vbo: d3d11.c 1376
|
// todo: make vbo: d3d11.c 1376
|
||||||
Ok(FilterChain {
|
Ok(FilterChainD3D11 {
|
||||||
passes: filters,
|
passes: filters,
|
||||||
output_framebuffers: output_framebuffers.into_boxed_slice(),
|
output_framebuffers: output_framebuffers.into_boxed_slice(),
|
||||||
feedback_framebuffers: feedback_framebuffers.into_boxed_slice(),
|
feedback_framebuffers: feedback_framebuffers.into_boxed_slice(),
|
||||||
|
@ -194,7 +194,7 @@ impl FilterChain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FilterChain {
|
impl FilterChainD3D11 {
|
||||||
fn create_constant_buffer(device: &ID3D11Device, size: u32) -> error::Result<ID3D11Buffer> {
|
fn create_constant_buffer(device: &ID3D11Device, size: u32) -> error::Result<ID3D11Buffer> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let buffer = device.CreateBuffer(
|
let buffer = device.CreateBuffer(
|
||||||
|
@ -247,7 +247,7 @@ impl FilterChain {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let ubo_cbuffer = if let Some(ubo) = &reflection.ubo && ubo.size != 0 {
|
let ubo_cbuffer = if let Some(ubo) = &reflection.ubo && ubo.size != 0 {
|
||||||
let buffer = FilterChain::create_constant_buffer(device, ubo.size)?;
|
let buffer = FilterChainD3D11::create_constant_buffer(device, ubo.size)?;
|
||||||
Some(ConstantBufferBinding {
|
Some(ConstantBufferBinding {
|
||||||
binding: ubo.binding,
|
binding: ubo.binding,
|
||||||
size: ubo.size,
|
size: ubo.size,
|
||||||
|
@ -259,7 +259,7 @@ impl FilterChain {
|
||||||
};
|
};
|
||||||
|
|
||||||
let push_cbuffer = if let Some(push) = &reflection.push_constant && push.size != 0 {
|
let push_cbuffer = if let Some(push) = &reflection.push_constant && push.size != 0 {
|
||||||
let buffer = FilterChain::create_constant_buffer(device, push.size)?;
|
let buffer = FilterChainD3D11::create_constant_buffer(device, push.size)?;
|
||||||
Some(ConstantBufferBinding {
|
Some(ConstantBufferBinding {
|
||||||
binding: if ubo_cbuffer.is_some() { 1 } else { 0 },
|
binding: if ubo_cbuffer.is_some() { 1 } else { 0 },
|
||||||
size: push.size,
|
size: push.size,
|
||||||
|
@ -468,7 +468,7 @@ impl FilterChain {
|
||||||
input: D3D11InputView,
|
input: D3D11InputView,
|
||||||
viewport: &Viewport<D3D11OutputView>,
|
viewport: &Viewport<D3D11OutputView>,
|
||||||
frame_count: usize,
|
frame_count: usize,
|
||||||
options: Option<&FrameOptions>,
|
options: Option<&FrameOptionsD3D11>,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
let passes = &mut self.passes[0..self.common.config.passes_enabled];
|
let passes = &mut self.passes[0..self.common.config.passes_enabled];
|
||||||
if let Some(options) = options {
|
if let Some(options) = options {
|
||||||
|
|
|
@ -225,9 +225,9 @@ pub mod d3d11_hello_triangle {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::filter_chain::FilterChain;
|
use crate::filter_chain::FilterChainD3D11;
|
||||||
|
|
||||||
use crate::options::FilterChainOptions;
|
use crate::options::FilterChainOptionsD3D11;
|
||||||
use crate::texture::D3D11InputView;
|
use crate::texture::D3D11InputView;
|
||||||
use crate::viewport::Viewport;
|
use crate::viewport::Viewport;
|
||||||
use librashader_common::{Size, Viewport};
|
use librashader_common::{Size, Viewport};
|
||||||
|
@ -240,7 +240,7 @@ pub mod d3d11_hello_triangle {
|
||||||
pub device: ID3D11Device,
|
pub device: ID3D11Device,
|
||||||
pub context: ID3D11DeviceContext,
|
pub context: ID3D11DeviceContext,
|
||||||
pub resources: Option<Resources>,
|
pub resources: Option<Resources>,
|
||||||
pub filter: FilterChain,
|
pub filter: FilterChainD3D11,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Resources {
|
pub struct Resources {
|
||||||
|
@ -267,10 +267,10 @@ pub mod d3d11_hello_triangle {
|
||||||
impl Sample {
|
impl Sample {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
filter: impl AsRef<Path>,
|
filter: impl AsRef<Path>,
|
||||||
filter_options: Option<&FilterChainOptions>,
|
filter_options: Option<&FilterChainOptionsD3D11>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let (dxgi_factory, device, context) = create_device()?;
|
let (dxgi_factory, device, context) = create_device()?;
|
||||||
let filter = FilterChain::load_from_path(&device, filter, filter_options).unwrap();
|
let filter = FilterChainD3D11::load_from_path(&device, filter, filter_options).unwrap();
|
||||||
Ok(Sample {
|
Ok(Sample {
|
||||||
filter,
|
filter,
|
||||||
dxgi_factory,
|
dxgi_factory,
|
||||||
|
|
|
@ -16,21 +16,21 @@ mod samplers;
|
||||||
mod texture;
|
mod texture;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use filter_chain::FilterChain;
|
pub use filter_chain::FilterChainD3D11;
|
||||||
pub use texture::D3D11InputView;
|
pub use texture::D3D11InputView;
|
||||||
pub use texture::D3D11OutputView;
|
pub use texture::D3D11OutputView;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::options::FilterChainOptions;
|
use crate::options::FilterChainOptionsD3D11;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn triangle_d3d11() {
|
fn triangle_d3d11() {
|
||||||
let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
|
let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
|
||||||
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
||||||
// "../test/basic.slangp",
|
// "../test/basic.slangp",
|
||||||
Some(&FilterChainOptions {
|
Some(&FilterChainOptionsD3D11 {
|
||||||
use_deferred_context: false,
|
use_deferred_context: false,
|
||||||
force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/// Options for each Direct3D11 shader frame.
|
/// Options for each Direct3D11 shader frame.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FrameOptions {
|
pub struct FrameOptionsD3D11 {
|
||||||
/// Whether or not to clear the history buffers.
|
/// Whether or not to clear the history buffers.
|
||||||
pub clear_history: bool,
|
pub clear_history: bool,
|
||||||
/// The direction of the frame. 1 should be vertical.
|
/// The direction of the frame. 1 should be vertical.
|
||||||
|
@ -13,7 +13,7 @@ pub struct FrameOptions {
|
||||||
/// Options for Direct3D11 filter chain creation.
|
/// Options for Direct3D11 filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FilterChainOptions {
|
pub struct FilterChainOptionsD3D11 {
|
||||||
/// Use a deferred context to record shader rendering state.
|
/// Use a deferred context to record shader rendering state.
|
||||||
///
|
///
|
||||||
/// The deferred context will be executed on the immediate context
|
/// The deferred context will be executed on the immediate context
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::FilterChain;
|
use crate::FilterChainD3D11;
|
||||||
use librashader_runtime::parameters::FilterChainParameters;
|
use librashader_runtime::parameters::FilterChainParameters;
|
||||||
use std::collections::hash_map::Iter;
|
use std::collections::hash_map::Iter;
|
||||||
|
|
||||||
impl FilterChainParameters for FilterChain {
|
impl FilterChainParameters for FilterChainD3D11 {
|
||||||
fn get_enabled_pass_count(&self) -> usize {
|
fn get_enabled_pass_count(&self) -> usize {
|
||||||
self.common.config.passes_enabled
|
self.common.config.passes_enabled
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,14 @@ use crate::binding::{GlUniformStorage, UniformLocation, VariableLocation};
|
||||||
use crate::error::FilterChainError;
|
use crate::error::FilterChainError;
|
||||||
use crate::filter_pass::FilterPass;
|
use crate::filter_pass::FilterPass;
|
||||||
use crate::gl::{DrawQuad, Framebuffer, FramebufferInterface, GLInterface, LoadLut, UboRing};
|
use crate::gl::{DrawQuad, Framebuffer, FramebufferInterface, GLInterface, LoadLut, UboRing};
|
||||||
use crate::options::{FilterChainOptions, FrameOptions};
|
use crate::options::{FilterChainOptionsGL, FrameOptionsGL};
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::Texture;
|
use crate::texture::Texture;
|
||||||
use crate::util::{gl_get_version, gl_u16_to_version};
|
use crate::util::{gl_get_version, gl_u16_to_version};
|
||||||
use crate::{error, util, GLImage};
|
use crate::{error, util, GLImage};
|
||||||
use gl::types::{GLenum, GLint, GLuint};
|
use gl::types::{GLint, GLuint};
|
||||||
use librashader_common::{FilterMode, Size, Viewport, WrapMode};
|
use librashader_common::{FilterMode, Viewport, WrapMode};
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||||
use librashader_reflect::back::cross::{CrossGlslContext, GlslVersion};
|
use librashader_reflect::back::cross::{CrossGlslContext, GlslVersion};
|
||||||
|
@ -91,7 +91,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
||||||
pub(crate) fn load_from_preset(
|
pub(crate) fn load_from_preset(
|
||||||
preset: ShaderPreset,
|
preset: ShaderPreset,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsGL>,
|
||||||
) -> error::Result<Self> {
|
) -> error::Result<Self> {
|
||||||
let (passes, semantics) = Self::load_preset(preset.shaders, &preset.textures)?;
|
let (passes, semantics) = Self::load_preset(preset.shaders, &preset.textures)?;
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
count: usize,
|
count: usize,
|
||||||
viewport: &Viewport<&Framebuffer>,
|
viewport: &Viewport<&Framebuffer>,
|
||||||
input: &GLImage,
|
input: &GLImage,
|
||||||
options: Option<&FrameOptions>,
|
options: Option<&FrameOptionsGL>,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
// 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];
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use gl::types::{GLenum, GLuint};
|
|
||||||
use std::panic::catch_unwind;
|
use std::panic::catch_unwind;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::error::{FilterChainError, Result};
|
use crate::error::{FilterChainError, Result};
|
||||||
use crate::filter_chain::filter_impl::FilterChainImpl;
|
use crate::filter_chain::filter_impl::FilterChainImpl;
|
||||||
use crate::filter_chain::inner::FilterChainDispatch;
|
use crate::filter_chain::inner::FilterChainDispatch;
|
||||||
use crate::options::{FilterChainOptions, FrameOptions};
|
use crate::options::{FilterChainOptionsGL, FrameOptionsGL};
|
||||||
use crate::{Framebuffer, GLImage};
|
use crate::{Framebuffer, GLImage};
|
||||||
use librashader_presets::ShaderPreset;
|
use librashader_presets::ShaderPreset;
|
||||||
|
|
||||||
|
@ -14,18 +14,18 @@ mod inner;
|
||||||
mod parameters;
|
mod parameters;
|
||||||
|
|
||||||
pub(crate) use filter_impl::FilterCommon;
|
pub(crate) use filter_impl::FilterCommon;
|
||||||
use librashader_common::{Size, Viewport};
|
use librashader_common::{Viewport};
|
||||||
|
|
||||||
/// An OpenGL filter chain.
|
/// An OpenGL filter chain.
|
||||||
pub struct FilterChain {
|
pub struct FilterChainGL {
|
||||||
pub(in crate::filter_chain) filter: FilterChainDispatch,
|
pub(in crate::filter_chain) filter: FilterChainDispatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FilterChain {
|
impl FilterChainGL {
|
||||||
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
||||||
pub fn load_from_preset(
|
pub fn load_from_preset(
|
||||||
preset: ShaderPreset,
|
preset: ShaderPreset,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsGL>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let result = catch_unwind(|| {
|
let result = catch_unwind(|| {
|
||||||
if let Some(options) = options && options.use_dsa {
|
if let Some(options) = options && options.use_dsa {
|
||||||
|
@ -48,7 +48,7 @@ impl FilterChain {
|
||||||
/// Load the shader preset at the given path into a filter chain.
|
/// Load the shader preset at the given path into a filter chain.
|
||||||
pub fn load_from_path(
|
pub fn load_from_path(
|
||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsGL>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse(path)?;
|
||||||
|
@ -64,7 +64,7 @@ impl FilterChain {
|
||||||
input: &GLImage,
|
input: &GLImage,
|
||||||
viewport: &Viewport<&Framebuffer>,
|
viewport: &Viewport<&Framebuffer>,
|
||||||
frame_count: usize,
|
frame_count: usize,
|
||||||
options: Option<&FrameOptions>,
|
options: Option<&FrameOptionsGL>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match &mut self.filter {
|
match &mut self.filter {
|
||||||
FilterChainDispatch::DirectStateAccess(p) => {
|
FilterChainDispatch::DirectStateAccess(p) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::filter_chain::filter_impl::FilterChainImpl;
|
use crate::filter_chain::filter_impl::FilterChainImpl;
|
||||||
use crate::filter_chain::inner::FilterChainDispatch;
|
use crate::filter_chain::inner::FilterChainDispatch;
|
||||||
use crate::gl::GLInterface;
|
use crate::gl::GLInterface;
|
||||||
use crate::FilterChain;
|
use crate::FilterChainGL;
|
||||||
use librashader_runtime::parameters::FilterChainParameters;
|
use librashader_runtime::parameters::FilterChainParameters;
|
||||||
use std::collections::hash_map::Iter;
|
use std::collections::hash_map::Iter;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ impl AsMut<dyn FilterChainParameters + 'static> for FilterChainDispatch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FilterChainParameters for FilterChain {
|
impl FilterChainParameters for FilterChainGL {
|
||||||
fn get_enabled_pass_count(&self) -> usize {
|
fn get_enabled_pass_count(&self) -> usize {
|
||||||
self.filter.as_ref().get_enabled_pass_count()
|
self.filter.as_ref().get_enabled_pass_count()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use glfw::{Context, Glfw, Window, WindowEvent};
|
||||||
use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
|
use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
|
||||||
use librashader_common::Size;
|
use librashader_common::Size;
|
||||||
|
|
||||||
use crate::filter_chain::FilterChain;
|
use crate::filter_chain::FilterChainGL;
|
||||||
use crate::framebuffer::GLImage;
|
use crate::framebuffer::GLImage;
|
||||||
use crate::gl::gl3::CompatibilityGL;
|
use crate::gl::gl3::CompatibilityGL;
|
||||||
use crate::gl::{FramebufferInterface, GLInterface};
|
use crate::gl::{FramebufferInterface, GLInterface};
|
||||||
|
@ -268,7 +268,7 @@ pub fn do_loop(
|
||||||
events: Receiver<(f64, WindowEvent)>,
|
events: Receiver<(f64, WindowEvent)>,
|
||||||
triangle_program: GLuint,
|
triangle_program: GLuint,
|
||||||
triangle_vao: GLuint,
|
triangle_vao: GLuint,
|
||||||
filter: &mut FilterChain,
|
filter: &mut FilterChainGL,
|
||||||
) {
|
) {
|
||||||
let mut framecount = 0;
|
let mut framecount = 0;
|
||||||
let mut rendered_framebuffer = 0;
|
let mut rendered_framebuffer = 0;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use glfw::{Context, Glfw, Window, WindowEvent};
|
||||||
use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
|
use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
|
||||||
use librashader_common::Size;
|
use librashader_common::Size;
|
||||||
|
|
||||||
use crate::filter_chain::FilterChain;
|
use crate::filter_chain::FilterChainGL;
|
||||||
use crate::framebuffer::GLImage;
|
use crate::framebuffer::GLImage;
|
||||||
use crate::gl::gl46::DirectStateAccessGL;
|
use crate::gl::gl46::DirectStateAccessGL;
|
||||||
use crate::gl::{FramebufferInterface, GLInterface};
|
use crate::gl::{FramebufferInterface, GLInterface};
|
||||||
|
@ -259,7 +259,7 @@ pub fn do_loop(
|
||||||
events: Receiver<(f64, WindowEvent)>,
|
events: Receiver<(f64, WindowEvent)>,
|
||||||
triangle_program: GLuint,
|
triangle_program: GLuint,
|
||||||
triangle_vao: GLuint,
|
triangle_vao: GLuint,
|
||||||
filter: &mut FilterChain,
|
filter: &mut FilterChainGL,
|
||||||
) {
|
) {
|
||||||
let mut framecount = 0;
|
let mut framecount = 0;
|
||||||
let mut rendered_framebuffer = 0;
|
let mut rendered_framebuffer = 0;
|
||||||
|
|
|
@ -17,21 +17,21 @@ pub mod error;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
|
|
||||||
pub use crate::gl::Framebuffer;
|
pub use crate::gl::Framebuffer;
|
||||||
pub use filter_chain::FilterChain;
|
pub use filter_chain::FilterChainGL;
|
||||||
pub use framebuffer::GLImage;
|
pub use framebuffer::GLImage;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::filter_chain::FilterChain;
|
use crate::filter_chain::FilterChainGL;
|
||||||
use crate::options::FilterChainOptions;
|
use crate::options::FilterChainOptionsGL;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn triangle_gl() {
|
fn triangle_gl() {
|
||||||
let (glfw, window, events, shader, vao) = gl::gl3::hello_triangle::setup();
|
let (glfw, window, events, shader, vao) = gl::gl3::hello_triangle::setup();
|
||||||
let mut filter = FilterChain::load_from_path(
|
let mut filter = FilterChainGL::load_from_path(
|
||||||
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
||||||
Some(&FilterChainOptions {
|
Some(&FilterChainOptionsGL {
|
||||||
gl_version: 0,
|
gl_version: 0,
|
||||||
use_dsa: false,
|
use_dsa: false,
|
||||||
force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
|
@ -45,10 +45,10 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn triangle_gl46() {
|
fn triangle_gl46() {
|
||||||
let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup();
|
let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup();
|
||||||
let mut filter = FilterChain::load_from_path(
|
let mut filter = FilterChainGL::load_from_path(
|
||||||
// "../test/slang-shaders/vhs/VHSPro.slangp",
|
// "../test/slang-shaders/vhs/VHSPro.slangp",
|
||||||
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
||||||
Some(&FilterChainOptions {
|
Some(&FilterChainOptionsGL {
|
||||||
gl_version: 0,
|
gl_version: 0,
|
||||||
use_dsa: true,
|
use_dsa: true,
|
||||||
force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/// Options for each OpenGL shader frame.
|
/// Options for each OpenGL shader frame.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FrameOptions {
|
pub struct FrameOptionsGL {
|
||||||
/// Whether or not to clear the history buffers.
|
/// Whether or not to clear the history buffers.
|
||||||
pub clear_history: bool,
|
pub clear_history: bool,
|
||||||
/// The direction of the frame. 1 should be vertical.
|
/// The direction of the frame. 1 should be vertical.
|
||||||
|
@ -13,7 +13,7 @@ pub struct FrameOptions {
|
||||||
/// Options for filter chain creation.
|
/// Options for filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FilterChainOptions {
|
pub struct FilterChainOptionsGL {
|
||||||
/// The GLSL version. Should be at least `330`.
|
/// The GLSL version. Should be at least `330`.
|
||||||
pub gl_version: u16,
|
pub gl_version: u16,
|
||||||
/// Whether or not to use the Direct State Access APIs. Only available on OpenGL 4.5+.
|
/// Whether or not to use the Direct State Access APIs. Only available on OpenGL 4.5+.
|
||||||
|
|
|
@ -26,7 +26,7 @@ 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::options::{FilterChainOptions, FrameOptions};
|
use crate::options::{FilterChainOptionsVulkan, FrameOptionsVulkan};
|
||||||
|
|
||||||
/// A Vulkan device and metadata that is required by the shader runtime.
|
/// A Vulkan device and metadata that is required by the shader runtime.
|
||||||
pub struct VulkanDevice {
|
pub struct VulkanDevice {
|
||||||
|
@ -112,7 +112,7 @@ impl TryFrom<(vk::PhysicalDevice, ash::Instance, ash::Device)> for VulkanDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Vulkan filter chain.
|
/// A Vulkan filter chain.
|
||||||
pub struct FilterChain {
|
pub struct FilterChainVulkan {
|
||||||
pub(crate) common: FilterCommon,
|
pub(crate) common: FilterCommon,
|
||||||
passes: Box<[FilterPass]>,
|
passes: Box<[FilterPass]>,
|
||||||
vulkan: VulkanDevice,
|
vulkan: VulkanDevice,
|
||||||
|
@ -188,13 +188,13 @@ impl Drop for FrameResiduals {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FilterChain {
|
impl FilterChainVulkan {
|
||||||
/// Load the shader preset at the given path into a filter chain.
|
/// Load the shader preset at the given path into a filter chain.
|
||||||
pub fn load_from_path(
|
pub fn load_from_path(
|
||||||
vulkan: impl TryInto<VulkanDevice, Error = FilterChainError>,
|
vulkan: impl TryInto<VulkanDevice, Error = FilterChainError>,
|
||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsVulkan>,
|
||||||
) -> error::Result<FilterChain> {
|
) -> error::Result<FilterChainVulkan> {
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse(path)?;
|
||||||
Self::load_from_preset(vulkan, preset, options)
|
Self::load_from_preset(vulkan, preset, options)
|
||||||
|
@ -204,9 +204,9 @@ impl FilterChain {
|
||||||
pub fn load_from_preset(
|
pub fn load_from_preset(
|
||||||
vulkan: impl TryInto<VulkanDevice, Error = FilterChainError>,
|
vulkan: impl TryInto<VulkanDevice, Error = FilterChainError>,
|
||||||
preset: ShaderPreset,
|
preset: ShaderPreset,
|
||||||
options: Option<&FilterChainOptions>,
|
options: Option<&FilterChainOptionsVulkan>,
|
||||||
) -> error::Result<FilterChain> {
|
) -> error::Result<FilterChainVulkan> {
|
||||||
let (passes, semantics) = FilterChain::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()?;
|
||||||
|
|
||||||
let mut frames_in_flight = options.map(|o| o.frames_in_flight).unwrap_or(0);
|
let mut frames_in_flight = options.map(|o| o.frames_in_flight).unwrap_or(0);
|
||||||
|
@ -217,11 +217,11 @@ impl FilterChain {
|
||||||
// initialize passes
|
// initialize passes
|
||||||
let filters = Self::init_passes(&device, passes, &semantics, frames_in_flight)?;
|
let filters = Self::init_passes(&device, passes, &semantics, frames_in_flight)?;
|
||||||
|
|
||||||
let luts = FilterChain::load_luts(&device, &preset.textures)?;
|
let luts = FilterChainVulkan::load_luts(&device, &preset.textures)?;
|
||||||
let samplers = SamplerSet::new(&device.device)?;
|
let samplers = SamplerSet::new(&device.device)?;
|
||||||
|
|
||||||
let (history_framebuffers, history_textures) =
|
let (history_framebuffers, history_textures) =
|
||||||
FilterChain::init_history(&device, &filters)?;
|
FilterChainVulkan::init_history(&device, &filters)?;
|
||||||
|
|
||||||
let mut output_framebuffers = Vec::new();
|
let mut output_framebuffers = Vec::new();
|
||||||
output_framebuffers.resize_with(filters.len(), || {
|
output_framebuffers.resize_with(filters.len(), || {
|
||||||
|
@ -246,7 +246,7 @@ impl FilterChain {
|
||||||
let mut intermediates = Vec::new();
|
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(FilterChain {
|
Ok(FilterChainVulkan {
|
||||||
common: FilterCommon {
|
common: FilterCommon {
|
||||||
luts,
|
luts,
|
||||||
samplers,
|
samplers,
|
||||||
|
@ -584,7 +584,7 @@ impl FilterChain {
|
||||||
viewport: &Viewport<VulkanImage>,
|
viewport: &Viewport<VulkanImage>,
|
||||||
input: &VulkanImage,
|
input: &VulkanImage,
|
||||||
cmd: vk::CommandBuffer,
|
cmd: vk::CommandBuffer,
|
||||||
options: Option<FrameOptions>,
|
options: Option<FrameOptionsVulkan>,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
let intermediates = &mut self.residuals[count % self.residuals.len()];
|
let intermediates = &mut self.residuals[count % self.residuals.len()];
|
||||||
intermediates.dispose();
|
intermediates.dispose();
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod swapchain;
|
||||||
mod syncobjects;
|
mod syncobjects;
|
||||||
pub mod vulkan_base;
|
pub mod vulkan_base;
|
||||||
|
|
||||||
use crate::filter_chain::{FilterChain, VulkanDevice};
|
use crate::filter_chain::{FilterChainVulkan, VulkanDevice};
|
||||||
use crate::hello_triangle::command::VulkanCommandPool;
|
use crate::hello_triangle::command::VulkanCommandPool;
|
||||||
use crate::hello_triangle::framebuffer::VulkanFramebuffer;
|
use crate::hello_triangle::framebuffer::VulkanFramebuffer;
|
||||||
use crate::hello_triangle::pipeline::VulkanPipeline;
|
use crate::hello_triangle::pipeline::VulkanPipeline;
|
||||||
|
@ -48,7 +48,7 @@ impl VulkanWindow {
|
||||||
event_loop: EventLoop<()>,
|
event_loop: EventLoop<()>,
|
||||||
window: winit::window::Window,
|
window: winit::window::Window,
|
||||||
vulkan: VulkanDraw,
|
vulkan: VulkanDraw,
|
||||||
mut filter_chain: FilterChain,
|
mut filter_chain: FilterChainVulkan,
|
||||||
) {
|
) {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
event_loop.run(move |event, _, control_flow| match event {
|
event_loop.run(move |event, _, control_flow| match event {
|
||||||
|
@ -136,7 +136,7 @@ impl VulkanWindow {
|
||||||
vulkan.base.device.cmd_end_render_pass(cmd);
|
vulkan.base.device.cmd_end_render_pass(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_frame(frame: usize, vulkan: &VulkanDraw, filter: &mut FilterChain) {
|
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]];
|
||||||
|
@ -370,7 +370,7 @@ pub struct VulkanDraw {
|
||||||
pub sync: SyncObjects,
|
pub sync: SyncObjects,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main(vulkan: VulkanBase, filter_chain: FilterChain) {
|
pub fn main(vulkan: VulkanBase, filter_chain: FilterChainVulkan) {
|
||||||
let event_loop = EventLoopBuilder::new()
|
let event_loop = EventLoopBuilder::new()
|
||||||
.with_any_thread(true)
|
.with_any_thread(true)
|
||||||
.with_dpi_aware(true)
|
.with_dpi_aware(true)
|
||||||
|
|
|
@ -19,7 +19,7 @@ mod util;
|
||||||
mod vulkan_primitives;
|
mod vulkan_primitives;
|
||||||
mod vulkan_state;
|
mod vulkan_state;
|
||||||
|
|
||||||
pub use filter_chain::FilterChain;
|
pub use filter_chain::FilterChainVulkan;
|
||||||
pub use filter_chain::VulkanDevice;
|
pub use filter_chain::VulkanDevice;
|
||||||
pub use filter_chain::VulkanInstance;
|
pub use filter_chain::VulkanInstance;
|
||||||
pub use texture::VulkanImage;
|
pub use texture::VulkanImage;
|
||||||
|
@ -30,7 +30,7 @@ pub mod options;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::filter_chain::FilterChain;
|
use crate::filter_chain::FilterChainVulkan;
|
||||||
use crate::hello_triangle::vulkan_base::VulkanBase;
|
use crate::hello_triangle::vulkan_base::VulkanBase;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -38,7 +38,7 @@ mod tests {
|
||||||
let entry = unsafe { ash::Entry::load().unwrap() };
|
let entry = unsafe { ash::Entry::load().unwrap() };
|
||||||
let base = VulkanBase::new(entry).unwrap();
|
let base = VulkanBase::new(entry).unwrap();
|
||||||
dbg!("finished");
|
dbg!("finished");
|
||||||
let mut filter = FilterChain::load_from_path(
|
let mut filter = FilterChainVulkan::load_from_path(
|
||||||
&base,
|
&base,
|
||||||
// "../test/slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp",
|
// "../test/slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp",
|
||||||
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/// Options for each Vulkan shader frame.
|
/// Options for each Vulkan shader frame.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FrameOptions {
|
pub struct FrameOptionsVulkan {
|
||||||
/// Whether or not to clear the history buffers.
|
/// Whether or not to clear the history buffers.
|
||||||
pub clear_history: bool,
|
pub clear_history: bool,
|
||||||
/// The direction of the frame. 1 should be vertical.
|
/// The direction of the frame. 1 should be vertical.
|
||||||
|
@ -13,7 +13,7 @@ pub struct FrameOptions {
|
||||||
/// Options for filter chain creation.
|
/// Options for filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FilterChainOptions {
|
pub struct FilterChainOptionsVulkan {
|
||||||
/// The number of frames in flight to keep. If zero, defaults to three.
|
/// The number of frames in flight to keep. If zero, defaults to three.
|
||||||
pub frames_in_flight: u32,
|
pub frames_in_flight: u32,
|
||||||
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::FilterChain;
|
use crate::FilterChainVulkan;
|
||||||
use librashader_runtime::parameters::FilterChainParameters;
|
use librashader_runtime::parameters::FilterChainParameters;
|
||||||
use std::collections::hash_map::Iter;
|
use std::collections::hash_map::Iter;
|
||||||
|
|
||||||
impl FilterChainParameters for FilterChain {
|
impl FilterChainParameters for FilterChainVulkan {
|
||||||
fn get_enabled_pass_count(&self) -> usize {
|
fn get_enabled_pass_count(&self) -> usize {
|
||||||
self.common.config.passes_enabled
|
self.common.config.passes_enabled
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,22 +100,73 @@ pub mod runtime {
|
||||||
/// Note that the OpenGL runtime requires `gl` to be
|
/// Note that the OpenGL runtime requires `gl` to be
|
||||||
/// initialized with [`gl::load_with`](https://docs.rs/gl/0.14.0/gl/fn.load_with.html).
|
/// initialized with [`gl::load_with`](https://docs.rs/gl/0.14.0/gl/fn.load_with.html).
|
||||||
pub mod gl {
|
pub mod gl {
|
||||||
|
pub use librashader_runtime_gl::{
|
||||||
|
options::{
|
||||||
|
FilterChainOptionsGL as FilterChainOptions,
|
||||||
|
FrameOptionsGL as FrameOptions,
|
||||||
|
},
|
||||||
|
FilterChainGL as FilterChain,
|
||||||
|
Framebuffer, GLImage,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
/// Re-exports names to deal with C API conflicts.
|
||||||
|
///
|
||||||
|
/// This is internal to librashader-capi and is exempt from semantic versioning.
|
||||||
|
pub mod capi {
|
||||||
pub use librashader_runtime_gl::*;
|
pub use librashader_runtime_gl::*;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "d3d11")]
|
#[cfg(feature = "d3d11")]
|
||||||
/// Shader runtime for Direct3D 11.
|
/// Shader runtime for Direct3D 11.
|
||||||
pub mod d3d11 {
|
pub mod d3d11 {
|
||||||
|
pub use librashader_runtime_d3d11::{
|
||||||
|
options::{
|
||||||
|
FilterChainOptionsD3D11 as FilterChainOptions,
|
||||||
|
FrameOptionsD3D11 as FrameOptions,
|
||||||
|
},
|
||||||
|
FilterChainD3D11 as FilterChain,
|
||||||
|
D3D11InputView, D3D11OutputView,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
/// Re-exports names to deal with C API conflicts.
|
||||||
|
///
|
||||||
|
/// This is internal to librashader-capi and is exempt from semantic versioning.
|
||||||
|
pub mod capi {
|
||||||
pub use librashader_runtime_d3d11::*;
|
pub use librashader_runtime_d3d11::*;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "vk")]
|
#[cfg(feature = "vk")]
|
||||||
/// Shader runtime for Vulkan 1.3+.
|
/// Shader runtime for Vulkan 1.3+.
|
||||||
pub mod vk {
|
pub mod vk {
|
||||||
|
pub use librashader_runtime_vk::{
|
||||||
|
options::{
|
||||||
|
FilterChainOptionsVulkan as FilterChainOptions,
|
||||||
|
FrameOptionsVulkan as FrameOptions,
|
||||||
|
},
|
||||||
|
FilterChainVulkan as FilterChain,
|
||||||
|
VulkanImage, VulkanDevice, VulkanInstance,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
/// Re-exports names to deal with C API conflicts.
|
||||||
|
///
|
||||||
|
/// This is internal to librashader-capi and is exempt from semantic versioning.
|
||||||
|
pub mod capi {
|
||||||
pub use librashader_runtime_vk::*;
|
pub use librashader_runtime_vk::*;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
/// Helper methods for runtimes.
|
||||||
|
///
|
||||||
|
/// This is internal to librashader runtimes and is exempt from semantic versioning.
|
||||||
pub mod helper {
|
pub mod helper {
|
||||||
pub use librashader_runtime::semantics::insert_lut_semantics;
|
pub use librashader_runtime::semantics::insert_lut_semantics;
|
||||||
pub use librashader_runtime::semantics::insert_pass_semantics;
|
pub use librashader_runtime::semantics::insert_pass_semantics;
|
||||||
|
|
Loading…
Reference in a new issue