rt: move image into runtime
This commit is contained in:
parent
ba41055a58
commit
1665770615
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -426,7 +426,6 @@ name = "librashader-common"
|
|||
version = "0.1.0-alpha.1"
|
||||
dependencies = [
|
||||
"gl",
|
||||
"image",
|
||||
"num-traits",
|
||||
"windows",
|
||||
]
|
||||
|
@ -472,6 +471,7 @@ name = "librashader-runtime"
|
|||
version = "0.1.0-alpha.1"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"image",
|
||||
"librashader-common",
|
||||
"librashader-preprocess",
|
||||
"librashader-presets",
|
||||
|
|
|
@ -19,7 +19,6 @@ dxgi = ["windows"]
|
|||
|
||||
[dependencies]
|
||||
gl = { version = "0.14.0", optional = true }
|
||||
image = "0.24.5"
|
||||
num-traits = "0.2.15"
|
||||
|
||||
[dependencies.windows]
|
||||
|
|
|
@ -10,9 +10,6 @@ pub mod dxgi;
|
|||
#[cfg(feature = "d3d11")]
|
||||
pub mod d3d11;
|
||||
|
||||
/// Image handing helpers.
|
||||
pub mod image;
|
||||
|
||||
use num_traits::AsPrimitive;
|
||||
use std::convert::Infallible;
|
||||
use std::str::FromStr;
|
||||
|
|
|
@ -20,6 +20,7 @@ pub(crate) fn remove_if<T>(values: &mut Vec<T>, f: impl FnMut(&T) -> bool) -> Op
|
|||
}
|
||||
|
||||
impl ShaderPreset {
|
||||
/// Try to parse the shader preset at the given path.
|
||||
pub fn try_parse(path: impl AsRef<Path>) -> Result<ShaderPreset, ParsePresetError> {
|
||||
let values = parse_preset(path)?;
|
||||
Ok(resolve_values(values))
|
||||
|
|
|
@ -12,7 +12,7 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
|||
description = "RetroArch shaders for all."
|
||||
|
||||
[dependencies]
|
||||
shaderc = { version = "0.8.0" }
|
||||
shaderc = { version = "0.8.0", features = [] }
|
||||
spirv_cross = { version = "0.23.1", features = [ "glsl", "hlsl" ] }
|
||||
|
||||
|
||||
|
@ -30,5 +30,6 @@ rspirv-reflect = { git = "https://github.com/Traverse-Research/rspirv-reflect",
|
|||
[features]
|
||||
default = []
|
||||
unstable-rust-pipeline = [ "naga", "rspirv", "rspirv-reflect" ]
|
||||
standalone = ["shaderc/build-from-source"]
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use librashader_common::image::ImageError;
|
||||
use librashader_runtime::image::ImageError;
|
||||
use librashader_preprocess::PreprocessError;
|
||||
use librashader_presets::ParsePresetError;
|
||||
use librashader_reflect::error::{ShaderCompileError, ShaderReflectError};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::texture::{DxImageView, LutTexture, Texture};
|
||||
use librashader_common::image::{Image, UVDirection};
|
||||
use librashader_runtime::image::{Image, UVDirection};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
|
|
|
@ -5,7 +5,7 @@ use librashader_common::{ImageFormat, Size};
|
|||
use librashader_presets::Scale2D;
|
||||
use windows::core::Interface;
|
||||
use windows::Win32::Graphics::Direct3D::D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
use windows::Win32::Graphics::Direct3D11::{ID3D11Device, ID3D11RenderTargetView, ID3D11ShaderResourceView, ID3D11Texture2D, D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE, D3D11_CPU_ACCESS_WRITE, D3D11_FORMAT_SUPPORT_RENDER_TARGET, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE, D3D11_FORMAT_SUPPORT_TEXTURE2D, D3D11_RENDER_TARGET_VIEW_DESC, D3D11_RENDER_TARGET_VIEW_DESC_0, D3D11_RTV_DIMENSION_TEXTURE2D, D3D11_SHADER_RESOURCE_VIEW_DESC, D3D11_SHADER_RESOURCE_VIEW_DESC_0, D3D11_TEX2D_RTV, D3D11_TEX2D_SRV, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_VIEWPORT, D3D11_RESOURCE_MISC_GENERATE_MIPS, D3D11_BOX, ID3D11DeviceContext};
|
||||
use windows::Win32::Graphics::Direct3D11::{ID3D11Device, ID3D11RenderTargetView, ID3D11ShaderResourceView, ID3D11Texture2D, D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE, D3D11_CPU_ACCESS_WRITE, D3D11_FORMAT_SUPPORT_RENDER_TARGET, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE, D3D11_FORMAT_SUPPORT_TEXTURE2D, D3D11_RENDER_TARGET_VIEW_DESC, D3D11_RENDER_TARGET_VIEW_DESC_0, D3D11_RTV_DIMENSION_TEXTURE2D, D3D11_SHADER_RESOURCE_VIEW_DESC, D3D11_SHADER_RESOURCE_VIEW_DESC_0, D3D11_TEX2D_RTV, D3D11_TEX2D_SRV, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_VIEWPORT, D3D11_RESOURCE_MISC_GENERATE_MIPS, ID3D11DeviceContext};
|
||||
use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT, DXGI_SAMPLE_DESC};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -23,7 +23,6 @@ pub use texture::DxImageView;
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::options::FilterChainOptions;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use librashader_common::image::Image;
|
||||
use librashader_runtime::image::Image;
|
||||
use librashader_common::{FilterMode, Size, WrapMode};
|
||||
use windows::Win32::Graphics::Direct3D::D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use gl::types::GLenum;
|
||||
use librashader_common::image::ImageError;
|
||||
use librashader_runtime::image::ImageError;
|
||||
use librashader_preprocess::PreprocessError;
|
||||
use librashader_presets::ParsePresetError;
|
||||
use librashader_reflect::error::{ShaderCompileError, ShaderReflectError};
|
||||
|
|
|
@ -67,10 +67,10 @@ impl DrawQuad for Gl3DrawQuad {
|
|||
|
||||
fn unbind_vertices(&self) {
|
||||
unsafe {
|
||||
gl::BindVertexArray(0);
|
||||
gl::BindBuffer(gl::ARRAY_BUFFER, 0);
|
||||
gl::DisableVertexAttribArray(0);
|
||||
gl::DisableVertexAttribArray(1);
|
||||
gl::BindVertexArray(0);
|
||||
gl::BindBuffer(gl::ARRAY_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::LoadLut;
|
||||
use crate::texture::Texture;
|
||||
use gl::types::{GLsizei, GLuint};
|
||||
use librashader_common::image::{Image, UVDirection};
|
||||
use librashader_runtime::image::{Image, UVDirection};
|
||||
use librashader_common::Size;
|
||||
use librashader_presets::TextureConfig;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::LoadLut;
|
||||
use crate::texture::Texture;
|
||||
use gl::types::{GLsizei, GLuint};
|
||||
use librashader_common::image::{Image, UVDirection};
|
||||
use librashader_runtime::image::{Image, UVDirection};
|
||||
use librashader_common::Size;
|
||||
use librashader_presets::TextureConfig;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
|
|
@ -19,3 +19,4 @@ librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.
|
|||
bytemuck = "1.12.3"
|
||||
rustc-hash = "1.1.0"
|
||||
num-traits = "0.2.15"
|
||||
image = "0.24.5"
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use librashader_common::Size;
|
||||
pub use image::ImageError;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
pub struct Image {
|
||||
|
@ -6,16 +9,21 @@ pub struct Image {
|
|||
pub pitch: usize,
|
||||
}
|
||||
|
||||
/// The direction of UV coordinates to load the image for.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum UVDirection {
|
||||
/// Origin is at the top left (Direct3D, Vulkan)
|
||||
TopLeft,
|
||||
/// Origin is at the bottom left (OpenGL)
|
||||
BottomLeft,
|
||||
}
|
||||
|
||||
impl Image {
|
||||
/// Load the image from the path as RGBA8.
|
||||
pub fn load(path: impl AsRef<Path>, direction: UVDirection) -> Result<Self, ImageError> {
|
||||
let mut image = image::open(path.as_ref())?;
|
||||
|
||||
if direction == BottomLeft {
|
||||
if direction == UVDirection::BottomLeft {
|
||||
image = image.flipv();
|
||||
}
|
||||
|
||||
|
@ -35,7 +43,3 @@ impl Image {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
use crate::Size;
|
||||
pub use image::ImageError;
|
||||
use crate::image::UVDirection::BottomLeft;
|
|
@ -14,3 +14,6 @@ pub mod parameters;
|
|||
|
||||
/// Filter chain helpers and traits.
|
||||
pub mod filter_chain;
|
||||
|
||||
/// Image handling helpers.
|
||||
pub mod image;
|
||||
|
|
Loading…
Reference in a new issue