Compare commits
17 commits
be4c634614
...
89090757fd
Author | SHA1 | Date | |
---|---|---|---|
Alex Janka | 89090757fd | ||
Alex Janka | 1406ddc5b3 | ||
Alex Janka | bf974ac642 | ||
d1e49b7eb4 | |||
5ef0055e05 | |||
1c6581d737 | |||
ac66b1b6f6 | |||
977975f4c7 | |||
3b9514ad38 | |||
899fb50da6 | |||
162226ce44 | |||
039fdfd41a | |||
e13bb88df2 | |||
7b375658c5 | |||
3fb6e3843e | |||
3cda5b706d | |||
4d6793d305 |
8
.github/workflows/package-obs.yml
vendored
8
.github/workflows/package-obs.yml
vendored
|
@ -19,14 +19,14 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- repo: Fedora_39
|
- repo: Fedora_40
|
||||||
spec: librashader.spec
|
spec: librashader.spec
|
||||||
can_fail: true
|
can_fail: true
|
||||||
name: Fedora 39 (.rpm)
|
name: Fedora 40 (.rpm)
|
||||||
- repo: xUbuntu_23.10
|
- repo: xUbuntu_24.04
|
||||||
spec: librashader.spec
|
spec: librashader.spec
|
||||||
can_fail: true
|
can_fail: true
|
||||||
name: Ubuntu 23.10 (.deb)
|
name: Ubuntu 24.04 (.deb)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [approve-obs-build]
|
needs: [approve-obs-build]
|
||||||
continue-on-error: ${{ matrix.can_fail }}
|
continue-on-error: ${{ matrix.can_fail }}
|
||||||
|
|
43
.github/workflows/publish-obs.yml
vendored
43
.github/workflows/publish-obs.yml
vendored
|
@ -7,50 +7,7 @@ env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
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:
|
publish-obs:
|
||||||
needs: build-obs-binary
|
|
||||||
if: github.repository == 'SnowflakePowered/librashader'
|
if: github.repository == 'SnowflakePowered/librashader'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: fedora:39
|
container: fedora:39
|
||||||
|
|
495
Cargo.lock
generated
495
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,7 @@ members = [
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
windows = "0.52.0"
|
windows = "0.58.0"
|
||||||
|
|
||||||
[workspace.metadata.release]
|
[workspace.metadata.release]
|
||||||
|
|
||||||
|
|
|
@ -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.
|
While librashader requires nightly Rust, the following MSRV policy is enforced for unstable library features.
|
||||||
|
|
||||||
* Windows and macOS: **latest** nightly
|
* 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.
|
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.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "librashader-cache"
|
name = "librashader-cache"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -12,8 +12,8 @@ description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0" }
|
serde = { version = "1.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8", features = ["serialize"] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0", features = ["serialize"] }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
platform-dirs = "0.3.0"
|
platform-dirs = "0.3.0"
|
||||||
blake3 = { version = "1.3.3" }
|
blake3 = { version = "1.3.3" }
|
||||||
thiserror = "1.0.38"
|
thiserror = "1.0.38"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//! here because of the orphan rule.
|
//! here because of the orphan rule.
|
||||||
|
|
||||||
use crate::{CacheKey, Cacheable};
|
use crate::{CacheKey, Cacheable};
|
||||||
use windows::core::ComInterface;
|
use windows::core::Interface;
|
||||||
|
|
||||||
impl CacheKey for windows::Win32::Graphics::Direct3D::ID3DBlob {
|
impl CacheKey for windows::Win32::Graphics::Direct3D::ID3DBlob {
|
||||||
fn hash_bytes(&self) -> &[u8] {
|
fn hash_bytes(&self) -> &[u8] {
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-capi"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -25,6 +25,8 @@ runtime-d3d9 = ["windows", "librashader/runtime-d3d9", "windows/Win32_Graphics_D
|
||||||
runtime-vulkan = ["ash", "librashader/runtime-vk"]
|
runtime-vulkan = ["ash", "librashader/runtime-vk"]
|
||||||
runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"]
|
runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"]
|
||||||
|
|
||||||
|
reflect-unstable = []
|
||||||
|
|
||||||
__cbindgen_internal = ["runtime-all"]
|
__cbindgen_internal = ["runtime-all"]
|
||||||
|
|
||||||
# make runtime-metal depend on this, so its automatically implied.
|
# make runtime-metal depend on this, so its automatically implied.
|
||||||
|
@ -42,7 +44,7 @@ sptr = "0.3.2"
|
||||||
|
|
||||||
[dependencies.librashader]
|
[dependencies.librashader]
|
||||||
path = "../librashader"
|
path = "../librashader"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["reflect", "presets", "preprocess"]
|
features = ["reflect", "presets", "preprocess"]
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub mod error;
|
||||||
mod ffi;
|
mod ffi;
|
||||||
pub mod presets;
|
pub mod presets;
|
||||||
|
|
||||||
#[cfg(feature = "reflect")]
|
#[cfg(feature = "reflect-unstable")]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod reflect;
|
pub mod reflect;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,11 @@ use crate::ctypes::{
|
||||||
};
|
};
|
||||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||||
use crate::ffi::extern_fn;
|
use crate::ffi::extern_fn;
|
||||||
use librashader::runtime::d3d11::{
|
use librashader::runtime::d3d11::{FilterChain, FilterChainOptions, FrameOptions};
|
||||||
D3D11InputView, D3D11OutputView, FilterChain, FilterChainOptions, FrameOptions,
|
|
||||||
};
|
|
||||||
use std::ffi::c_char;
|
use std::ffi::c_char;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::mem::{ManuallyDrop, MaybeUninit};
|
use std::mem::{ManuallyDrop, MaybeUninit};
|
||||||
|
use std::ops::Deref;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use windows::Win32::Graphics::Direct3D11::{
|
use windows::Win32::Graphics::Direct3D11::{
|
||||||
|
@ -16,32 +15,19 @@ use windows::Win32::Graphics::Direct3D11::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::LIBRASHADER_API_VERSION;
|
use crate::LIBRASHADER_API_VERSION;
|
||||||
use librashader::runtime::{FilterChainParameters, Size, Viewport};
|
use librashader::runtime::{FilterChainParameters, Viewport};
|
||||||
|
|
||||||
/// Direct3D 11 parameters for the source image.
|
/// Direct3D 11 parameters for the source image.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct libra_source_image_d3d11_t {
|
pub struct libra_source_image_d3d11_t {
|
||||||
/// A shader resource view into the source image
|
/// A shader resource view into the source image
|
||||||
pub handle: ManuallyDrop<ID3D11ShaderResourceView>,
|
pub handle: ManuallyDrop<ID3D11ShaderResourceView>,
|
||||||
/// The width of the source image.
|
/// This is currently ignored.
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
/// The height of the source image.
|
/// This is currently ignored.
|
||||||
pub height: u32,
|
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.
|
/// Options for Direct3D 11 filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Default, Debug, Clone)]
|
#[derive(Default, Debug, Clone)]
|
||||||
|
@ -251,19 +237,14 @@ extern_fn! {
|
||||||
let viewport = Viewport {
|
let viewport = Viewport {
|
||||||
x: viewport.x,
|
x: viewport.x,
|
||||||
y: viewport.y,
|
y: viewport.y,
|
||||||
output: D3D11OutputView {
|
output: ManuallyDrop::into_inner(out.clone()),
|
||||||
size: Size::new(viewport.width, viewport.height),
|
|
||||||
handle: ManuallyDrop::into_inner(out.clone()),
|
|
||||||
},
|
|
||||||
mvp,
|
mvp,
|
||||||
};
|
};
|
||||||
|
|
||||||
let options = options.map(FromUninit::from_uninit);
|
let options = options.map(FromUninit::from_uninit);
|
||||||
|
|
||||||
let image = image.try_into()?;
|
|
||||||
|
|
||||||
unsafe {
|
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())?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,11 @@ pub struct libra_source_image_d3d12_t {
|
||||||
pub resource: ManuallyDrop<ID3D12Resource>,
|
pub resource: ManuallyDrop<ID3D12Resource>,
|
||||||
/// A CPU descriptor handle to a shader resource view of the image.
|
/// A CPU descriptor handle to a shader resource view of the image.
|
||||||
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
|
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
|
||||||
/// The format of the image.
|
/// This is currently ignored.
|
||||||
pub format: DXGI_FORMAT,
|
pub format: DXGI_FORMAT,
|
||||||
/// The width of the source image.
|
/// This is currently ignored.
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
/// The height of the source image.
|
/// This is currently ignored.
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,6 @@ impl TryFrom<libra_source_image_d3d12_t> for D3D12InputImage {
|
||||||
Ok(D3D12InputImage {
|
Ok(D3D12InputImage {
|
||||||
resource: ManuallyDrop::into_inner(resource),
|
resource: ManuallyDrop::into_inner(resource),
|
||||||
descriptor: value.descriptor,
|
descriptor: value.descriptor,
|
||||||
size: Size::new(value.width, value.height),
|
|
||||||
format: value.format,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-common"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
|
|
@ -42,6 +42,12 @@ use num_traits::AsPrimitive;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum ShaderStorage {
|
||||||
|
Path(std::path::PathBuf),
|
||||||
|
String(String),
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||||
/// Supported image formats for textures.
|
/// Supported image formats for textures.
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-preprocess"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -14,7 +14,7 @@ description = "RetroArch shaders for all."
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
nom = "7.1.1"
|
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"
|
encoding_rs = "0.8.31"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -17,7 +17,6 @@ use crate::include::read_source;
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
use librashader_common::map::FastHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use librashader_common::ImageFormat;
|
use librashader_common::ImageFormat;
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
/// The source file for a single shader pass.
|
/// The source file for a single shader pass.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
@ -58,8 +57,8 @@ pub struct ShaderParameter {
|
||||||
impl ShaderSource {
|
impl ShaderSource {
|
||||||
/// Load the source file at the given path, resolving includes relative to the location of the
|
/// Load the source file at the given path, resolving includes relative to the location of the
|
||||||
/// source file.
|
/// source file.
|
||||||
pub fn load(path: impl AsRef<Path>) -> Result<ShaderSource, PreprocessError> {
|
pub fn load(file: &librashader_common::ShaderStorage) -> Result<ShaderSource, PreprocessError> {
|
||||||
load_shader_source(path)
|
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> {
|
pub(crate) fn load_shader_source(
|
||||||
let source = read_source(path)?;
|
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 meta = pragma::parse_pragma_meta(&source)?;
|
||||||
let text = stage::process_stages(&source)?;
|
let text = stage::process_stages(&source)?;
|
||||||
let parameters = FastHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
|
let parameters = FastHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
|
||||||
|
@ -100,9 +105,9 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn load_file() {
|
pub fn load_file() {
|
||||||
let result = load_shader_source(
|
let result = load_shader_source(&librashader_common::ShaderStorage::Path(
|
||||||
"../test/slang-shaders/blurs/shaders/royale/blur3x3-last-pass.slang",
|
"../test/slang-shaders/blurs/shaders/royale/blur3x3-last-pass.slang".into(),
|
||||||
)
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
eprintln!("{:#}", result.vertex)
|
eprintln!("{:#}", result.vertex)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-presets"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
nom = "7.1.1"
|
nom = "7.1.1"
|
||||||
nom_locate = "4.0.0"
|
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"
|
num-traits = "0.2"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
# we don't need unicode
|
# we don't need unicode
|
||||||
|
|
|
@ -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> {
|
pub fn to_hashmap(mut self) -> FastHashMap<String, String> {
|
||||||
let mut map = FastHashMap::default();
|
let mut map = FastHashMap::default();
|
||||||
let last_user_rot = self
|
let last_user_rot = self
|
||||||
|
|
|
@ -115,7 +115,7 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
|
||||||
|
|
||||||
let shader = ShaderPassConfig {
|
let shader = ShaderPassConfig {
|
||||||
id,
|
id,
|
||||||
name,
|
name: librashader_common::ShaderStorage::Path(name),
|
||||||
alias: shader_values.iter().find_map(|f| match f {
|
alias: shader_values.iter().find_map(|f| match f {
|
||||||
Value::Alias(_, value) => Some(value.to_string()),
|
Value::Alias(_, value) => Some(value.to_string()),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::extract_if::MakeExtractIf;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
ShaderCount(i32),
|
ShaderCount(i32),
|
||||||
FeedbackPass(i32),
|
FeedbackPass(#[allow(unused)] i32),
|
||||||
Shader(i32, PathBuf),
|
Shader(i32, PathBuf),
|
||||||
ScaleX(i32, ScaleFactor),
|
ScaleX(i32, ScaleFactor),
|
||||||
ScaleY(i32, ScaleFactor),
|
ScaleY(i32, ScaleFactor),
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub struct ShaderPassConfig {
|
||||||
/// The index of the shader pass relative to its parent preset.
|
/// The index of the shader pass relative to its parent preset.
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
/// The fully qualified path to the shader pass source file.
|
/// 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.
|
/// The alias of the shader pass if available.
|
||||||
pub alias: Option<String>,
|
pub alias: Option<String>,
|
||||||
/// The filtering mode that this shader pass should expect.
|
/// The filtering mode that this shader pass should expect.
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-reflect"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -18,9 +18,9 @@ bytemuck = "1.13.0"
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
bitflags = "2.4.2"
|
bitflags = "2.4.2"
|
||||||
|
|
||||||
librashader-common = { path = "../librashader-common", version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
|
|
||||||
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1", optional = true }
|
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" ]
|
naga = [ "rspirv", "spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ]
|
||||||
serialize = [ "serde" ]
|
serialize = [ "serde" ]
|
||||||
msl = [ "spirv_cross/msl", "naga/msl-out" ]
|
msl = [ "spirv_cross/msl", "naga/msl-out" ]
|
||||||
|
|
||||||
|
unstable-naga-in = ["naga/glsl-in"]
|
|
@ -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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use thiserror::Error;
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ShaderCompileError {
|
pub enum ShaderCompileError {
|
||||||
/// Compile error from naga.
|
/// Compile error from naga.
|
||||||
#[cfg(feature = "unstable-naga")]
|
#[cfg(feature = "unstable-naga-in")]
|
||||||
#[error("shader")]
|
#[error("shader")]
|
||||||
NagaCompileError(Vec<naga::front::glsl::Error>),
|
NagaCompileError(Vec<naga::front::glsl::Error>),
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ pub enum ShaderReflectError {
|
||||||
NagaReflectError(#[from] naga::WithSpan<naga::valid::ValidationError>),
|
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 {
|
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
|
||||||
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
|
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
|
||||||
ShaderCompileError::NagaCompileError(err)
|
ShaderCompileError::NagaCompileError(err)
|
||||||
|
|
|
@ -40,12 +40,9 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! ## What's with all the traits?
|
//! ## What's with all the traits?
|
||||||
//! librashader-reflect is designed to be compiler-agnostic. In the future, we will allow usage of
|
//! librashader-reflect is designed to be compiler-agnostic. [naga](https://docs.rs/naga/latest/naga/index.html),
|
||||||
//! [naga](https://docs.rs/naga/latest/naga/index.html), a pure-Rust shader compiler, when it has
|
//! a pure-Rust shader compiler, as well as SPIRV-Cross via [SpirvCompilation](crate::front::SpirvCompilation)
|
||||||
//! matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
|
//! is supported.
|
||||||
//!
|
|
||||||
//! 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).
|
|
||||||
#![feature(impl_trait_in_assoc_type)]
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod glsl;
|
pub mod glsl;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod hlsl;
|
pub mod hlsl;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod msl;
|
pub mod msl;
|
||||||
|
|
||||||
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
||||||
|
@ -20,6 +25,8 @@ use spirv_cross::ErrorCode;
|
||||||
use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData};
|
use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData};
|
||||||
|
|
||||||
/// Reflect shaders under SPIRV-Cross semantics.
|
/// Reflect shaders under SPIRV-Cross semantics.
|
||||||
|
///
|
||||||
|
/// SPIRV-Cross supports GLSL, HLSL, SPIR-V, and MSL targets.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SpirvCross;
|
pub struct SpirvCross;
|
||||||
|
|
||||||
|
@ -754,7 +761,10 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_into() {
|
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();
|
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();
|
||||||
|
|
||||||
for (_index, param) in result.parameters.iter().enumerate() {
|
for (_index, param) in result.parameters.iter().enumerate() {
|
||||||
|
|
|
@ -120,7 +120,10 @@ mod test {
|
||||||
pub fn test_into() {
|
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/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();
|
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub mod presets;
|
||||||
|
|
||||||
mod helper;
|
mod helper;
|
||||||
|
|
||||||
|
/// Reflection via naga.
|
||||||
#[cfg(feature = "naga")]
|
#[cfg(feature = "naga")]
|
||||||
pub mod naga;
|
pub mod naga;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod msl;
|
pub mod msl;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod spirv;
|
pub mod spirv;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod wgsl;
|
pub mod wgsl;
|
||||||
|
|
||||||
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
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,
|
/// The Naga reflector will lower combined image samplers to split,
|
||||||
/// with the same bind point on descriptor group 1.
|
/// with the same bind point on descriptor group 1.
|
||||||
|
///
|
||||||
|
/// Naga supports WGSL, SPIR-V, and MSL targets.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Naga;
|
pub struct Naga;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -172,7 +172,10 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_into() {
|
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();
|
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime-d3d11"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -12,18 +12,21 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8", features = ["d3d"] }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0", features = ["d3d"] }
|
||||||
|
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
bytemuck = "1.12.3"
|
bytemuck = "1.12.3"
|
||||||
rayon = "1.6.1"
|
rayon = "1.6.1"
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
debug-shader = []
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.windows]
|
[target.'cfg(windows)'.dependencies.windows]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = [
|
features = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::texture::{D3D11InputView, InputTexture};
|
use crate::texture::InputTexture;
|
||||||
use librashader_common::{ImageFormat, Size, Viewport};
|
use librashader_common::{ImageFormat, Size, Viewport};
|
||||||
|
|
||||||
use librashader_common::map::FastHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
@ -21,8 +21,8 @@ use crate::graphics_pipeline::D3D11State;
|
||||||
use crate::luts::LutTexture;
|
use crate::luts::LutTexture;
|
||||||
use crate::options::{FilterChainOptionsD3D11, FrameOptionsD3D11};
|
use crate::options::{FilterChainOptionsD3D11, FrameOptionsD3D11};
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::util::d3d11_compile_bound_shader;
|
use crate::util::{d3d11_compile_bound_shader, GetSize};
|
||||||
use crate::{error, util, D3D11OutputView};
|
use crate::{error, util};
|
||||||
use librashader_cache::cache_shader_object;
|
use librashader_cache::cache_shader_object;
|
||||||
use librashader_cache::CachedCompilation;
|
use librashader_cache::CachedCompilation;
|
||||||
use librashader_presets::context::VideoDriver;
|
use librashader_presets::context::VideoDriver;
|
||||||
|
@ -36,7 +36,8 @@ use librashader_runtime::scaling::ScaleFramebuffer;
|
||||||
use librashader_runtime::uniforms::UniformStorage;
|
use librashader_runtime::uniforms::UniformStorage;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use windows::Win32::Graphics::Direct3D11::{
|
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_CPU_ACCESS_WRITE, D3D11_CREATE_DEVICE_SINGLETHREADED, D3D11_RESOURCE_MISC_GENERATE_MIPS,
|
||||||
D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_USAGE_DYNAMIC,
|
D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_USAGE_DYNAMIC,
|
||||||
};
|
};
|
||||||
|
@ -347,7 +348,7 @@ impl FilterChainD3D11 {
|
||||||
fn push_history(
|
fn push_history(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &ID3D11DeviceContext,
|
ctx: &ID3D11DeviceContext,
|
||||||
input: &D3D11InputView,
|
input: &ID3D11ShaderResourceView,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
||||||
back.copy_from(ctx, input)?;
|
back.copy_from(ctx, input)?;
|
||||||
|
@ -399,8 +400,8 @@ impl FilterChainD3D11 {
|
||||||
pub unsafe fn frame(
|
pub unsafe fn frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: Option<&ID3D11DeviceContext>,
|
ctx: Option<&ID3D11DeviceContext>,
|
||||||
input: D3D11InputView,
|
input: &ID3D11ShaderResourceView,
|
||||||
viewport: &Viewport<D3D11OutputView>,
|
viewport: &Viewport<ID3D11RenderTargetView>,
|
||||||
frame_count: usize,
|
frame_count: usize,
|
||||||
options: Option<&FrameOptionsD3D11>,
|
options: Option<&FrameOptionsD3D11>,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
|
@ -447,8 +448,8 @@ impl FilterChainD3D11 {
|
||||||
// rescale render buffers to ensure all bindings are valid.
|
// rescale render buffers to ensure all bindings are valid.
|
||||||
OwnedImage::scale_framebuffers(
|
OwnedImage::scale_framebuffers(
|
||||||
source.size(),
|
source.size(),
|
||||||
viewport.output.size,
|
viewport.output.size()?,
|
||||||
original.view.size,
|
original.view.size()?,
|
||||||
&mut self.output_framebuffers,
|
&mut self.output_framebuffers,
|
||||||
&mut self.feedback_framebuffers,
|
&mut self.feedback_framebuffers,
|
||||||
passes,
|
passes,
|
||||||
|
@ -481,7 +482,6 @@ impl FilterChainD3D11 {
|
||||||
source.filter = pass.config.filter;
|
source.filter = pass.config.filter;
|
||||||
source.wrap_mode = pass.config.wrap_mode;
|
source.wrap_mode = pass.config.wrap_mode;
|
||||||
let target = &self.output_framebuffers[index];
|
let target = &self.output_framebuffers[index];
|
||||||
let size = target.size;
|
|
||||||
pass.draw(
|
pass.draw(
|
||||||
ctx,
|
ctx,
|
||||||
index,
|
index,
|
||||||
|
@ -491,15 +491,12 @@ impl FilterChainD3D11 {
|
||||||
viewport,
|
viewport,
|
||||||
&original,
|
&original,
|
||||||
&source,
|
&source,
|
||||||
RenderTarget::identity(&target.as_output()?),
|
RenderTarget::identity(&target.create_render_target_view()?),
|
||||||
QuadType::Offscreen,
|
QuadType::Offscreen,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
source = InputTexture {
|
source = InputTexture {
|
||||||
view: D3D11InputView {
|
view: target.create_shader_resource_view()?,
|
||||||
handle: target.create_shader_resource_view()?,
|
|
||||||
size,
|
|
||||||
},
|
|
||||||
filter: pass.config.filter,
|
filter: pass.config.filter,
|
||||||
wrap_mode: pass.config.wrap_mode,
|
wrap_mode: pass.config.wrap_mode,
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,13 +16,14 @@ use librashader_runtime::filter_pass::FilterPassMeta;
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use windows::Win32::Graphics::Direct3D11::{
|
use windows::Win32::Graphics::Direct3D11::{
|
||||||
ID3D11Buffer, ID3D11DeviceContext, ID3D11InputLayout, ID3D11PixelShader, ID3D11SamplerState,
|
ID3D11Buffer, ID3D11DeviceContext, ID3D11InputLayout, ID3D11PixelShader,
|
||||||
ID3D11ShaderResourceView, ID3D11VertexShader, D3D11_MAPPED_SUBRESOURCE,
|
ID3D11RenderTargetView, ID3D11SamplerState, ID3D11ShaderResourceView, ID3D11VertexShader,
|
||||||
D3D11_MAP_WRITE_DISCARD, D3D11_VIEWPORT,
|
D3D11_MAPPED_SUBRESOURCE, D3D11_MAP_WRITE_DISCARD, D3D11_VIEWPORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::error;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::{error, D3D11OutputView};
|
use crate::util::GetSize;
|
||||||
use librashader_runtime::uniforms::{UniformStorage, UniformStorageAccess};
|
use librashader_runtime::uniforms::{UniformStorage, UniformStorageAccess};
|
||||||
|
|
||||||
pub struct ConstantBufferBinding {
|
pub struct ConstantBufferBinding {
|
||||||
|
@ -55,7 +56,7 @@ const NULL_TEXTURES: &[Option<ID3D11ShaderResourceView>; 16] = &[
|
||||||
|
|
||||||
impl TextureInput for InputTexture {
|
impl TextureInput for InputTexture {
|
||||||
fn size(&self) -> Size<u32> {
|
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,
|
_device: &Self::DeviceContext,
|
||||||
) {
|
) {
|
||||||
let (texture_binding, sampler_binding) = descriptors;
|
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] =
|
sampler_binding[binding.binding as usize] =
|
||||||
Some(samplers.get(texture.wrap_mode, texture.filter).clone());
|
Some(samplers.get(texture.wrap_mode, texture.filter).clone());
|
||||||
}
|
}
|
||||||
|
@ -149,15 +150,15 @@ impl FilterPass {
|
||||||
parent: &FilterCommon,
|
parent: &FilterCommon,
|
||||||
frame_count: u32,
|
frame_count: u32,
|
||||||
options: &FrameOptionsD3D11,
|
options: &FrameOptionsD3D11,
|
||||||
viewport: &Viewport<D3D11OutputView>,
|
viewport: &Viewport<ID3D11RenderTargetView>,
|
||||||
original: &InputTexture,
|
original: &InputTexture,
|
||||||
source: &InputTexture,
|
source: &InputTexture,
|
||||||
output: RenderTarget<D3D11OutputView>,
|
output: RenderTarget<ID3D11RenderTargetView>,
|
||||||
vbo_type: QuadType,
|
vbo_type: QuadType,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
if self.config.mipmap_input && !parent.disable_mipmaps {
|
if self.config.mipmap_input && !parent.disable_mipmaps {
|
||||||
unsafe {
|
unsafe {
|
||||||
ctx.GenerateMips(&source.view.handle);
|
ctx.GenerateMips(&source.view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -170,14 +171,17 @@ impl FilterPass {
|
||||||
let mut samplers: [Option<ID3D11SamplerState>; 16] = std::array::from_fn(|_| None);
|
let mut samplers: [Option<ID3D11SamplerState>; 16] = std::array::from_fn(|_| None);
|
||||||
let descriptors = (&mut textures, &mut samplers);
|
let descriptors = (&mut textures, &mut samplers);
|
||||||
|
|
||||||
|
let output_size = output.output.size()?;
|
||||||
|
let viewport_size = viewport.output.size()?;
|
||||||
|
|
||||||
self.build_semantics(
|
self.build_semantics(
|
||||||
pass_index,
|
pass_index,
|
||||||
parent,
|
parent,
|
||||||
output.mvp,
|
output.mvp,
|
||||||
frame_count,
|
frame_count,
|
||||||
options,
|
options,
|
||||||
output.output.size,
|
output_size,
|
||||||
viewport.output.size,
|
viewport_size,
|
||||||
descriptors,
|
descriptors,
|
||||||
original,
|
original,
|
||||||
source,
|
source,
|
||||||
|
@ -241,15 +245,16 @@ impl FilterPass {
|
||||||
std::mem::size_of::<Option<windows::core::IUnknown>>()
|
std::mem::size_of::<Option<windows::core::IUnknown>>()
|
||||||
== std::mem::size_of::<windows::core::IUnknown>()
|
== std::mem::size_of::<windows::core::IUnknown>()
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.PSSetShaderResources(0, Some(std::mem::transmute(textures.as_ref())));
|
ctx.PSSetShaderResources(0, Some(std::mem::transmute(textures.as_ref())));
|
||||||
ctx.PSSetSamplers(0, Some(std::mem::transmute(samplers.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 {
|
ctx.RSSetViewports(Some(&[D3D11_VIEWPORT {
|
||||||
TopLeftX: output.x,
|
TopLeftX: output.x,
|
||||||
TopLeftY: output.y,
|
TopLeftY: output.y,
|
||||||
Width: output.output.size.width as f32,
|
Width: output_size.width as f32,
|
||||||
Height: output.output.size.height as f32,
|
Height: output_size.height as f32,
|
||||||
MinDepth: 0.0,
|
MinDepth: 0.0,
|
||||||
MaxDepth: 1.0,
|
MaxDepth: 1.0,
|
||||||
}]))
|
}]))
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
use crate::error;
|
||||||
use crate::error::{assume_d3d11_init, FilterChainError};
|
use crate::error::{assume_d3d11_init, FilterChainError};
|
||||||
use crate::texture::D3D11InputView;
|
|
||||||
use crate::util::d3d11_get_closest_format;
|
use crate::util::d3d11_get_closest_format;
|
||||||
use crate::{error, D3D11OutputView};
|
|
||||||
use librashader_common::{ImageFormat, Size};
|
use librashader_common::{ImageFormat, Size};
|
||||||
use librashader_presets::Scale2D;
|
use librashader_presets::Scale2D;
|
||||||
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
|
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::Direct3D::D3D_SRV_DIMENSION_TEXTURE2D;
|
||||||
use windows::Win32::Graphics::Direct3D11::{
|
use windows::Win32::Graphics::Direct3D11::{
|
||||||
ID3D11Device, ID3D11DeviceContext, ID3D11RenderTargetView, ID3D11ShaderResourceView,
|
ID3D11Device, ID3D11DeviceContext, ID3D11RenderTargetView, ID3D11ShaderResourceView,
|
||||||
|
@ -171,33 +170,25 @@ impl OwnedImage {
|
||||||
Ok(rtv)
|
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(
|
pub fn copy_from(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &ID3D11DeviceContext,
|
ctx: &ID3D11DeviceContext,
|
||||||
image: &D3D11InputView,
|
image: &ID3D11ShaderResourceView,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
let original_resource: ID3D11Texture2D = unsafe {
|
let original_resource: ID3D11Texture2D = unsafe {
|
||||||
let resource = image.handle.GetResource()?;
|
let resource = image.GetResource()?;
|
||||||
resource.cast()?
|
resource.cast()?
|
||||||
};
|
};
|
||||||
|
|
||||||
let format = unsafe {
|
let (format, image_size) = unsafe {
|
||||||
let mut desc = Default::default();
|
let mut desc = Default::default();
|
||||||
original_resource.GetDesc(&mut desc);
|
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");
|
// eprintln!("[history] resizing");
|
||||||
self.init(image.size, ImageFormat::from(format))?;
|
self.init(image_size, ImageFormat::from(format))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -25,5 +25,3 @@ use librashader_runtime::impl_filter_chain_parameters;
|
||||||
impl_filter_chain_parameters!(FilterChainD3D11);
|
impl_filter_chain_parameters!(FilterChainD3D11);
|
||||||
|
|
||||||
pub use filter_chain::FilterChainD3D11;
|
pub use filter_chain::FilterChainD3D11;
|
||||||
pub use texture::D3D11InputView;
|
|
||||||
pub use texture::D3D11OutputView;
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
use crate::error;
|
||||||
use crate::error::assume_d3d11_init;
|
use crate::error::assume_d3d11_init;
|
||||||
use crate::texture::InputTexture;
|
use crate::texture::InputTexture;
|
||||||
use crate::{error, D3D11InputView};
|
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use librashader_runtime::image::Image;
|
use librashader_runtime::image::Image;
|
||||||
use librashader_runtime::scaling::MipmapSize;
|
use librashader_runtime::scaling::MipmapSize;
|
||||||
|
@ -139,10 +139,7 @@ impl LutTexture {
|
||||||
handle,
|
handle,
|
||||||
desc,
|
desc,
|
||||||
image: InputTexture {
|
image: InputTexture {
|
||||||
view: D3D11InputView {
|
view: srv,
|
||||||
handle: srv,
|
|
||||||
size: source.size,
|
|
||||||
},
|
|
||||||
filter,
|
filter,
|
||||||
wrap_mode,
|
wrap_mode,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,33 +1,11 @@
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use crate::framebuffer::OwnedImage;
|
use crate::framebuffer::OwnedImage;
|
||||||
use librashader_common::{FilterMode, Size, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use windows::Win32::Graphics::Direct3D11::{ID3D11RenderTargetView, ID3D11ShaderResourceView};
|
use windows::Win32::Graphics::Direct3D11::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>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct InputTexture {
|
pub struct InputTexture {
|
||||||
pub view: D3D11InputView,
|
pub view: ID3D11ShaderResourceView,
|
||||||
pub filter: FilterMode,
|
pub filter: FilterMode,
|
||||||
pub wrap_mode: WrapMode,
|
pub wrap_mode: WrapMode,
|
||||||
}
|
}
|
||||||
|
@ -39,10 +17,7 @@ impl InputTexture {
|
||||||
filter: FilterMode,
|
filter: FilterMode,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(InputTexture {
|
Ok(InputTexture {
|
||||||
view: D3D11InputView {
|
view: fbo.create_shader_resource_view()?,
|
||||||
handle: fbo.create_shader_resource_view()?,
|
|
||||||
size: fbo.size,
|
|
||||||
},
|
|
||||||
filter,
|
filter,
|
||||||
wrap_mode,
|
wrap_mode,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::error::assume_d3d11_init;
|
use crate::error::assume_d3d11_init;
|
||||||
|
use librashader_common::Size;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use windows::core::PCSTR;
|
use windows::core::{Interface, PCSTR};
|
||||||
use windows::Win32::Graphics::Direct3D::Fxc::{
|
use windows::Win32::Graphics::Direct3D::Fxc::{
|
||||||
D3DCompile, D3DCOMPILE_DEBUG, D3DCOMPILE_OPTIMIZATION_LEVEL3, D3DCOMPILE_SKIP_OPTIMIZATION,
|
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>,
|
factory: ShaderFactory<'a, L, T>,
|
||||||
) -> error::Result<T>
|
) -> error::Result<T>
|
||||||
where
|
where
|
||||||
L: windows::core::IntoParam<ID3D11ClassLinkage>,
|
L: windows::core::Param<ID3D11ClassLinkage>,
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
// SAFETY: slice as valid for as long as vs_blob is alive.
|
// 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)
|
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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ where
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let hwnd = hwnd?;
|
||||||
sample.bind_to_window(&hwnd).unwrap();
|
sample.bind_to_window(&hwnd).unwrap();
|
||||||
unsafe { ShowWindow(hwnd, SW_SHOW) };
|
unsafe { ShowWindow(hwnd, SW_SHOW) };
|
||||||
|
|
||||||
|
@ -246,7 +247,6 @@ pub mod d3d11_hello_triangle {
|
||||||
use librashader_runtime::image::Image;
|
use librashader_runtime::image::Image;
|
||||||
use librashader_runtime_d3d11::options::FilterChainOptionsD3D11;
|
use librashader_runtime_d3d11::options::FilterChainOptionsD3D11;
|
||||||
use librashader_runtime_d3d11::FilterChainD3D11;
|
use librashader_runtime_d3d11::FilterChainD3D11;
|
||||||
use librashader_runtime_d3d11::{D3D11InputView, D3D11OutputView};
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use texture::ExampleTexture;
|
use texture::ExampleTexture;
|
||||||
|
@ -437,7 +437,7 @@ pub mod d3d11_hello_triangle {
|
||||||
drop(resources.backbuffer.take());
|
drop(resources.backbuffer.take());
|
||||||
resources
|
resources
|
||||||
.swapchain
|
.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:?}"));
|
.unwrap_or_else(|f| eprintln!("{f:?}"));
|
||||||
let (rtv, backbuffer) = create_rtv(&self.device, &resources.swapchain)?;
|
let (rtv, backbuffer) = create_rtv(&self.device, &resources.swapchain)?;
|
||||||
|
|
||||||
|
@ -572,23 +572,11 @@ pub mod d3d11_hello_triangle {
|
||||||
self.filter
|
self.filter
|
||||||
.frame(
|
.frame(
|
||||||
None,
|
None,
|
||||||
D3D11InputView {
|
&srv,
|
||||||
handle: srv,
|
|
||||||
size: Size {
|
|
||||||
width: tex2d_desc.Width,
|
|
||||||
height: tex2d_desc.Height,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&Viewport {
|
&Viewport {
|
||||||
x: 0f32,
|
x: 0f32,
|
||||||
y: 0f32,
|
y: 0f32,
|
||||||
output: D3D11OutputView {
|
output: resources.backbuffer_rtv.as_ref().unwrap().clone(),
|
||||||
size: Size {
|
|
||||||
width: backbuffer_desc.Width,
|
|
||||||
height: backbuffer_desc.Height,
|
|
||||||
},
|
|
||||||
handle: resources.backbuffer_rtv.as_ref().unwrap().clone(),
|
|
||||||
},
|
|
||||||
mvp: None,
|
mvp: None,
|
||||||
},
|
},
|
||||||
resources.frame_count,
|
resources.frame_count,
|
||||||
|
@ -606,7 +594,10 @@ pub mod d3d11_hello_triangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
resources.swapchain.Present(0, 0).ok()?;
|
resources
|
||||||
|
.swapchain
|
||||||
|
.Present(0, DXGI_PRESENT::default())
|
||||||
|
.ok()?;
|
||||||
}
|
}
|
||||||
resources.frame_count += 1;
|
resources.frame_count += 1;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -12,8 +12,7 @@ use librashader_runtime_d3d11::options::FilterChainOptionsD3D11;
|
||||||
// const FILTER_PATH: &str =
|
// const FILTER_PATH: &str =
|
||||||
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID].slangp";
|
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID].slangp";
|
||||||
|
|
||||||
const FILTER_PATH: &str =
|
const FILTER_PATH: &str = "../test/shaders_slang/crt/crt-royale.slangp";
|
||||||
"../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp";
|
|
||||||
|
|
||||||
// const FILTER_PATH: &str = "../test/slang-shaders/test/history.slangp";
|
// const FILTER_PATH: &str = "../test/slang-shaders/test/history.slangp";
|
||||||
// const FILTER_PATH: &str = "../test/slang-shaders/test/feedback.slangp";
|
// const FILTER_PATH: &str = "../test/slang-shaders/test/feedback.slangp";
|
||||||
|
@ -61,7 +60,7 @@ fn triangle_d3d11() {
|
||||||
FILTER_PATH,
|
FILTER_PATH,
|
||||||
Some(&FilterChainOptionsD3D11 {
|
Some(&FilterChainOptionsD3D11 {
|
||||||
force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
disable_cache: false,
|
disable_cache: true,
|
||||||
}),
|
}),
|
||||||
// replace below with 'None' for the triangle
|
// replace below with 'None' for the triangle
|
||||||
// None,
|
// None,
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime-d3d12"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -12,12 +12,12 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["d3d12"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["d3d12"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8", features = ["dxil"] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0", features = ["dxil"] }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8", features = ["d3d"] }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0", features = ["d3d"] }
|
||||||
|
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ use librashader_runtime::uniforms::UniformStorage;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use windows::core::ComInterface;
|
use windows::core::Interface;
|
||||||
use windows::Win32::Foundation::CloseHandle;
|
use windows::Win32::Foundation::CloseHandle;
|
||||||
use windows::Win32::Graphics::Direct3D::Dxc::{
|
use windows::Win32::Graphics::Direct3D::Dxc::{
|
||||||
CLSID_DxcCompiler, CLSID_DxcLibrary, CLSID_DxcValidator, DxcCreateInstance, IDxcCompiler,
|
CLSID_DxcCompiler, CLSID_DxcLibrary, CLSID_DxcValidator, DxcCreateInstance, IDxcCompiler,
|
||||||
|
|
|
@ -18,7 +18,7 @@ use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use windows::core::ComInterface;
|
use windows::core::Interface;
|
||||||
use windows::Win32::Foundation::RECT;
|
use windows::Win32::Foundation::RECT;
|
||||||
use windows::Win32::Graphics::Direct3D12::{
|
use windows::Win32::Graphics::Direct3D12::{
|
||||||
ID3D12GraphicsCommandList, ID3D12GraphicsCommandList4, D3D12_RENDER_PASS_BEGINNING_ACCESS,
|
ID3D12GraphicsCommandList, ID3D12GraphicsCommandList4, D3D12_RENDER_PASS_BEGINNING_ACCESS,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use librashader_reflect::back::ShaderCompilerOutput;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use widestring::u16cstr;
|
use widestring::u16cstr;
|
||||||
use windows::core::ComInterface;
|
use windows::core::Interface;
|
||||||
use windows::Win32::Foundation::BOOL;
|
use windows::Win32::Foundation::BOOL;
|
||||||
use windows::Win32::Graphics::Direct3D::Dxc::{
|
use windows::Win32::Graphics::Direct3D::Dxc::{
|
||||||
CLSID_DxcLibrary, DxcCreateInstance, IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator, DXC_CP,
|
CLSID_DxcLibrary, DxcCreateInstance, IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator, DXC_CP,
|
||||||
|
|
|
@ -8,8 +8,6 @@ use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT;
|
||||||
pub struct D3D12InputImage {
|
pub struct D3D12InputImage {
|
||||||
pub resource: ID3D12Resource,
|
pub resource: ID3D12Resource,
|
||||||
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
|
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
|
||||||
pub size: Size<u32>,
|
|
||||||
pub format: DXGI_FORMAT,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -117,11 +115,12 @@ impl InputTexture {
|
||||||
filter: FilterMode,
|
filter: FilterMode,
|
||||||
wrap_mode: WrapMode,
|
wrap_mode: WrapMode,
|
||||||
) -> InputTexture {
|
) -> InputTexture {
|
||||||
|
let desc = unsafe { image.resource.GetDesc() };
|
||||||
InputTexture {
|
InputTexture {
|
||||||
resource: image.resource,
|
resource: image.resource,
|
||||||
descriptor: InputDescriptor::Raw(image.descriptor),
|
descriptor: InputDescriptor::Raw(image.descriptor),
|
||||||
size: image.size,
|
size: Size::new(desc.Width as u32, desc.Height),
|
||||||
format: image.format,
|
format: desc.Format,
|
||||||
wrap_mode,
|
wrap_mode,
|
||||||
filter,
|
filter,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::error::assume_d3d12_init;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use widestring::{u16cstr, U16CStr};
|
use widestring::{u16cstr, U16CStr};
|
||||||
use windows::core::{ComInterface, PCWSTR};
|
use windows::core::{Interface, PCWSTR};
|
||||||
use windows::Win32::Graphics::Direct3D::Dxc::{
|
use windows::Win32::Graphics::Direct3D::Dxc::{
|
||||||
DxcValidatorFlags_InPlaceEdit, IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator, DXC_CP,
|
DxcValidatorFlags_InPlaceEdit, IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator, DXC_CP,
|
||||||
DXC_CP_UTF8,
|
DXC_CP_UTF8,
|
||||||
|
|
|
@ -109,7 +109,8 @@ where
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
sample.bind_to_window(&hwnd)?;
|
let hwnd = hwnd?;
|
||||||
|
sample.bind_to_window(&hwnd).unwrap();
|
||||||
unsafe { ShowWindow(hwnd, SW_SHOW) };
|
unsafe { ShowWindow(hwnd, SW_SHOW) };
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -187,8 +188,7 @@ fn get_hardware_adapter(factory: &IDXGIFactory4) -> Result<IDXGIAdapter1> {
|
||||||
for i in 0.. {
|
for i in 0.. {
|
||||||
let adapter = unsafe { factory.EnumAdapters1(i)? };
|
let adapter = unsafe { factory.EnumAdapters1(i)? };
|
||||||
|
|
||||||
let mut desc = Default::default();
|
let mut desc = unsafe { adapter.GetDesc1()? };
|
||||||
unsafe { adapter.GetDesc1(&mut desc)? };
|
|
||||||
|
|
||||||
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32) != DXGI_ADAPTER_FLAG_NONE.0 as u32 {
|
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
|
// 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]) };
|
unsafe { resources.command_queue.ExecuteCommandLists(&[command_list]) };
|
||||||
|
|
||||||
// Present the frame.
|
// 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);
|
wait_for_previous_frame(resources);
|
||||||
self.framecount += 1;
|
self.framecount += 1;
|
||||||
|
@ -624,11 +626,6 @@ pub mod d3d12_hello_triangle {
|
||||||
D3D12InputImage {
|
D3D12InputImage {
|
||||||
resource: resources.framebuffer.clone(),
|
resource: resources.framebuffer.clone(),
|
||||||
descriptor: framebuffer,
|
descriptor: framebuffer,
|
||||||
size: Size::new(
|
|
||||||
resources.viewport.Width as u32,
|
|
||||||
resources.viewport.Height as u32,
|
|
||||||
),
|
|
||||||
format: DXGI_FORMAT_R8G8B8A8_UNORM,
|
|
||||||
},
|
},
|
||||||
&Viewport {
|
&Viewport {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
|
|
|
@ -6,12 +6,12 @@ use crate::hello_triangle::{DXSample, SampleCommandLine};
|
||||||
fn triangle_d3d12() {
|
fn triangle_d3d12() {
|
||||||
let sample = hello_triangle::d3d12_hello_triangle::Sample::new(
|
let sample = hello_triangle::d3d12_hello_triangle::Sample::new(
|
||||||
// "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
// "../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/basic.slangp",
|
||||||
// "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.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/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/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/shaders_slang/crt/crt-royale.slangp",
|
||||||
// "../test/slang-shaders/vhs/VHSPro.slangp",
|
// "../test/slang-shaders/vhs/VHSPro.slangp",
|
||||||
&SampleCommandLine {
|
&SampleCommandLine {
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime-d3d9"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -12,18 +12,20 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["d3d9", "d3d11"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["d3d9", "d3d11"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8", features = ["d3d"] }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0", features = ["d3d"] }
|
||||||
|
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
bytemuck = "1.12.3"
|
bytemuck = "1.12.3"
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
num-traits = "0.2.18"
|
num-traits = "0.2.18"
|
||||||
|
|
||||||
|
windows-core = "0.58.0"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.windows]
|
[target.'cfg(windows)'.dependencies.windows]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = [
|
features = [
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl ConstantRegister {
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|(mangled_name, register)| {
|
.find_map(|(mangled_name, register)| {
|
||||||
if context
|
if context
|
||||||
.fragment_buffers
|
.vertex_buffers
|
||||||
.contains_uniform(uniform_name, mangled_name)
|
.contains_uniform(uniform_name, mangled_name)
|
||||||
{
|
{
|
||||||
Some(register)
|
Some(register)
|
||||||
|
@ -98,15 +98,17 @@ impl ContextOffset<D3D9UniformBinder, ConstantRegister, IDirect3DDevice9> for Co
|
||||||
pub(crate) type D3D9UniformStorage =
|
pub(crate) type D3D9UniformStorage =
|
||||||
UniformStorage<D3D9UniformBinder, ConstantRegister, Box<[u8]>, Box<[u8]>, IDirect3DDevice9>;
|
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 {}
|
trait D3D9UniformScalar: UniformScalar + AsPrimitive<f32> + Copy {}
|
||||||
impl D3D9UniformScalar for u32 {}
|
impl D3D9UniformScalar for u32 {}
|
||||||
impl D3D9UniformScalar for i32 {}
|
impl D3D9UniformScalar for i32 {}
|
||||||
impl D3D9UniformScalar for f32 {}
|
impl D3D9UniformScalar for f32 {}
|
||||||
|
|
||||||
pub(crate) struct D3D9UniformBinder;
|
pub(crate) struct D3D9UniformBinder;
|
||||||
impl<T> BindUniform<ConstantRegister, T, IDirect3DDevice9> for D3D9UniformBinder
|
impl<T: D3D9UniformScalar> BindUniform<ConstantRegister, T, IDirect3DDevice9>
|
||||||
where
|
for D3D9UniformBinder
|
||||||
T: D3D9UniformScalar,
|
|
||||||
{
|
{
|
||||||
fn bind_uniform(
|
fn bind_uniform(
|
||||||
_block: UniformMemberBlock,
|
_block: UniformMemberBlock,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use windows::core::imp::BOOL;
|
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};
|
use windows::Win32::Graphics::Direct3D::{ID3DBlob, ID3DInclude, D3D_SHADER_MACRO};
|
||||||
|
|
||||||
const D3DERR_INVALIDCALL: u32 = 0x8876086c;
|
const D3DERR_INVALIDCALL: u32 = 0x8876086c;
|
||||||
|
@ -49,17 +49,17 @@ pub unsafe fn D3DXCompileShader<P1, P2, P3>(
|
||||||
ppconstanttable: Option<*mut Option<ID3DXConstantTable>>,
|
ppconstanttable: Option<*mut Option<ID3DXConstantTable>>,
|
||||||
) -> ::windows::core::Result<()>
|
) -> ::windows::core::Result<()>
|
||||||
where
|
where
|
||||||
P1: IntoParam<ID3DInclude>,
|
P1: Param<ID3DInclude>,
|
||||||
P2: IntoParam<PCSTR>,
|
P2: Param<PCSTR>,
|
||||||
P3: IntoParam<PCSTR>,
|
P3: Param<PCSTR>,
|
||||||
{
|
{
|
||||||
raw::D3DXCompileShader(
|
raw::D3DXCompileShader(
|
||||||
psrcdata,
|
psrcdata,
|
||||||
srcdatasize,
|
srcdatasize,
|
||||||
::core::mem::transmute(pdefines.unwrap_or(::std::ptr::null())),
|
::core::mem::transmute(pdefines.unwrap_or(::std::ptr::null())),
|
||||||
pinclude.into_param().abi(),
|
pinclude.param().abi(),
|
||||||
pfunctioname.into_param().abi(),
|
pfunctioname.param().abi(),
|
||||||
pprofile.into_param().abi(),
|
pprofile.param().abi(),
|
||||||
flags,
|
flags,
|
||||||
::core::mem::transmute(ppcode),
|
::core::mem::transmute(ppcode),
|
||||||
::core::mem::transmute(pperrormsgs.unwrap_or(::std::ptr::null_mut())),
|
::core::mem::transmute(pperrormsgs.unwrap_or(::std::ptr::null_mut())),
|
||||||
|
@ -68,9 +68,11 @@ where
|
||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(transparent)]
|
windows::core::imp::define_interface!(
|
||||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
ID3DXConstantTable,
|
||||||
pub struct ID3DXConstantTable(windows::core::IUnknown);
|
ID3DXConstantTable_Vtbl,
|
||||||
|
0xab3c758f_93e_4356_b7_62_4d_b1_8f_1b_3a1
|
||||||
|
);
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl ID3DXConstantTable {
|
impl ID3DXConstantTable {
|
||||||
|
@ -79,7 +81,8 @@ impl ID3DXConstantTable {
|
||||||
p_function: *const c_void,
|
p_function: *const c_void,
|
||||||
) -> windows::core::Result<ID3DXConstantTable> {
|
) -> windows::core::Result<ID3DXConstantTable> {
|
||||||
let mut result__ = ::std::mem::zeroed();
|
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)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -150,12 +153,12 @@ impl ID3DXConstantTable {
|
||||||
pname: P,
|
pname: P,
|
||||||
) -> windows::core::Result<D3DXHANDLE>
|
) -> windows::core::Result<D3DXHANDLE>
|
||||||
where
|
where
|
||||||
P: IntoParam<PCSTR>,
|
P: Param<PCSTR>,
|
||||||
{
|
{
|
||||||
let handle = (windows::core::Interface::vtable(self).GetConstantByName)(
|
let handle = (windows::core::Interface::vtable(self).GetConstantByName)(
|
||||||
windows::core::Interface::as_raw(self),
|
windows::core::Interface::as_raw(self),
|
||||||
hconstant.unwrap_or(D3DXHANDLE(std::ptr::null())),
|
hconstant.unwrap_or(D3DXHANDLE(std::ptr::null())),
|
||||||
pname.into_param().abi(),
|
pname.param().abi(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if handle.0 as u32 == D3DERR_INVALIDCALL {
|
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)]
|
#[repr(C)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
@ -430,8 +428,3 @@ pub enum D3DXPARAMETER_TYPE {
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct D3DXHANDLE(pub *const c_void);
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,13 +6,7 @@ use librashader_runtime::quad::{QuadType, VertexInput};
|
||||||
|
|
||||||
use windows::Win32::Foundation::FALSE;
|
use windows::Win32::Foundation::FALSE;
|
||||||
|
|
||||||
use windows::Win32::Graphics::Direct3D9::{
|
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};
|
||||||
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,
|
|
||||||
};
|
|
||||||
|
|
||||||
const OFFSCREEN_VBO_DATA: [VertexInput; 4] = [
|
const OFFSCREEN_VBO_DATA: [VertexInput; 4] = [
|
||||||
VertexInput {
|
VertexInput {
|
||||||
|
@ -111,6 +105,7 @@ impl DrawQuad {
|
||||||
device.SetRenderState(D3DRS_ZENABLE, FALSE.0 as u32)?;
|
device.SetRenderState(D3DRS_ZENABLE, FALSE.0 as u32)?;
|
||||||
device.SetRenderState(D3DRS_LIGHTING, FALSE.0 as u32)?;
|
device.SetRenderState(D3DRS_LIGHTING, FALSE.0 as u32)?;
|
||||||
|
|
||||||
|
device.SetRenderState(D3DRS_COLORWRITEENABLE, 0xfu32)?;
|
||||||
device.BeginScene()?;
|
device.BeginScene()?;
|
||||||
device.SetStreamSource(0, &self.vbo, 0, std::mem::size_of::<VertexInput>() as u32)?;
|
device.SetStreamSource(0, &self.vbo, 0, std::mem::size_of::<VertexInput>() as u32)?;
|
||||||
// device.SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1)?;
|
// device.SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1)?;
|
||||||
|
|
|
@ -89,6 +89,7 @@ where
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let hwnd = hwnd?;
|
||||||
sample.bind_to_window(&hwnd).unwrap();
|
sample.bind_to_window(&hwnd).unwrap();
|
||||||
unsafe { ShowWindow(hwnd, SW_SHOW) };
|
unsafe { ShowWindow(hwnd, SW_SHOW) };
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime-gl"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -12,12 +12,12 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
|
||||||
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1" }
|
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1" }
|
||||||
|
|
||||||
gl = "0.14.0"
|
gl = "0.14.0"
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime-mtl"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["metal"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["metal"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
|
||||||
|
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime-vk"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["vulkan"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["vulkan"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
|
||||||
|
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "librashader-runtime-wgpu"
|
name = "librashader-runtime-wgpu"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8", features = ["wgsl"], default-features = false }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0", features = ["wgsl"], default-features = false }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
|
||||||
|
|
||||||
wgpu = { version = "22.0", default-features = false, features = ["wgsl"] }
|
wgpu = { version = "22.0", default-features = false, features = ["wgsl"] }
|
||||||
image = "0.25.1"
|
image = "0.25.1"
|
||||||
|
|
|
@ -25,7 +25,7 @@ use librashader_reflect::reflect::naga::{Naga, NagaLoweringOptions};
|
||||||
use librashader_runtime::framebuffer::FramebufferInit;
|
use librashader_runtime::framebuffer::FramebufferInit;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::scaling::ScaleFramebuffer;
|
use librashader_runtime::scaling::ScaleFramebuffer;
|
||||||
use wgpu::{AdapterInfo, Device, TextureFormat};
|
use wgpu::{Device, TextureFormat};
|
||||||
|
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::error::FilterChainError;
|
use crate::error::FilterChainError;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::error::FilterChainError;
|
|
||||||
use crate::framebuffer::WgpuOutputView;
|
use crate::framebuffer::WgpuOutputView;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use librashader_cache::cache_pipeline;
|
use librashader_cache::cache_pipeline;
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "librashader-runtime"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
license = "MPL-2.0 OR GPL-3.0-only"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -12,10 +12,10 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
num-traits = "0.2.15"
|
num-traits = "0.2.15"
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
|
|
|
@ -4,7 +4,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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"
|
license = "MPL-2.0 OR GPL-3.0-only"
|
||||||
version = "0.2.8"
|
version = "0.3.0"
|
||||||
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
|
||||||
repository = "https://github.com/SnowflakePowered/librashader"
|
repository = "https://github.com/SnowflakePowered/librashader"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
@ -13,25 +13,25 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
librashader-common = { path = "../librashader-common", version = "0.2.8" }
|
librashader-common = { path = "../librashader-common", version = "0.3.0" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.8" }
|
librashader-presets = { path = "../librashader-presets", version = "0.3.0" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.8" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.0" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.8" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.3.0" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.8" }
|
librashader-cache = { path = "../librashader-cache", version = "0.3.0" }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.8" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.3.0" }
|
||||||
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.2.8", optional = true }
|
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.3.0", optional = true }
|
||||||
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.2.8", optional = true }
|
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.3.0", optional = true }
|
||||||
librashader-runtime-d3d9 = { path = "../librashader-runtime-d3d9", version = "0.2.8", optional = true }
|
librashader-runtime-d3d9 = { path = "../librashader-runtime-d3d9", version = "0.3.0", optional = true }
|
||||||
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.2.8", optional = true }
|
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.3.0", optional = true }
|
||||||
librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.2.8", optional = true }
|
librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.3.0", optional = true }
|
||||||
librashader-runtime-mtl = { path = "../librashader-runtime-mtl", version = "0.2.8", optional = true }
|
librashader-runtime-mtl = { path = "../librashader-runtime-mtl", version = "0.3.0", optional = true }
|
||||||
|
|
||||||
ash = { version = "0.38", optional = true }
|
ash = { version = "0.38", optional = true }
|
||||||
halfbrown = "0.2.4"
|
halfbrown = "0.2.4"
|
||||||
|
|
||||||
[target.'cfg(not(all(target_vendor="apple", docsrs)))'.dependencies]
|
[target.'cfg(not(all(target_vendor="apple", docsrs)))'.dependencies]
|
||||||
wgpu = { version = "22", default-features = false, optional = true }
|
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 }
|
wgpu-types = { version = "22", optional = true }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.windows]
|
[target.'cfg(windows)'.dependencies.windows]
|
||||||
|
|
|
@ -259,7 +259,7 @@ pub mod runtime {
|
||||||
options::{
|
options::{
|
||||||
FilterChainOptionsD3D11 as FilterChainOptions, FrameOptionsD3D11 as FrameOptions,
|
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")]
|
#[cfg(feature = "runtime-wgpu")]
|
||||||
#[doc(cfg(feature = "runtime-wgpu"))]
|
#[doc(cfg(feature = "runtime-wgpu"))]
|
||||||
/// Shader runtime for 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 {
|
pub mod wgpu {
|
||||||
#[cfg(not(all(target_vendor = "apple", feature = "docsrs")))]
|
|
||||||
pub use librashader_runtime_wgpu::{
|
pub use librashader_runtime_wgpu::{
|
||||||
error,
|
error,
|
||||||
options::{
|
options::{
|
||||||
|
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
|
@ -1 +1 @@
|
||||||
Subproject commit d668788a29a390704a07fba99895ee69a6707f45
|
Subproject commit e04aa575febae5927db6b445a3c47b8f4221df78
|
Loading…
Reference in a new issue