capi: resolve name conflicts due to conflicting struct names in each module

This commit is contained in:
chyyran 2023-01-13 16:55:50 -05:00
parent 6782f08820
commit 45d03fbfb8
21 changed files with 145 additions and 94 deletions

View file

@ -7,11 +7,11 @@ pub type libra_shader_preset_t = Option<NonNull<ShaderPreset>>;
pub type libra_error_t = Option<NonNull<LibrashaderError>>;
#[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")]
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.
#[repr(C)]

View file

@ -11,8 +11,8 @@ use windows::Win32::Graphics::Direct3D11::{
ID3D11Device, ID3D11RenderTargetView, ID3D11ShaderResourceView,
};
pub use librashader::runtime::d3d11::options::FilterChainOptions;
pub use librashader::runtime::d3d11::options::FrameOptions;
pub use librashader::runtime::d3d11::capi::options::FilterChainOptionsD3D11;
pub use librashader::runtime::d3d11::capi::options::FrameOptionsD3D11;
use librashader::runtime::{Size, Viewport};
@ -53,7 +53,7 @@ extern_fn! {
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
fn libra_d3d11_filter_chain_create(
preset: *mut libra_shader_preset_t,
options: *const FilterChainOptions,
options: *const FilterChainOptionsD3D11,
device: *const ID3D11Device,
out: *mut MaybeUninit<libra_d3d11_filter_chain_t>
) {
@ -71,7 +71,7 @@ extern_fn! {
Some(unsafe { &*options })
};
let chain = librashader::runtime::d3d11::FilterChain::load_from_preset(
let chain = librashader::runtime::d3d11::capi::FilterChainD3D11::load_from_preset(
unsafe { &*device },
*preset,
options,
@ -102,7 +102,7 @@ extern_fn! {
viewport: libra_viewport_t,
out: *const ID3D11RenderTargetView,
mvp: *const f32,
opt: *const FrameOptions
opt: *const FrameOptionsD3D11
) mut |chain| {
assert_some_ptr!(mut chain);
assert_non_null!(out);

View file

@ -9,8 +9,8 @@ use std::mem::MaybeUninit;
use std::ptr::NonNull;
use std::slice;
pub use librashader::runtime::gl::options::FilterChainOptions;
pub use librashader::runtime::gl::options::FrameOptions;
pub use librashader::runtime::gl::capi::options::FilterChainOptionsGL;
pub use librashader::runtime::gl::capi::options::FrameOptionsGL;
use librashader::runtime::{Size, Viewport};
/// 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.
fn libra_gl_filter_chain_create(
preset: *mut libra_shader_preset_t,
options: *const FilterChainOptions,
options: *const FilterChainOptionsGL,
out: *mut MaybeUninit<libra_gl_filter_chain_t>
) {
assert_non_null!(preset);
@ -97,7 +97,7 @@ extern_fn! {
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 {
out.write(MaybeUninit::new(NonNull::new(Box::into_raw(Box::new(
@ -124,7 +124,7 @@ extern_fn! {
viewport: libra_viewport_t,
out: libra_draw_framebuffer_gl_t,
mvp: *const f32,
opt: *const FrameOptions
opt: *const FrameOptionsGL
) mut |chain| {
assert_some_ptr!(mut chain);
let image: GLImage = image.into();

View file

@ -19,7 +19,7 @@ use std::path::Path;
use crate::error::FilterChainError;
use crate::filter_pass::{ConstantBufferBinding, FilterPass};
use crate::framebuffer::OwnedFramebuffer;
use crate::options::{FilterChainOptions, FrameOptions};
use crate::options::{FilterChainOptionsD3D11, FrameOptionsD3D11};
use crate::quad_render::DrawQuad;
use crate::render_target::RenderTarget;
use crate::samplers::SamplerSet;
@ -47,7 +47,7 @@ type ShaderPassMeta = (
);
/// A Direct3D 11 filter chain.
pub struct FilterChain {
pub struct FilterChainD3D11 {
pub(crate) common: FilterCommon,
pub(crate) passes: Vec<FilterPass>,
pub(crate) output_framebuffers: Box<[OwnedFramebuffer]>,
@ -74,13 +74,13 @@ pub(crate) struct FilterCommon {
pub disable_mipmaps: bool,
}
impl FilterChain {
impl FilterChainD3D11 {
/// Load the shader preset at the given path into a filter chain.
pub fn load_from_path(
device: &ID3D11Device,
path: impl AsRef<Path>,
options: Option<&FilterChainOptions>,
) -> error::Result<FilterChain> {
options: Option<&FilterChainOptionsD3D11>,
) -> error::Result<FilterChainD3D11> {
// load passes from preset
let preset = ShaderPreset::try_parse(path)?;
Self::load_from_preset(device, preset, options)
@ -90,16 +90,16 @@ impl FilterChain {
pub fn load_from_preset(
device: &ID3D11Device,
preset: ShaderPreset,
options: Option<&FilterChainOptions>,
) -> error::Result<FilterChain> {
let (passes, semantics) = FilterChain::load_preset(preset.shaders, &preset.textures)?;
options: Option<&FilterChainOptionsD3D11>,
) -> error::Result<FilterChainD3D11> {
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 samplers = SamplerSet::new(device)?;
// initialize passes
let filters = FilterChain::init_passes(device, passes, &semantics)?;
let filters = FilterChainD3D11::init_passes(device, passes, &semantics)?;
let mut immediate_context = None;
unsafe {
@ -154,15 +154,15 @@ impl FilterChain {
feedback_textures.resize_with(filters.len(), || None);
// load luts
let luts = FilterChain::load_luts(device, &current_context, &preset.textures)?;
let luts = FilterChainD3D11::load_luts(device, &current_context, &preset.textures)?;
let (history_framebuffers, history_textures) =
FilterChain::init_history(device, &current_context, &filters)?;
FilterChainD3D11::init_history(device, &current_context, &filters)?;
let draw_quad = DrawQuad::new(device, &current_context)?;
// todo: make vbo: d3d11.c 1376
Ok(FilterChain {
Ok(FilterChainD3D11 {
passes: filters,
output_framebuffers: output_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> {
unsafe {
let buffer = device.CreateBuffer(
@ -247,7 +247,7 @@ impl FilterChain {
)?;
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 {
binding: ubo.binding,
size: ubo.size,
@ -259,7 +259,7 @@ impl FilterChain {
};
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 {
binding: if ubo_cbuffer.is_some() { 1 } else { 0 },
size: push.size,
@ -468,7 +468,7 @@ impl FilterChain {
input: D3D11InputView,
viewport: &Viewport<D3D11OutputView>,
frame_count: usize,
options: Option<&FrameOptions>,
options: Option<&FrameOptionsD3D11>,
) -> error::Result<()> {
let passes = &mut self.passes[0..self.common.config.passes_enabled];
if let Some(options) = options {

View file

@ -225,9 +225,9 @@ pub mod d3d11_hello_triangle {
use super::*;
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::viewport::Viewport;
use librashader_common::{Size, Viewport};
@ -240,7 +240,7 @@ pub mod d3d11_hello_triangle {
pub device: ID3D11Device,
pub context: ID3D11DeviceContext,
pub resources: Option<Resources>,
pub filter: FilterChain,
pub filter: FilterChainD3D11,
}
pub struct Resources {
@ -267,10 +267,10 @@ pub mod d3d11_hello_triangle {
impl Sample {
pub(crate) fn new(
filter: impl AsRef<Path>,
filter_options: Option<&FilterChainOptions>,
filter_options: Option<&FilterChainOptionsD3D11>,
) -> Result<Self> {
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 {
filter,
dxgi_factory,

View file

@ -16,21 +16,21 @@ mod samplers;
mod texture;
mod util;
pub use filter_chain::FilterChain;
pub use filter_chain::FilterChainD3D11;
pub use texture::D3D11InputView;
pub use texture::D3D11OutputView;
#[cfg(test)]
mod tests {
use super::*;
use crate::options::FilterChainOptions;
use crate::options::FilterChainOptionsD3D11;
#[test]
fn triangle_d3d11() {
let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// "../test/basic.slangp",
Some(&FilterChainOptions {
Some(&FilterChainOptionsD3D11 {
use_deferred_context: false,
force_no_mipmaps: false,
}),

View file

@ -3,7 +3,7 @@
/// Options for each Direct3D11 shader frame.
#[repr(C)]
#[derive(Debug, Clone)]
pub struct FrameOptions {
pub struct FrameOptionsD3D11 {
/// Whether or not to clear the history buffers.
pub clear_history: bool,
/// The direction of the frame. 1 should be vertical.
@ -13,7 +13,7 @@ pub struct FrameOptions {
/// Options for Direct3D11 filter chain creation.
#[repr(C)]
#[derive(Debug, Clone)]
pub struct FilterChainOptions {
pub struct FilterChainOptionsD3D11 {
/// Use a deferred context to record shader rendering state.
///
/// The deferred context will be executed on the immediate context

View file

@ -1,8 +1,8 @@
use crate::FilterChain;
use crate::FilterChainD3D11;
use librashader_runtime::parameters::FilterChainParameters;
use std::collections::hash_map::Iter;
impl FilterChainParameters for FilterChain {
impl FilterChainParameters for FilterChainD3D11 {
fn get_enabled_pass_count(&self) -> usize {
self.common.config.passes_enabled
}

View file

@ -2,14 +2,14 @@ use crate::binding::{GlUniformStorage, UniformLocation, VariableLocation};
use crate::error::FilterChainError;
use crate::filter_pass::FilterPass;
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::samplers::SamplerSet;
use crate::texture::Texture;
use crate::util::{gl_get_version, gl_u16_to_version};
use crate::{error, util, GLImage};
use gl::types::{GLenum, GLint, GLuint};
use librashader_common::{FilterMode, Size, Viewport, WrapMode};
use gl::types::{GLint, GLuint};
use librashader_common::{FilterMode, Viewport, WrapMode};
use librashader_preprocess::ShaderSource;
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
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`.
pub(crate) fn load_from_preset(
preset: ShaderPreset,
options: Option<&FilterChainOptions>,
options: Option<&FilterChainOptionsGL>,
) -> error::Result<Self> {
let (passes, semantics) = Self::load_preset(preset.shaders, &preset.textures)?;
@ -421,7 +421,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
count: usize,
viewport: &Viewport<&Framebuffer>,
input: &GLImage,
options: Option<&FrameOptions>,
options: Option<&FrameOptionsGL>,
) -> error::Result<()> {
// limit number of passes to those enabled.
let passes = &mut self.passes[0..self.common.config.passes_enabled];

View file

@ -1,11 +1,11 @@
use gl::types::{GLenum, GLuint};
use std::panic::catch_unwind;
use std::path::Path;
use crate::error::{FilterChainError, Result};
use crate::filter_chain::filter_impl::FilterChainImpl;
use crate::filter_chain::inner::FilterChainDispatch;
use crate::options::{FilterChainOptions, FrameOptions};
use crate::options::{FilterChainOptionsGL, FrameOptionsGL};
use crate::{Framebuffer, GLImage};
use librashader_presets::ShaderPreset;
@ -14,18 +14,18 @@ mod inner;
mod parameters;
pub(crate) use filter_impl::FilterCommon;
use librashader_common::{Size, Viewport};
use librashader_common::{Viewport};
/// An OpenGL filter chain.
pub struct FilterChain {
pub struct FilterChainGL {
pub(in crate::filter_chain) filter: FilterChainDispatch,
}
impl FilterChain {
impl FilterChainGL {
/// Load a filter chain from a pre-parsed `ShaderPreset`.
pub fn load_from_preset(
preset: ShaderPreset,
options: Option<&FilterChainOptions>,
options: Option<&FilterChainOptionsGL>,
) -> Result<Self> {
let result = catch_unwind(|| {
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.
pub fn load_from_path(
path: impl AsRef<Path>,
options: Option<&FilterChainOptions>,
options: Option<&FilterChainOptionsGL>,
) -> Result<Self> {
// load passes from preset
let preset = ShaderPreset::try_parse(path)?;
@ -64,7 +64,7 @@ impl FilterChain {
input: &GLImage,
viewport: &Viewport<&Framebuffer>,
frame_count: usize,
options: Option<&FrameOptions>,
options: Option<&FrameOptionsGL>,
) -> Result<()> {
match &mut self.filter {
FilterChainDispatch::DirectStateAccess(p) => {

View file

@ -1,7 +1,7 @@
use crate::filter_chain::filter_impl::FilterChainImpl;
use crate::filter_chain::inner::FilterChainDispatch;
use crate::gl::GLInterface;
use crate::FilterChain;
use crate::FilterChainGL;
use librashader_runtime::parameters::FilterChainParameters;
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 {
self.filter.as_ref().get_enabled_pass_count()
}

View file

@ -7,7 +7,7 @@ use glfw::{Context, Glfw, Window, WindowEvent};
use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
use librashader_common::Size;
use crate::filter_chain::FilterChain;
use crate::filter_chain::FilterChainGL;
use crate::framebuffer::GLImage;
use crate::gl::gl3::CompatibilityGL;
use crate::gl::{FramebufferInterface, GLInterface};
@ -268,7 +268,7 @@ pub fn do_loop(
events: Receiver<(f64, WindowEvent)>,
triangle_program: GLuint,
triangle_vao: GLuint,
filter: &mut FilterChain,
filter: &mut FilterChainGL,
) {
let mut framecount = 0;
let mut rendered_framebuffer = 0;

View file

@ -7,7 +7,7 @@ use glfw::{Context, Glfw, Window, WindowEvent};
use gl::types::{GLchar, GLenum, GLint, GLsizei, GLuint};
use librashader_common::Size;
use crate::filter_chain::FilterChain;
use crate::filter_chain::FilterChainGL;
use crate::framebuffer::GLImage;
use crate::gl::gl46::DirectStateAccessGL;
use crate::gl::{FramebufferInterface, GLInterface};
@ -259,7 +259,7 @@ pub fn do_loop(
events: Receiver<(f64, WindowEvent)>,
triangle_program: GLuint,
triangle_vao: GLuint,
filter: &mut FilterChain,
filter: &mut FilterChainGL,
) {
let mut framecount = 0;
let mut rendered_framebuffer = 0;

View file

@ -17,21 +17,21 @@ pub mod error;
pub mod options;
pub use crate::gl::Framebuffer;
pub use filter_chain::FilterChain;
pub use filter_chain::FilterChainGL;
pub use framebuffer::GLImage;
#[cfg(test)]
mod tests {
use super::*;
use crate::filter_chain::FilterChain;
use crate::options::FilterChainOptions;
use crate::filter_chain::FilterChainGL;
use crate::options::FilterChainOptionsGL;
#[test]
fn triangle_gl() {
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",
Some(&FilterChainOptions {
Some(&FilterChainOptionsGL {
gl_version: 0,
use_dsa: false,
force_no_mipmaps: false,
@ -45,10 +45,10 @@ mod tests {
#[test]
fn triangle_gl46() {
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/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
Some(&FilterChainOptions {
Some(&FilterChainOptionsGL {
gl_version: 0,
use_dsa: true,
force_no_mipmaps: false,

View file

@ -3,7 +3,7 @@
/// Options for each OpenGL shader frame.
#[repr(C)]
#[derive(Debug, Clone)]
pub struct FrameOptions {
pub struct FrameOptionsGL {
/// Whether or not to clear the history buffers.
pub clear_history: bool,
/// The direction of the frame. 1 should be vertical.
@ -13,7 +13,7 @@ pub struct FrameOptions {
/// Options for filter chain creation.
#[repr(C)]
#[derive(Debug, Clone)]
pub struct FilterChainOptions {
pub struct FilterChainOptionsGL {
/// The GLSL version. Should be at least `330`.
pub gl_version: u16,
/// Whether or not to use the Direct State Access APIs. Only available on OpenGL 4.5+.

View file

@ -26,7 +26,7 @@ use librashader_runtime::uniforms::UniformStorage;
use rustc_hash::FxHashMap;
use std::collections::VecDeque;
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.
pub struct VulkanDevice {
@ -112,7 +112,7 @@ impl TryFrom<(vk::PhysicalDevice, ash::Instance, ash::Device)> for VulkanDevice
}
/// A Vulkan filter chain.
pub struct FilterChain {
pub struct FilterChainVulkan {
pub(crate) common: FilterCommon,
passes: Box<[FilterPass]>,
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.
pub fn load_from_path(
vulkan: impl TryInto<VulkanDevice, Error = FilterChainError>,
path: impl AsRef<Path>,
options: Option<&FilterChainOptions>,
) -> error::Result<FilterChain> {
options: Option<&FilterChainOptionsVulkan>,
) -> error::Result<FilterChainVulkan> {
// load passes from preset
let preset = ShaderPreset::try_parse(path)?;
Self::load_from_preset(vulkan, preset, options)
@ -204,9 +204,9 @@ impl FilterChain {
pub fn load_from_preset(
vulkan: impl TryInto<VulkanDevice, Error = FilterChainError>,
preset: ShaderPreset,
options: Option<&FilterChainOptions>,
) -> error::Result<FilterChain> {
let (passes, semantics) = FilterChain::load_preset(preset.shaders, &preset.textures)?;
options: Option<&FilterChainOptionsVulkan>,
) -> error::Result<FilterChainVulkan> {
let (passes, semantics) = FilterChainVulkan::load_preset(preset.shaders, &preset.textures)?;
let device = vulkan.try_into()?;
let mut frames_in_flight = options.map(|o| o.frames_in_flight).unwrap_or(0);
@ -217,11 +217,11 @@ impl FilterChain {
// initialize passes
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 (history_framebuffers, history_textures) =
FilterChain::init_history(&device, &filters)?;
FilterChainVulkan::init_history(&device, &filters)?;
let mut output_framebuffers = Vec::new();
output_framebuffers.resize_with(filters.len(), || {
@ -246,7 +246,7 @@ impl FilterChain {
let mut intermediates = Vec::new();
intermediates.resize_with(frames_in_flight as usize, || FrameResiduals::new(&device.device));
Ok(FilterChain {
Ok(FilterChainVulkan {
common: FilterCommon {
luts,
samplers,
@ -584,7 +584,7 @@ impl FilterChain {
viewport: &Viewport<VulkanImage>,
input: &VulkanImage,
cmd: vk::CommandBuffer,
options: Option<FrameOptions>,
options: Option<FrameOptionsVulkan>,
) -> error::Result<()> {
let intermediates = &mut self.residuals[count % self.residuals.len()];
intermediates.dispose();

View file

@ -8,7 +8,7 @@ mod swapchain;
mod syncobjects;
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::framebuffer::VulkanFramebuffer;
use crate::hello_triangle::pipeline::VulkanPipeline;
@ -48,7 +48,7 @@ impl VulkanWindow {
event_loop: EventLoop<()>,
window: winit::window::Window,
vulkan: VulkanDraw,
mut filter_chain: FilterChain,
mut filter_chain: FilterChainVulkan,
) {
let mut counter = 0;
event_loop.run(move |event, _, control_flow| match event {
@ -136,7 +136,7 @@ impl VulkanWindow {
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 in_flight = [vulkan.sync.in_flight[index]];
let image_available = [vulkan.sync.image_available[index]];
@ -370,7 +370,7 @@ pub struct VulkanDraw {
pub sync: SyncObjects,
}
pub fn main(vulkan: VulkanBase, filter_chain: FilterChain) {
pub fn main(vulkan: VulkanBase, filter_chain: FilterChainVulkan) {
let event_loop = EventLoopBuilder::new()
.with_any_thread(true)
.with_dpi_aware(true)

View file

@ -19,7 +19,7 @@ mod util;
mod vulkan_primitives;
mod vulkan_state;
pub use filter_chain::FilterChain;
pub use filter_chain::FilterChainVulkan;
pub use filter_chain::VulkanDevice;
pub use filter_chain::VulkanInstance;
pub use texture::VulkanImage;
@ -30,7 +30,7 @@ pub mod options;
#[cfg(test)]
mod tests {
use super::*;
use crate::filter_chain::FilterChain;
use crate::filter_chain::FilterChainVulkan;
use crate::hello_triangle::vulkan_base::VulkanBase;
#[test]
@ -38,7 +38,7 @@ mod tests {
let entry = unsafe { ash::Entry::load().unwrap() };
let base = VulkanBase::new(entry).unwrap();
dbg!("finished");
let mut filter = FilterChain::load_from_path(
let mut filter = FilterChainVulkan::load_from_path(
&base,
// "../test/slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp",
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",

View file

@ -3,7 +3,7 @@
/// Options for each Vulkan shader frame.
#[repr(C)]
#[derive(Debug, Clone)]
pub struct FrameOptions {
pub struct FrameOptionsVulkan {
/// Whether or not to clear the history buffers.
pub clear_history: bool,
/// The direction of the frame. 1 should be vertical.
@ -13,7 +13,7 @@ pub struct FrameOptions {
/// Options for filter chain creation.
#[repr(C)]
#[derive(Debug, Clone)]
pub struct FilterChainOptions {
pub struct FilterChainOptionsVulkan {
/// The number of frames in flight to keep. If zero, defaults to three.
pub frames_in_flight: u32,
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.

View file

@ -1,8 +1,8 @@
use crate::FilterChain;
use crate::FilterChainVulkan;
use librashader_runtime::parameters::FilterChainParameters;
use std::collections::hash_map::Iter;
impl FilterChainParameters for FilterChain {
impl FilterChainParameters for FilterChainVulkan {
fn get_enabled_pass_count(&self) -> usize {
self.common.config.passes_enabled
}

View file

@ -100,22 +100,73 @@ pub mod runtime {
/// 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).
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::*;
}
}
#[cfg(feature = "d3d11")]
/// Shader runtime for Direct3D 11.
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::*;
}
}
#[cfg(feature = "vk")]
/// Shader runtime for Vulkan 1.3+.
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::*;
}
}
#[doc(hidden)]
/// Helper methods for runtimes.
///
/// This is internal to librashader runtimes and is exempt from semantic versioning.
pub mod helper {
pub use librashader_runtime::semantics::insert_lut_semantics;
pub use librashader_runtime::semantics::insert_pass_semantics;