Compare commits

...

17 commits

Author SHA1 Message Date
Alex Janka 89090757fd fix shaderstorage in tests 2024-08-19 14:53:16 +10:00
Alex Janka 1406ddc5b3 nightly rust-toolchain.toml 2024-08-19 14:53:16 +10:00
Alex Janka bf974ac642 shaders can be either a path or a string 2024-08-19 14:53:16 +10:00
chyyran d1e49b7eb4 rt(d3d9): search "global" namespace for register assignments 2024-08-12 01:47:52 -04:00
chyyran 5ef0055e05 rt(d3d9): fix vertex assignments accidentally searching fragment 2024-08-12 01:47:52 -04:00
chyyran 1c6581d737 rt(d3d9): set colorwritemask to all 2024-08-12 01:47:52 -04:00
chyyran ac66b1b6f6 style: fix warnings 2024-08-09 00:56:44 -04:00
chyyran 977975f4c7 doc: document naga reflect 2024-08-09 00:56:44 -04:00
chyyran 3b9514ad38 doc: allow wgpu doc on apple 2024-08-09 00:56:44 -04:00
chyyran 899fb50da6 chore: Release 2024-08-03 00:13:40 -04:00
chyyran 162226ce44 ci: don't build locally
OSC seems very broken on Github Actions
2024-08-02 01:35:13 -04:00
chyyran 039fdfd41a ci: update OBS build platform 2024-08-02 01:26:31 -04:00
chyyran e13bb88df2 doc: update MSRV due to naga 2024-08-02 01:09:43 -04:00
chyyran 7b375658c5 dep: update cargo.lock 2024-08-02 01:04:56 -04:00
chyyran 3fb6e3843e dep: update to windows 0.58 2024-08-02 00:56:28 -04:00
chyyran 3cda5b706d rt(d3d12): get rid of size in inputview 2024-08-02 00:16:52 -04:00
chyyran 4d6793d305 rt(d3d11): get rid of input/output view wrappers 2024-08-02 00:16:52 -04:00
63 changed files with 601 additions and 561 deletions

View file

@ -19,14 +19,14 @@ jobs:
strategy:
matrix:
include:
- repo: Fedora_39
- repo: Fedora_40
spec: librashader.spec
can_fail: true
name: Fedora 39 (.rpm)
- repo: xUbuntu_23.10
name: Fedora 40 (.rpm)
- repo: xUbuntu_24.04
spec: librashader.spec
can_fail: true
name: Ubuntu 23.10 (.deb)
name: Ubuntu 24.04 (.deb)
runs-on: ubuntu-latest
needs: [approve-obs-build]
continue-on-error: ${{ matrix.can_fail }}

View file

@ -7,50 +7,7 @@ env:
CARGO_TERM_COLOR: always
jobs:
build-obs-binary:
if: github.repository == 'SnowflakePowered/librashader'
strategy:
matrix:
include:
- repo: Fedora_39
spec: librashader.spec
can_fail: true
- repo: xUbuntu_23.10
spec: librashader.spec
can_fail: true
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.can_fail }}
container:
image: fedora:39
options: --privileged
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install OSC and dependencies
env:
OBS_CONFIG: ${{ secrets.OBS_CONFIG }}
run: |
sudo dnf install -y osc obs-service-obs_scm obs-service-cargo_vendor cargo python3-zstandard
mkdir -p ~/.config/osc
echo "$OBS_CONFIG" > ~/.config/osc/oscrc
- name: Checkout Open Build Service repository
run: |
osc co home:chyyran:librashader/librashader
- name: Copy spec from repository
run: |
cp -r ./pkg/obs/ home:chyyran:librashader/librashader/
sed -r -i 's/(<param name="revision">)(.+)(<\/param>)/<param name="revision">${{ github.sha }}<\/param>/g' home:chyyran:librashader/librashader/_service
- name: Vendor sources for Open Build Service
run: |
cd home:chyyran:librashader/librashader/
rm *.obscpio
osc service mr
- name: Build package
run: |
cd home:chyyran:librashader/librashader/
osc build --no-verify --trust-all-projects ${{ matrix.repo }} x86_64 ${{ matrix.spec }}
publish-obs:
needs: build-obs-binary
if: github.repository == 'SnowflakePowered/librashader'
runs-on: ubuntu-latest
container: fedora:39

495
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ members = [
resolver = "2"
[workspace.dependencies]
windows = "0.52.0"
windows = "0.58.0"
[workspace.metadata.release]

View file

@ -222,7 +222,7 @@ in both the Rust and C API without an increase to either `LIBRASHADER_CURRENT_VE
While librashader requires nightly Rust, the following MSRV policy is enforced for unstable library features.
* Windows and macOS: **latest** nightly
* Linux: **1.70**
* Linux: **1.76**
A CI job runs weekly to ensure librashader continues to build on nightly. Note that the MSRV is only intended to ease distribution on Linux and is allowed to change any time. It generally tracks the latest version of Rust available in the latest version of Ubuntu, but this may change with no warning in a patch release.

View file

@ -2,7 +2,7 @@
name = "librashader-cache"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -12,8 +12,8 @@ description = "RetroArch shaders for all."
[dependencies]
serde = { version = "1.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8", features = ["serialize"] }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0", features = ["serialize"] }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
platform-dirs = "0.3.0"
blake3 = { version = "1.3.3" }
thiserror = "1.0.38"

View file

@ -2,7 +2,7 @@
//! here because of the orphan rule.
use crate::{CacheKey, Cacheable};
use windows::core::ComInterface;
use windows::core::Interface;
impl CacheKey for windows::Win32::Graphics::Direct3D::ID3DBlob {
fn hash_bytes(&self) -> &[u8] {

View file

@ -3,7 +3,7 @@ name = "librashader-capi"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -25,6 +25,8 @@ runtime-d3d9 = ["windows", "librashader/runtime-d3d9", "windows/Win32_Graphics_D
runtime-vulkan = ["ash", "librashader/runtime-vk"]
runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"]
reflect-unstable = []
__cbindgen_internal = ["runtime-all"]
# make runtime-metal depend on this, so its automatically implied.
@ -42,7 +44,7 @@ sptr = "0.3.2"
[dependencies.librashader]
path = "../librashader"
version = "0.2.8"
version = "0.3.0"
default-features = false
features = ["reflect", "presets", "preprocess"]

View file

@ -75,7 +75,7 @@ pub mod error;
mod ffi;
pub mod presets;
#[cfg(feature = "reflect")]
#[cfg(feature = "reflect-unstable")]
#[doc(hidden)]
pub mod reflect;

View file

@ -3,12 +3,11 @@ use crate::ctypes::{
};
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
use crate::ffi::extern_fn;
use librashader::runtime::d3d11::{
D3D11InputView, D3D11OutputView, FilterChain, FilterChainOptions, FrameOptions,
};
use librashader::runtime::d3d11::{FilterChain, FilterChainOptions, FrameOptions};
use std::ffi::c_char;
use std::ffi::CStr;
use std::mem::{ManuallyDrop, MaybeUninit};
use std::ops::Deref;
use std::ptr::NonNull;
use std::slice;
use windows::Win32::Graphics::Direct3D11::{
@ -16,32 +15,19 @@ use windows::Win32::Graphics::Direct3D11::{
};
use crate::LIBRASHADER_API_VERSION;
use librashader::runtime::{FilterChainParameters, Size, Viewport};
use librashader::runtime::{FilterChainParameters, Viewport};
/// Direct3D 11 parameters for the source image.
#[repr(C)]
pub struct libra_source_image_d3d11_t {
/// A shader resource view into the source image
pub handle: ManuallyDrop<ID3D11ShaderResourceView>,
/// The width of the source image.
/// This is currently ignored.
pub width: u32,
/// The height of the source image.
/// This is currently ignored.
pub height: u32,
}
impl TryFrom<libra_source_image_d3d11_t> for D3D11InputView {
type Error = LibrashaderError;
fn try_from(value: libra_source_image_d3d11_t) -> Result<Self, Self::Error> {
let handle = value.handle.clone();
Ok(D3D11InputView {
handle: ManuallyDrop::into_inner(handle),
size: Size::new(value.width, value.height),
})
}
}
/// Options for Direct3D 11 filter chain creation.
#[repr(C)]
#[derive(Default, Debug, Clone)]
@ -251,19 +237,14 @@ extern_fn! {
let viewport = Viewport {
x: viewport.x,
y: viewport.y,
output: D3D11OutputView {
size: Size::new(viewport.width, viewport.height),
handle: ManuallyDrop::into_inner(out.clone()),
},
output: ManuallyDrop::into_inner(out.clone()),
mvp,
};
let options = options.map(FromUninit::from_uninit);
let image = image.try_into()?;
unsafe {
chain.frame(device_context.as_deref(), image, &viewport, frame_count, options.as_ref())?;
chain.frame(device_context.as_deref(), image.handle.deref(), &viewport, frame_count, options.as_ref())?;
}
}
}

View file

@ -26,11 +26,11 @@ pub struct libra_source_image_d3d12_t {
pub resource: ManuallyDrop<ID3D12Resource>,
/// A CPU descriptor handle to a shader resource view of the image.
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
/// The format of the image.
/// This is currently ignored.
pub format: DXGI_FORMAT,
/// The width of the source image.
/// This is currently ignored.
pub width: u32,
/// The height of the source image.
/// This is currently ignored.
pub height: u32,
}
@ -104,8 +104,6 @@ impl TryFrom<libra_source_image_d3d12_t> for D3D12InputImage {
Ok(D3D12InputImage {
resource: ManuallyDrop::into_inner(resource),
descriptor: value.descriptor,
size: Size::new(value.width, value.height),
format: value.format,
})
}
}

View file

@ -3,7 +3,7 @@ name = "librashader-common"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"

View file

@ -42,6 +42,12 @@ use num_traits::AsPrimitive;
use std::convert::Infallible;
use std::str::FromStr;
#[derive(Debug, Clone)]
pub enum ShaderStorage {
Path(std::path::PathBuf),
String(String),
}
#[repr(u32)]
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, Hash)]
/// Supported image formats for textures.

View file

@ -3,7 +3,7 @@ name = "librashader-preprocess"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -14,7 +14,7 @@ description = "RetroArch shaders for all."
[dependencies]
thiserror = "1.0.37"
nom = "7.1.1"
librashader-common = { path = "../librashader-common", version = "0.2.8" }
librashader-common = { path = "../librashader-common", version = "0.3.0" }
encoding_rs = "0.8.31"
[features]

View file

@ -17,7 +17,6 @@ use crate::include::read_source;
pub use error::*;
use librashader_common::map::FastHashMap;
use librashader_common::ImageFormat;
use std::path::Path;
/// The source file for a single shader pass.
#[derive(Debug, Clone, PartialEq)]
@ -58,8 +57,8 @@ pub struct ShaderParameter {
impl ShaderSource {
/// Load the source file at the given path, resolving includes relative to the location of the
/// source file.
pub fn load(path: impl AsRef<Path>) -> Result<ShaderSource, PreprocessError> {
load_shader_source(path)
pub fn load(file: &librashader_common::ShaderStorage) -> Result<ShaderSource, PreprocessError> {
load_shader_source(file)
}
}
@ -78,8 +77,14 @@ impl SourceOutput for String {
}
}
pub(crate) fn load_shader_source(path: impl AsRef<Path>) -> Result<ShaderSource, PreprocessError> {
let source = read_source(path)?;
pub(crate) fn load_shader_source(
file: &librashader_common::ShaderStorage,
) -> Result<ShaderSource, PreprocessError> {
let source = match file {
librashader_common::ShaderStorage::Path(path) => read_source(path)?,
librashader_common::ShaderStorage::String(s) => s.to_string(),
};
let meta = pragma::parse_pragma_meta(&source)?;
let text = stage::process_stages(&source)?;
let parameters = FastHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
@ -100,9 +105,9 @@ mod test {
#[test]
pub fn load_file() {
let result = load_shader_source(
"../test/slang-shaders/blurs/shaders/royale/blur3x3-last-pass.slang",
)
let result = load_shader_source(&librashader_common::ShaderStorage::Path(
"../test/slang-shaders/blurs/shaders/royale/blur3x3-last-pass.slang".into(),
))
.unwrap();
eprintln!("{:#}", result.vertex)
}

View file

@ -3,7 +3,7 @@ name = "librashader-presets"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
thiserror = "1.0.37"
nom = "7.1.1"
nom_locate = "4.0.0"
librashader-common = { path = "../librashader-common", version = "0.2.8" }
librashader-common = { path = "../librashader-common", version = "0.3.0" }
num-traits = "0.2"
once_cell = "1"
# we don't need unicode

View file

@ -326,6 +326,10 @@ impl WildcardContext {
}
}
/// Convert the context into a string hashmap.
///
/// This is a one way conversion, and will normalize rotation context items
/// into `VID-FINAL-ROT`.
pub fn to_hashmap(mut self) -> FastHashMap<String, String> {
let mut map = FastHashMap::default();
let last_user_rot = self

View file

@ -115,7 +115,7 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
let shader = ShaderPassConfig {
id,
name,
name: librashader_common::ShaderStorage::Path(name),
alias: shader_values.iter().find_map(|f| match f {
Value::Alias(_, value) => Some(value.to_string()),
_ => None,

View file

@ -23,7 +23,7 @@ use crate::extract_if::MakeExtractIf;
#[derive(Debug)]
pub enum Value {
ShaderCount(i32),
FeedbackPass(i32),
FeedbackPass(#[allow(unused)] i32),
Shader(i32, PathBuf),
ScaleX(i32, ScaleFactor),
ScaleY(i32, ScaleFactor),

View file

@ -10,7 +10,7 @@ pub struct ShaderPassConfig {
/// The index of the shader pass relative to its parent preset.
pub id: i32,
/// The fully qualified path to the shader pass source file.
pub name: PathBuf,
pub name: librashader_common::ShaderStorage,
/// The alias of the shader pass if available.
pub alias: Option<String>,
/// The filtering mode that this shader pass should expect.

View file

@ -3,7 +3,7 @@ name = "librashader-reflect"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -18,9 +18,9 @@ bytemuck = "1.13.0"
thiserror = "1.0.37"
bitflags = "2.4.2"
librashader-common = { path = "../librashader-common", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-common = { path = "../librashader-common", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1", optional = true }
@ -46,3 +46,5 @@ cross = [ "spirv_cross", "spirv_cross/glsl", "spirv_cross/hlsl", "spirv_cross/ms
naga = [ "rspirv", "spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ]
serialize = [ "serde" ]
msl = [ "spirv_cross/msl", "naga/msl-out" ]
unstable-naga-in = ["naga/glsl-in"]

View file

@ -87,6 +87,11 @@ impl HlslBufferAssignments {
}
}
// Sometimes SPIRV-cross will assign variables to "global"
if Self::find_mangled_name("global", uniform_name, mangled_name) {
return true;
}
return false;
}
}

View file

@ -6,7 +6,7 @@ use thiserror::Error;
#[derive(Error, Debug)]
pub enum ShaderCompileError {
/// Compile error from naga.
#[cfg(feature = "unstable-naga")]
#[cfg(feature = "unstable-naga-in")]
#[error("shader")]
NagaCompileError(Vec<naga::front::glsl::Error>),
@ -131,7 +131,7 @@ pub enum ShaderReflectError {
NagaReflectError(#[from] naga::WithSpan<naga::valid::ValidationError>),
}
#[cfg(feature = "unstable-naga")]
#[cfg(feature = "unstable-naga-in")]
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
ShaderCompileError::NagaCompileError(err)

View file

@ -40,12 +40,9 @@
//! ```
//!
//! ## What's with all the traits?
//! librashader-reflect is designed to be compiler-agnostic. In the future, we will allow usage of
//! [naga](https://docs.rs/naga/latest/naga/index.html), a pure-Rust shader compiler, when it has
//! matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
//!
//! In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::front::SpirvCompilation),
//! which does transpilation via [glslang](https://github.com/KhronosGroup/glslang) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross).
//! librashader-reflect is designed to be compiler-agnostic. [naga](https://docs.rs/naga/latest/naga/index.html),
//! a pure-Rust shader compiler, as well as SPIRV-Cross via [SpirvCompilation](crate::front::SpirvCompilation)
//! is supported.
#![feature(impl_trait_in_assoc_type)]
#![feature(let_chains)]

View file

@ -1,5 +1,10 @@
#[doc(hidden)]
pub mod glsl;
#[doc(hidden)]
pub mod hlsl;
#[doc(hidden)]
pub mod msl;
use crate::error::{SemanticsErrorKind, ShaderReflectError};
@ -20,6 +25,8 @@ use spirv_cross::ErrorCode;
use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData};
/// Reflect shaders under SPIRV-Cross semantics.
///
/// SPIRV-Cross supports GLSL, HLSL, SPIR-V, and MSL targets.
#[derive(Debug)]
pub struct SpirvCross;
@ -754,7 +761,10 @@ mod test {
#[test]
pub fn test_into() {
let result = ShaderSource::load("../test/basic.slang").unwrap();
let result = ShaderSource::load(&librashader_common::ShaderStorage::Path(
"../test/basic.slang".into(),
))
.unwrap();
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();
for (_index, param) in result.parameters.iter().enumerate() {

View file

@ -120,7 +120,10 @@ mod test {
pub fn test_into() {
// let result = ShaderSource::load("../test/shaders_slang/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang").unwrap();
// let result = ShaderSource::load("../test/shaders_slang/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang").unwrap();
let result = ShaderSource::load("../test/basic.slang").unwrap();
let result = ShaderSource::load(&librashader_common::ShaderStorage::Path(
"../test/basic.slang".into(),
))
.unwrap();
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();

View file

@ -12,6 +12,7 @@ pub mod presets;
mod helper;
/// Reflection via naga.
#[cfg(feature = "naga")]
pub mod naga;

View file

@ -1,5 +1,10 @@
#[doc(hidden)]
pub mod msl;
#[doc(hidden)]
pub mod spirv;
#[doc(hidden)]
pub mod wgsl;
use crate::error::{SemanticsErrorKind, ShaderReflectError};
@ -28,6 +33,8 @@ use crate::reflect::{align_uniform_size, ReflectShader, ShaderReflection};
///
/// The Naga reflector will lower combined image samplers to split,
/// with the same bind point on descriptor group 1.
///
/// Naga supports WGSL, SPIR-V, and MSL targets.
#[derive(Debug)]
pub struct Naga;
#[derive(Debug)]

View file

@ -172,7 +172,10 @@ mod test {
#[test]
pub fn test_into() {
let result = ShaderSource::load("../test/basic.slang").unwrap();
let result = ShaderSource::load(&librashader_common::ShaderStorage::Path(
"../test/basic.slang".into(),
))
.unwrap();
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-d3d11"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -12,18 +12,21 @@ keywords = ["shader", "retroarch", "SPIR-V"]
description = "RetroArch shaders for all."
[dependencies]
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8", features = ["d3d"] }
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0", features = ["d3d"] }
thiserror = "1.0.37"
bytemuck = "1.12.3"
rayon = "1.6.1"
array-concat = "0.5.2"
[features]
debug-shader = []
[target.'cfg(windows)'.dependencies.windows]
workspace = true
features = [

View file

@ -1,4 +1,4 @@
use crate::texture::{D3D11InputView, InputTexture};
use crate::texture::InputTexture;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_common::map::FastHashMap;
@ -21,8 +21,8 @@ use crate::graphics_pipeline::D3D11State;
use crate::luts::LutTexture;
use crate::options::{FilterChainOptionsD3D11, FrameOptionsD3D11};
use crate::samplers::SamplerSet;
use crate::util::d3d11_compile_bound_shader;
use crate::{error, util, D3D11OutputView};
use crate::util::{d3d11_compile_bound_shader, GetSize};
use crate::{error, util};
use librashader_cache::cache_shader_object;
use librashader_cache::CachedCompilation;
use librashader_presets::context::VideoDriver;
@ -36,7 +36,8 @@ use librashader_runtime::scaling::ScaleFramebuffer;
use librashader_runtime::uniforms::UniformStorage;
use rayon::prelude::*;
use windows::Win32::Graphics::Direct3D11::{
ID3D11Buffer, ID3D11Device, ID3D11DeviceContext, D3D11_BIND_CONSTANT_BUFFER, D3D11_BUFFER_DESC,
ID3D11Buffer, ID3D11Device, ID3D11DeviceContext, ID3D11RenderTargetView,
ID3D11ShaderResourceView, D3D11_BIND_CONSTANT_BUFFER, D3D11_BUFFER_DESC,
D3D11_CPU_ACCESS_WRITE, D3D11_CREATE_DEVICE_SINGLETHREADED, D3D11_RESOURCE_MISC_GENERATE_MIPS,
D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_USAGE_DYNAMIC,
};
@ -347,7 +348,7 @@ impl FilterChainD3D11 {
fn push_history(
&mut self,
ctx: &ID3D11DeviceContext,
input: &D3D11InputView,
input: &ID3D11ShaderResourceView,
) -> error::Result<()> {
if let Some(mut back) = self.history_framebuffers.pop_back() {
back.copy_from(ctx, input)?;
@ -399,8 +400,8 @@ impl FilterChainD3D11 {
pub unsafe fn frame(
&mut self,
ctx: Option<&ID3D11DeviceContext>,
input: D3D11InputView,
viewport: &Viewport<D3D11OutputView>,
input: &ID3D11ShaderResourceView,
viewport: &Viewport<ID3D11RenderTargetView>,
frame_count: usize,
options: Option<&FrameOptionsD3D11>,
) -> error::Result<()> {
@ -447,8 +448,8 @@ impl FilterChainD3D11 {
// rescale render buffers to ensure all bindings are valid.
OwnedImage::scale_framebuffers(
source.size(),
viewport.output.size,
original.view.size,
viewport.output.size()?,
original.view.size()?,
&mut self.output_framebuffers,
&mut self.feedback_framebuffers,
passes,
@ -481,7 +482,6 @@ impl FilterChainD3D11 {
source.filter = pass.config.filter;
source.wrap_mode = pass.config.wrap_mode;
let target = &self.output_framebuffers[index];
let size = target.size;
pass.draw(
ctx,
index,
@ -491,15 +491,12 @@ impl FilterChainD3D11 {
viewport,
&original,
&source,
RenderTarget::identity(&target.as_output()?),
RenderTarget::identity(&target.create_render_target_view()?),
QuadType::Offscreen,
)?;
source = InputTexture {
view: D3D11InputView {
handle: target.create_shader_resource_view()?,
size,
},
view: target.create_shader_resource_view()?,
filter: pass.config.filter,
wrap_mode: pass.config.wrap_mode,
};

View file

@ -16,13 +16,14 @@ use librashader_runtime::filter_pass::FilterPassMeta;
use librashader_runtime::quad::QuadType;
use librashader_runtime::render_target::RenderTarget;
use windows::Win32::Graphics::Direct3D11::{
ID3D11Buffer, ID3D11DeviceContext, ID3D11InputLayout, ID3D11PixelShader, ID3D11SamplerState,
ID3D11ShaderResourceView, ID3D11VertexShader, D3D11_MAPPED_SUBRESOURCE,
D3D11_MAP_WRITE_DISCARD, D3D11_VIEWPORT,
ID3D11Buffer, ID3D11DeviceContext, ID3D11InputLayout, ID3D11PixelShader,
ID3D11RenderTargetView, ID3D11SamplerState, ID3D11ShaderResourceView, ID3D11VertexShader,
D3D11_MAPPED_SUBRESOURCE, D3D11_MAP_WRITE_DISCARD, D3D11_VIEWPORT,
};
use crate::error;
use crate::samplers::SamplerSet;
use crate::{error, D3D11OutputView};
use crate::util::GetSize;
use librashader_runtime::uniforms::{UniformStorage, UniformStorageAccess};
pub struct ConstantBufferBinding {
@ -55,7 +56,7 @@ const NULL_TEXTURES: &[Option<ID3D11ShaderResourceView>; 16] = &[
impl TextureInput for InputTexture {
fn size(&self) -> Size<u32> {
self.view.size
self.view.size().unwrap_or(Size::default())
}
}
@ -77,7 +78,7 @@ impl BindSemantics for FilterPass {
_device: &Self::DeviceContext,
) {
let (texture_binding, sampler_binding) = descriptors;
texture_binding[binding.binding as usize] = Some(texture.view.handle.clone());
texture_binding[binding.binding as usize] = Some(texture.view.clone());
sampler_binding[binding.binding as usize] =
Some(samplers.get(texture.wrap_mode, texture.filter).clone());
}
@ -149,15 +150,15 @@ impl FilterPass {
parent: &FilterCommon,
frame_count: u32,
options: &FrameOptionsD3D11,
viewport: &Viewport<D3D11OutputView>,
viewport: &Viewport<ID3D11RenderTargetView>,
original: &InputTexture,
source: &InputTexture,
output: RenderTarget<D3D11OutputView>,
output: RenderTarget<ID3D11RenderTargetView>,
vbo_type: QuadType,
) -> error::Result<()> {
if self.config.mipmap_input && !parent.disable_mipmaps {
unsafe {
ctx.GenerateMips(&source.view.handle);
ctx.GenerateMips(&source.view);
}
}
unsafe {
@ -170,14 +171,17 @@ impl FilterPass {
let mut samplers: [Option<ID3D11SamplerState>; 16] = std::array::from_fn(|_| None);
let descriptors = (&mut textures, &mut samplers);
let output_size = output.output.size()?;
let viewport_size = viewport.output.size()?;
self.build_semantics(
pass_index,
parent,
output.mvp,
frame_count,
options,
output.output.size,
viewport.output.size,
output_size,
viewport_size,
descriptors,
original,
source,
@ -241,15 +245,16 @@ impl FilterPass {
std::mem::size_of::<Option<windows::core::IUnknown>>()
== std::mem::size_of::<windows::core::IUnknown>()
);
ctx.PSSetShaderResources(0, Some(std::mem::transmute(textures.as_ref())));
ctx.PSSetSamplers(0, Some(std::mem::transmute(samplers.as_ref())));
ctx.OMSetRenderTargets(Some(&[Some(output.output.handle.clone())]), None);
ctx.OMSetRenderTargets(Some(&[Some(output.output.clone())]), None);
ctx.RSSetViewports(Some(&[D3D11_VIEWPORT {
TopLeftX: output.x,
TopLeftY: output.y,
Width: output.output.size.width as f32,
Height: output.output.size.height as f32,
Width: output_size.width as f32,
Height: output_size.height as f32,
MinDepth: 0.0,
MaxDepth: 1.0,
}]))

View file

@ -1,11 +1,10 @@
use crate::error;
use crate::error::{assume_d3d11_init, FilterChainError};
use crate::texture::D3D11InputView;
use crate::util::d3d11_get_closest_format;
use crate::{error, D3D11OutputView};
use librashader_common::{ImageFormat, Size};
use librashader_presets::Scale2D;
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
use windows::core::ComInterface;
use windows::core::Interface;
use windows::Win32::Graphics::Direct3D::D3D_SRV_DIMENSION_TEXTURE2D;
use windows::Win32::Graphics::Direct3D11::{
ID3D11Device, ID3D11DeviceContext, ID3D11RenderTargetView, ID3D11ShaderResourceView,
@ -171,33 +170,25 @@ impl OwnedImage {
Ok(rtv)
}
pub fn as_output(&self) -> error::Result<D3D11OutputView> {
let rtv = self.create_render_target_view()?;
Ok(D3D11OutputView {
handle: rtv,
size: self.size,
})
}
pub fn copy_from(
&mut self,
ctx: &ID3D11DeviceContext,
image: &D3D11InputView,
image: &ID3D11ShaderResourceView,
) -> error::Result<()> {
let original_resource: ID3D11Texture2D = unsafe {
let resource = image.handle.GetResource()?;
let resource = image.GetResource()?;
resource.cast()?
};
let format = unsafe {
let (format, image_size) = unsafe {
let mut desc = Default::default();
original_resource.GetDesc(&mut desc);
desc.Format
(desc.Format, Size::new(desc.Width, desc.Height))
};
if self.size != image.size || format != self.format {
if self.size != image_size || format != self.format {
// eprintln!("[history] resizing");
self.init(image.size, ImageFormat::from(format))?;
self.init(image_size, ImageFormat::from(format))?;
}
unsafe {

View file

@ -25,5 +25,3 @@ use librashader_runtime::impl_filter_chain_parameters;
impl_filter_chain_parameters!(FilterChainD3D11);
pub use filter_chain::FilterChainD3D11;
pub use texture::D3D11InputView;
pub use texture::D3D11OutputView;

View file

@ -1,6 +1,6 @@
use crate::error;
use crate::error::assume_d3d11_init;
use crate::texture::InputTexture;
use crate::{error, D3D11InputView};
use librashader_common::{FilterMode, WrapMode};
use librashader_runtime::image::Image;
use librashader_runtime::scaling::MipmapSize;
@ -139,10 +139,7 @@ impl LutTexture {
handle,
desc,
image: InputTexture {
view: D3D11InputView {
handle: srv,
size: source.size,
},
view: srv,
filter,
wrap_mode,
},

View file

@ -1,33 +1,11 @@
use crate::error::Result;
use crate::framebuffer::OwnedImage;
use librashader_common::{FilterMode, Size, WrapMode};
use windows::Win32::Graphics::Direct3D11::{ID3D11RenderTargetView, ID3D11ShaderResourceView};
/// An image view for use as a shader resource.
///
/// Contains an `ID3D11ShaderResourceView`, and a size.
#[derive(Debug, Clone)]
pub struct D3D11InputView {
/// A handle to the shader resource view.
pub handle: ID3D11ShaderResourceView,
/// The size of the image.
pub size: Size<u32>,
}
/// An image view for use as a render target.
///
/// Contains an `ID3D11RenderTargetView`, and a size.
#[derive(Debug, Clone)]
pub struct D3D11OutputView {
/// A handle to the render target view.
pub handle: ID3D11RenderTargetView,
/// The size of the image.
pub size: Size<u32>,
}
use librashader_common::{FilterMode, WrapMode};
use windows::Win32::Graphics::Direct3D11::ID3D11ShaderResourceView;
#[derive(Debug, Clone)]
pub struct InputTexture {
pub view: D3D11InputView,
pub view: ID3D11ShaderResourceView,
pub filter: FilterMode,
pub wrap_mode: WrapMode,
}
@ -39,10 +17,7 @@ impl InputTexture {
filter: FilterMode,
) -> Result<Self> {
Ok(InputTexture {
view: D3D11InputView {
handle: fbo.create_shader_resource_view()?,
size: fbo.size,
},
view: fbo.create_shader_resource_view()?,
filter,
wrap_mode,
})

View file

@ -1,7 +1,8 @@
use crate::error;
use crate::error::assume_d3d11_init;
use librashader_common::Size;
use std::slice;
use windows::core::PCSTR;
use windows::core::{Interface, PCSTR};
use windows::Win32::Graphics::Direct3D::Fxc::{
D3DCompile, D3DCOMPILE_DEBUG, D3DCOMPILE_OPTIMIZATION_LEVEL3, D3DCOMPILE_SKIP_OPTIMIZATION,
};
@ -146,7 +147,7 @@ pub fn d3d11_compile_bound_shader<'a, T, L>(
factory: ShaderFactory<'a, L, T>,
) -> error::Result<T>
where
L: windows::core::IntoParam<ID3D11ClassLinkage>,
L: windows::core::Param<ID3D11ClassLinkage>,
{
unsafe {
// SAFETY: slice as valid for as long as vs_blob is alive.
@ -175,3 +176,39 @@ pub fn d3d11_create_input_layout(
Ok(input_layout)
}
}
pub(crate) trait GetSize {
fn size(&self) -> error::Result<Size<u32>>;
}
impl GetSize for ID3D11RenderTargetView {
fn size(&self) -> error::Result<Size<u32>> {
let parent = unsafe { self.GetResource()?.cast::<ID3D11Texture2D>()? };
let mut desc = Default::default();
unsafe {
parent.GetDesc(&mut desc);
}
Ok(Size {
height: desc.Height,
width: desc.Width,
})
}
}
impl GetSize for ID3D11ShaderResourceView {
fn size(&self) -> error::Result<Size<u32>> {
let parent = unsafe { self.GetResource()?.cast::<ID3D11Texture2D>()? };
let mut desc = Default::default();
unsafe {
parent.GetDesc(&mut desc);
}
Ok(Size {
height: desc.Height,
width: desc.Width,
})
}
}

View file

@ -144,6 +144,7 @@ where
)
};
let hwnd = hwnd?;
sample.bind_to_window(&hwnd).unwrap();
unsafe { ShowWindow(hwnd, SW_SHOW) };
@ -246,7 +247,6 @@ pub mod d3d11_hello_triangle {
use librashader_runtime::image::Image;
use librashader_runtime_d3d11::options::FilterChainOptionsD3D11;
use librashader_runtime_d3d11::FilterChainD3D11;
use librashader_runtime_d3d11::{D3D11InputView, D3D11OutputView};
use std::slice;
use std::time::Instant;
use texture::ExampleTexture;
@ -437,7 +437,7 @@ pub mod d3d11_hello_triangle {
drop(resources.backbuffer.take());
resources
.swapchain
.ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0)
.ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, DXGI_SWAP_CHAIN_FLAG(0))
.unwrap_or_else(|f| eprintln!("{f:?}"));
let (rtv, backbuffer) = create_rtv(&self.device, &resources.swapchain)?;
@ -572,23 +572,11 @@ pub mod d3d11_hello_triangle {
self.filter
.frame(
None,
D3D11InputView {
handle: srv,
size: Size {
width: tex2d_desc.Width,
height: tex2d_desc.Height,
},
},
&srv,
&Viewport {
x: 0f32,
y: 0f32,
output: D3D11OutputView {
size: Size {
width: backbuffer_desc.Width,
height: backbuffer_desc.Height,
},
handle: resources.backbuffer_rtv.as_ref().unwrap().clone(),
},
output: resources.backbuffer_rtv.as_ref().unwrap().clone(),
mvp: None,
},
resources.frame_count,
@ -606,7 +594,10 @@ pub mod d3d11_hello_triangle {
}
unsafe {
resources.swapchain.Present(0, 0).ok()?;
resources
.swapchain
.Present(0, DXGI_PRESENT::default())
.ok()?;
}
resources.frame_count += 1;
Ok(())

View file

@ -12,8 +12,7 @@ use librashader_runtime_d3d11::options::FilterChainOptionsD3D11;
// const FILTER_PATH: &str =
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID].slangp";
const FILTER_PATH: &str =
"../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp";
const FILTER_PATH: &str = "../test/shaders_slang/crt/crt-royale.slangp";
// const FILTER_PATH: &str = "../test/slang-shaders/test/history.slangp";
// const FILTER_PATH: &str = "../test/slang-shaders/test/feedback.slangp";
@ -61,7 +60,7 @@ fn triangle_d3d11() {
FILTER_PATH,
Some(&FilterChainOptionsD3D11 {
force_no_mipmaps: false,
disable_cache: false,
disable_cache: true,
}),
// replace below with 'None' for the triangle
// None,

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-d3d12"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -12,12 +12,12 @@ keywords = ["shader", "retroarch", "SPIR-V"]
description = "RetroArch shaders for all."
[dependencies]
librashader-common = { path = "../librashader-common", features = ["d3d12"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8", features = ["dxil"] }
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8", features = ["d3d"] }
librashader-common = { path = "../librashader-common", features = ["d3d12"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0", features = ["dxil"] }
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0", features = ["d3d"] }
thiserror = "1.0.37"

View file

@ -30,7 +30,7 @@ use librashader_runtime::uniforms::UniformStorage;
use std::collections::VecDeque;
use std::mem::ManuallyDrop;
use std::path::Path;
use windows::core::ComInterface;
use windows::core::Interface;
use windows::Win32::Foundation::CloseHandle;
use windows::Win32::Graphics::Direct3D::Dxc::{
CLSID_DxcCompiler, CLSID_DxcLibrary, CLSID_DxcValidator, DxcCreateInstance, IDxcCompiler,

View file

@ -18,7 +18,7 @@ use librashader_runtime::quad::QuadType;
use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
use std::ops::Deref;
use windows::core::ComInterface;
use windows::core::Interface;
use windows::Win32::Foundation::RECT;
use windows::Win32::Graphics::Direct3D12::{
ID3D12GraphicsCommandList, ID3D12GraphicsCommandList4, D3D12_RENDER_PASS_BEGINNING_ACCESS,

View file

@ -9,7 +9,7 @@ use librashader_reflect::back::ShaderCompilerOutput;
use std::mem::ManuallyDrop;
use std::ops::Deref;
use widestring::u16cstr;
use windows::core::ComInterface;
use windows::core::Interface;
use windows::Win32::Foundation::BOOL;
use windows::Win32::Graphics::Direct3D::Dxc::{
CLSID_DxcLibrary, DxcCreateInstance, IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator, DXC_CP,

View file

@ -8,8 +8,6 @@ use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT;
pub struct D3D12InputImage {
pub resource: ID3D12Resource,
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
pub size: Size<u32>,
pub format: DXGI_FORMAT,
}
#[derive(Clone)]
@ -117,11 +115,12 @@ impl InputTexture {
filter: FilterMode,
wrap_mode: WrapMode,
) -> InputTexture {
let desc = unsafe { image.resource.GetDesc() };
InputTexture {
resource: image.resource,
descriptor: InputDescriptor::Raw(image.descriptor),
size: image.size,
format: image.format,
size: Size::new(desc.Width as u32, desc.Height),
format: desc.Format,
wrap_mode,
filter,
}

View file

@ -4,7 +4,7 @@ use crate::error::assume_d3d12_init;
use std::mem::ManuallyDrop;
use std::u64;
use widestring::{u16cstr, U16CStr};
use windows::core::{ComInterface, PCWSTR};
use windows::core::{Interface, PCWSTR};
use windows::Win32::Graphics::Direct3D::Dxc::{
DxcValidatorFlags_InPlaceEdit, IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator, DXC_CP,
DXC_CP_UTF8,

View file

@ -109,7 +109,8 @@ where
)
};
sample.bind_to_window(&hwnd)?;
let hwnd = hwnd?;
sample.bind_to_window(&hwnd).unwrap();
unsafe { ShowWindow(hwnd, SW_SHOW) };
loop {
@ -187,8 +188,7 @@ fn get_hardware_adapter(factory: &IDXGIFactory4) -> Result<IDXGIAdapter1> {
for i in 0.. {
let adapter = unsafe { factory.EnumAdapters1(i)? };
let mut desc = Default::default();
unsafe { adapter.GetDesc1(&mut desc)? };
let mut desc = unsafe { adapter.GetDesc1()? };
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32) != DXGI_ADAPTER_FLAG_NONE.0 as u32 {
// Don't select the Basic Render Driver adapter. If you want a
@ -529,7 +529,9 @@ pub mod d3d12_hello_triangle {
unsafe { resources.command_queue.ExecuteCommandLists(&[command_list]) };
// Present the frame.
unsafe { resources.swap_chain.Present(1, 0) }.ok().unwrap();
unsafe { resources.swap_chain.Present(1, DXGI_PRESENT::default()) }
.ok()
.unwrap();
wait_for_previous_frame(resources);
self.framecount += 1;
@ -624,11 +626,6 @@ pub mod d3d12_hello_triangle {
D3D12InputImage {
resource: resources.framebuffer.clone(),
descriptor: framebuffer,
size: Size::new(
resources.viewport.Width as u32,
resources.viewport.Height as u32,
),
format: DXGI_FORMAT_R8G8B8A8_UNORM,
},
&Viewport {
x: 0.0,

View file

@ -6,12 +6,12 @@ use crate::hello_triangle::{DXSample, SampleCommandLine};
fn triangle_d3d12() {
let sample = hello_triangle::d3d12_hello_triangle::Sample::new(
// "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// "../test/shaders_slang/crt/crt-lottes.slangp",
"../test/shaders_slang/crt/crt-lottes.slangp",
// "../test/basic.slangp",
// "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.slangp",
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp",
// "../test/slang-shaders/test/feedback.slangp",
"../test/shaders_slang/test/history.slangp",
// "../test/shaders_slang/test/history.slangp",
// "../test/shaders_slang/crt/crt-royale.slangp",
// "../test/slang-shaders/vhs/VHSPro.slangp",
&SampleCommandLine {

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-d3d9"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -12,18 +12,20 @@ keywords = ["shader", "retroarch", "SPIR-V"]
description = "RetroArch shaders for all."
[dependencies]
librashader-common = { path = "../librashader-common", features = ["d3d9", "d3d11"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8", features = ["d3d"] }
librashader-common = { path = "../librashader-common", features = ["d3d9", "d3d11"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0", features = ["d3d"] }
thiserror = "1.0.37"
bytemuck = "1.12.3"
array-concat = "0.5.2"
num-traits = "0.2.18"
windows-core = "0.58.0"
[target.'cfg(windows)'.dependencies.windows]
workspace = true
features = [

View file

@ -62,7 +62,7 @@ impl ConstantRegister {
.iter()
.find_map(|(mangled_name, register)| {
if context
.fragment_buffers
.vertex_buffers
.contains_uniform(uniform_name, mangled_name)
{
Some(register)
@ -98,15 +98,17 @@ impl ContextOffset<D3D9UniformBinder, ConstantRegister, IDirect3DDevice9> for Co
pub(crate) type D3D9UniformStorage =
UniformStorage<D3D9UniformBinder, ConstantRegister, Box<[u8]>, Box<[u8]>, IDirect3DDevice9>;
/// Trait for uniform scalars that can be converted to f32 as required by SM3.0
/// Mostly used to get around orphan rule.
#[allow(unused)]
trait D3D9UniformScalar: UniformScalar + AsPrimitive<f32> + Copy {}
impl D3D9UniformScalar for u32 {}
impl D3D9UniformScalar for i32 {}
impl D3D9UniformScalar for f32 {}
pub(crate) struct D3D9UniformBinder;
impl<T> BindUniform<ConstantRegister, T, IDirect3DDevice9> for D3D9UniformBinder
where
T: D3D9UniformScalar,
impl<T: D3D9UniformScalar> BindUniform<ConstantRegister, T, IDirect3DDevice9>
for D3D9UniformBinder
{
fn bind_uniform(
_block: UniformMemberBlock,

View file

@ -1,6 +1,6 @@
use std::ffi::c_void;
use windows::core::imp::BOOL;
use windows::core::{IntoParam, HRESULT, PCSTR};
use windows::core::{Param, HRESULT, PCSTR};
use windows::Win32::Graphics::Direct3D::{ID3DBlob, ID3DInclude, D3D_SHADER_MACRO};
const D3DERR_INVALIDCALL: u32 = 0x8876086c;
@ -49,17 +49,17 @@ pub unsafe fn D3DXCompileShader<P1, P2, P3>(
ppconstanttable: Option<*mut Option<ID3DXConstantTable>>,
) -> ::windows::core::Result<()>
where
P1: IntoParam<ID3DInclude>,
P2: IntoParam<PCSTR>,
P3: IntoParam<PCSTR>,
P1: Param<ID3DInclude>,
P2: Param<PCSTR>,
P3: Param<PCSTR>,
{
raw::D3DXCompileShader(
psrcdata,
srcdatasize,
::core::mem::transmute(pdefines.unwrap_or(::std::ptr::null())),
pinclude.into_param().abi(),
pfunctioname.into_param().abi(),
pprofile.into_param().abi(),
pinclude.param().abi(),
pfunctioname.param().abi(),
pprofile.param().abi(),
flags,
::core::mem::transmute(ppcode),
::core::mem::transmute(pperrormsgs.unwrap_or(::std::ptr::null_mut())),
@ -68,9 +68,11 @@ where
.ok()
}
#[repr(transparent)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ID3DXConstantTable(windows::core::IUnknown);
windows::core::imp::define_interface!(
ID3DXConstantTable,
ID3DXConstantTable_Vtbl,
0xab3c758f_93e_4356_b7_62_4d_b1_8f_1b_3a1
);
#[allow(dead_code)]
impl ID3DXConstantTable {
@ -79,7 +81,8 @@ impl ID3DXConstantTable {
p_function: *const c_void,
) -> windows::core::Result<ID3DXConstantTable> {
let mut result__ = ::std::mem::zeroed();
raw::D3DXGetShaderConstantTable(p_function, &mut result__).from_abi(result__)
raw::D3DXGetShaderConstantTable(p_function, &mut result__)
.and_then(|| windows::core::Type::from_abi(result__))
}
#[allow(non_snake_case)]
@ -150,12 +153,12 @@ impl ID3DXConstantTable {
pname: P,
) -> windows::core::Result<D3DXHANDLE>
where
P: IntoParam<PCSTR>,
P: Param<PCSTR>,
{
let handle = (windows::core::Interface::vtable(self).GetConstantByName)(
windows::core::Interface::as_raw(self),
hconstant.unwrap_or(D3DXHANDLE(std::ptr::null())),
pname.into_param().abi(),
pname.param().abi(),
);
if handle.0 as u32 == D3DERR_INVALIDCALL {
@ -193,11 +196,6 @@ impl ID3DXConstantTable {
}
}
impl windows::core::CanInto<windows::core::IUnknown> for ID3DXConstantTable {}
unsafe impl windows::core::Interface for ID3DXConstantTable {
type Vtable = ID3DXConstantTable_Vtbl;
}
#[repr(C)]
#[doc(hidden)]
#[allow(non_camel_case_types)]
@ -430,8 +428,3 @@ pub enum D3DXPARAMETER_TYPE {
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct D3DXHANDLE(pub *const c_void);
unsafe impl windows::core::ComInterface for ID3DXConstantTable {
const IID: windows::core::GUID =
windows::core::GUID::from_u128(0xab3c758f_93e_4356_b7_62_4d_b1_8f_1b_3a1);
}

View file

@ -6,13 +6,7 @@ use librashader_runtime::quad::{QuadType, VertexInput};
use windows::Win32::Foundation::FALSE;
use windows::Win32::Graphics::Direct3D9::{
IDirect3DDevice9, IDirect3DVertexBuffer9, IDirect3DVertexDeclaration9, D3DCMP_ALWAYS,
D3DCULL_NONE, D3DDECLMETHOD_DEFAULT, D3DDECLTYPE_FLOAT2, D3DDECLTYPE_FLOAT3,
D3DDECLTYPE_UNUSED, D3DDECLUSAGE_TEXCOORD, D3DPOOL_DEFAULT, D3DPT_TRIANGLESTRIP,
D3DRS_CLIPPING, D3DRS_CULLMODE, D3DRS_LIGHTING, D3DRS_ZENABLE, D3DRS_ZFUNC,
D3DTRANSFORMSTATETYPE, D3DTS_PROJECTION, D3DTS_VIEW, D3DVERTEXELEMENT9,
};
use windows::Win32::Graphics::Direct3D9::{IDirect3DDevice9, IDirect3DVertexBuffer9, IDirect3DVertexDeclaration9, D3DCMP_ALWAYS, D3DCULL_NONE, D3DDECLMETHOD_DEFAULT, D3DDECLTYPE_FLOAT2, D3DDECLTYPE_FLOAT3, D3DDECLTYPE_UNUSED, D3DDECLUSAGE_TEXCOORD, D3DPOOL_DEFAULT, D3DPT_TRIANGLESTRIP, D3DRS_CLIPPING, D3DRS_CULLMODE, D3DRS_LIGHTING, D3DRS_ZENABLE, D3DRS_ZFUNC, D3DTRANSFORMSTATETYPE, D3DTS_PROJECTION, D3DTS_VIEW, D3DVERTEXELEMENT9, D3DRS_COLORWRITEENABLE};
const OFFSCREEN_VBO_DATA: [VertexInput; 4] = [
VertexInput {
@ -111,6 +105,7 @@ impl DrawQuad {
device.SetRenderState(D3DRS_ZENABLE, FALSE.0 as u32)?;
device.SetRenderState(D3DRS_LIGHTING, FALSE.0 as u32)?;
device.SetRenderState(D3DRS_COLORWRITEENABLE, 0xfu32)?;
device.BeginScene()?;
device.SetStreamSource(0, &self.vbo, 0, std::mem::size_of::<VertexInput>() as u32)?;
// device.SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1)?;

View file

@ -89,6 +89,7 @@ where
)
};
let hwnd = hwnd?;
sample.bind_to_window(&hwnd).unwrap();
unsafe { ShowWindow(hwnd, SW_SHOW) };

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-gl"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -12,12 +12,12 @@ keywords = ["shader", "retroarch", "SPIR-V"]
description = "RetroArch shaders for all."
[dependencies]
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1" }
gl = "0.14.0"

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-mtl"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -14,11 +14,11 @@ description = "RetroArch shaders for all."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
librashader-common = { path = "../librashader-common", features = ["metal"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
librashader-common = { path = "../librashader-common", features = ["metal"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
thiserror = "1.0"
array-concat = "0.5.2"

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-vk"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -14,12 +14,12 @@ description = "RetroArch shaders for all."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
librashader-common = { path = "../librashader-common", features = ["vulkan"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
librashader-common = { path = "../librashader-common", features = ["vulkan"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
bytemuck = { version = "1.12.3", features = ["derive"] }
thiserror = "1.0.37"

View file

@ -2,7 +2,7 @@
name = "librashader-runtime-wgpu"
edition = "2021"
version = "0.2.8"
version = "0.3.0"
license = "MPL-2.0 OR GPL-3.0-only"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
@ -14,12 +14,12 @@ description = "RetroArch shaders for all."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8", features = ["wgsl"], default-features = false }
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0", features = ["wgsl"], default-features = false }
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
wgpu = { version = "22.0", default-features = false, features = ["wgsl"] }
image = "0.25.1"

View file

@ -25,7 +25,7 @@ use librashader_reflect::reflect::naga::{Naga, NagaLoweringOptions};
use librashader_runtime::framebuffer::FramebufferInit;
use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::scaling::ScaleFramebuffer;
use wgpu::{AdapterInfo, Device, TextureFormat};
use wgpu::{Device, TextureFormat};
use crate::error;
use crate::error::FilterChainError;

View file

@ -1,4 +1,3 @@
use crate::error::FilterChainError;
use crate::framebuffer::WgpuOutputView;
use crate::util;
use librashader_cache::cache_pipeline;

View file

@ -3,7 +3,7 @@ name = "librashader-runtime"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -12,10 +12,10 @@ keywords = ["shader", "retroarch", "SPIR-V"]
description = "RetroArch shaders for all."
[dependencies]
librashader-common = { path = "../librashader-common", version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-common = { path = "../librashader-common", version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
bytemuck = { version = "1.12.3", features = ["derive"] }
num-traits = "0.2.15"
array-concat = "0.5.2"

View file

@ -4,7 +4,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.8"
version = "0.3.0"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"
@ -13,25 +13,25 @@ keywords = ["shader", "retroarch", "SPIR-V"]
description = "RetroArch shaders for all."
[dependencies]
librashader-common = { path = "../librashader-common", version = "0.2.8" }
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.2.8", optional = true }
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.2.8", optional = true }
librashader-runtime-d3d9 = { path = "../librashader-runtime-d3d9", version = "0.2.8", optional = true }
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.2.8", optional = true }
librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.2.8", optional = true }
librashader-runtime-mtl = { path = "../librashader-runtime-mtl", version = "0.2.8", optional = true }
librashader-common = { path = "../librashader-common", version = "0.3.0" }
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.3.0", optional = true }
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.3.0", optional = true }
librashader-runtime-d3d9 = { path = "../librashader-runtime-d3d9", version = "0.3.0", optional = true }
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.3.0", optional = true }
librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.3.0", optional = true }
librashader-runtime-mtl = { path = "../librashader-runtime-mtl", version = "0.3.0", optional = true }
ash = { version = "0.38", optional = true }
halfbrown = "0.2.4"
[target.'cfg(not(all(target_vendor="apple", docsrs)))'.dependencies]
wgpu = { version = "22", default-features = false, optional = true }
librashader-runtime-wgpu = { path = "../librashader-runtime-wgpu", version = "0.2.8", optional = true }
librashader-runtime-wgpu = { path = "../librashader-runtime-wgpu", version = "0.3.0", optional = true }
wgpu-types = { version = "22", optional = true }
[target.'cfg(windows)'.dependencies.windows]

View file

@ -259,7 +259,7 @@ pub mod runtime {
options::{
FilterChainOptionsD3D11 as FilterChainOptions, FrameOptionsD3D11 as FrameOptions,
},
D3D11InputView, D3D11OutputView, FilterChainD3D11 as FilterChain,
FilterChainD3D11 as FilterChain,
};
}
@ -318,18 +318,7 @@ pub mod runtime {
#[cfg(feature = "runtime-wgpu")]
#[doc(cfg(feature = "runtime-wgpu"))]
/// Shader runtime for wgpu.
#[cfg_attr(
all(
feature = "runtime-wgpu",
all(target_vendor = "apple", feature = "docsrs")
),
doc = "\n\nThe wgpu runtime is available on macOS and iOS, but technical reasons prevent them from rendering on docs.rs.
\n\n This is because wgpu on macOS and iOS link to [metal-rs](https://github.com/gfx-rs/metal-rs), which can not build on docs.rs.
See [SSheldon/rustc-objc-exception#13](https://github.com/SSheldon/rust-objc-exception/issues/13) for more details.
\n\n The wgpu runtime is identical for all supported operating systems, so please refer to documentation from another operating system."
)]
pub mod wgpu {
#[cfg(not(all(target_vendor = "apple", feature = "docsrs")))]
pub use librashader_runtime_wgpu::{
error,
options::{

2
rust-toolchain.toml Normal file
View file

@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"

@ -1 +1 @@
Subproject commit d668788a29a390704a07fba99895ee69a6707f45
Subproject commit e04aa575febae5927db6b445a3c47b8f4221df78