deps: upgrade to windows 0.48.0

This commit is contained in:
chyyran 2023-04-23 01:13:31 -04:00 committed by Ronny Chan
parent 70aa4091e0
commit 020fac87ba
25 changed files with 243 additions and 123 deletions

69
Cargo.lock generated
View file

@ -2552,11 +2552,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.44.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.48.0",
] ]
[[package]] [[package]]
@ -2578,7 +2578,7 @@ version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.42.1",
] ]
[[package]] [[package]]
@ -2587,21 +2587,42 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.42.1",
"windows_aarch64_msvc 0.42.1", "windows_aarch64_msvc 0.42.1",
"windows_i686_gnu 0.42.1", "windows_i686_gnu 0.42.1",
"windows_i686_msvc 0.42.1", "windows_i686_msvc 0.42.1",
"windows_x86_64_gnu 0.42.1", "windows_x86_64_gnu 0.42.1",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.42.1",
"windows_x86_64_msvc 0.42.1", "windows_x86_64_msvc 0.42.1",
] ]
[[package]]
name = "windows-targets"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
dependencies = [
"windows_aarch64_gnullvm 0.48.0",
"windows_aarch64_msvc 0.48.0",
"windows_i686_gnu 0.48.0",
"windows_i686_msvc 0.48.0",
"windows_x86_64_gnu 0.48.0",
"windows_x86_64_gnullvm 0.48.0",
"windows_x86_64_msvc 0.48.0",
]
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.42.1" version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.36.1" version = "0.36.1"
@ -2614,6 +2635,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.36.1" version = "0.36.1"
@ -2626,6 +2653,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.36.1" version = "0.36.1"
@ -2638,6 +2671,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.36.1" version = "0.36.1"
@ -2650,12 +2689,24 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.1" version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.36.1" version = "0.36.1"
@ -2668,6 +2719,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]] [[package]]
name = "winit" name = "winit"
version = "0.27.5" version = "0.27.5"

View file

@ -23,7 +23,7 @@ rusqlite = { version = "0.28.0", features = ["bundled"] }
bytemuck = "1.13.0" bytemuck = "1.13.0"
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.44.0" version = "0.48.0"
features = [ features = [
"Win32_Graphics_Direct3D", "Win32_Graphics_Direct3D",
"Win32_Graphics_Direct3D_Fxc", "Win32_Graphics_Direct3D_Fxc",

View file

@ -2,6 +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;
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] {
@ -52,7 +53,7 @@ impl Cacheable for windows::Win32::Graphics::Direct3D::Dxc::IDxcBlob {
return None; return None;
}; };
Some(blob.into()) Some(blob.cast().ok()?)
} }
fn to_bytes(&self) -> Option<Vec<u8>> { fn to_bytes(&self) -> Option<Vec<u8>> {

View file

@ -32,7 +32,7 @@ ash = { version = "0.37.2+1.3.238", optional = true }
spirv_cross = { package = "librashader-spirv-cross", version = "0.23" } spirv_cross = { package = "librashader-spirv-cross", version = "0.23" }
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.44.0" version = "0.48.0"
optional = true optional = true
[package.metadata.docs.rs] [package.metadata.docs.rs]

View file

@ -5,4 +5,4 @@ pub fn main() {
println!("cargo:rustc-link-arg=/DELAYLOAD:dxcompiler.dll"); println!("cargo:rustc-link-arg=/DELAYLOAD:dxcompiler.dll");
println!("cargo:rustc-link-arg=/DELAYLOAD:d3d12.dll"); println!("cargo:rustc-link-arg=/DELAYLOAD:d3d12.dll");
} }
} }

View file

@ -27,7 +27,7 @@ num-traits = "0.2.15"
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
optional = true optional = true
version = "0.44.0" version = "0.48.0"
features = [ features = [
"Win32_Foundation", "Win32_Foundation",
"Win32_Graphics_Dxgi_Common", "Win32_Graphics_Dxgi_Common",

View file

@ -1,15 +1,18 @@
use std::ops::RangeFrom;
use crate::error::ParsePresetError; use crate::error::ParsePresetError;
use crate::parse::Span; use crate::parse::Span;
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::{is_not, take_until}; use nom::bytes::complete::{is_not, take_until};
use nom::character::complete::{char, line_ending, multispace1, not_line_ending}; use nom::character::complete::{char, line_ending, multispace1, not_line_ending};
use std::ops::RangeFrom;
use nom::combinator::{eof, map_res, value}; use nom::combinator::{eof, map_res, value};
use nom::error::{ErrorKind, ParseError}; use nom::error::{ErrorKind, ParseError};
use nom::sequence::delimited; use nom::sequence::delimited;
use nom::{bytes::complete::tag, character::complete::multispace0, IResult, InputIter, InputLength, InputTake, Slice, AsChar}; use nom::{
bytes::complete::tag, character::complete::multispace0, AsChar, IResult, InputIter,
InputLength, InputTake, Slice,
};
#[derive(Debug)] #[derive(Debug)]
pub struct Token<'a> { pub struct Token<'a> {
@ -51,9 +54,10 @@ fn parse_assignment(input: Span) -> IResult<Span, ()> {
} }
fn unbalanced_quote<I>(input: I) -> IResult<I, ()> fn unbalanced_quote<I>(input: I) -> IResult<I, ()>
where I: Slice<RangeFrom<usize>> + InputIter + InputLength, where
<I as InputIter>::Item: AsChar, I: Slice<RangeFrom<usize>> + InputIter + InputLength,
I: Copy <I as InputIter>::Item: AsChar,
I: Copy,
{ {
if let Ok((input, _)) = eof::<_, ()>(input) { if let Ok((input, _)) = eof::<_, ()>(input) {
Ok((input, ())) Ok((input, ()))

View file

@ -530,7 +530,6 @@ pub fn parse_values(
param_val, param_val,
)); ));
} }
// very last resort, assume undeclared texture (must have extension) // very last resort, assume undeclared texture (must have extension)
else if Path::new(token.value.fragment()).extension().is_some() else if Path::new(token.value.fragment()).extension().is_some()
&& ["_mipmap", "_linear", "_wrap_mode", "_repeat_mode"] && ["_mipmap", "_linear", "_wrap_mode", "_repeat_mode"]

View file

@ -15,7 +15,5 @@ fn parses_all_slang_presets() {
#[test] #[test]
fn parses_problematic() { fn parses_problematic() {
let path = "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_NDS_DREZ/NDS-[DREZ]-[Native]-[ADV]-[Guest]-[Night].slangp"; let path = "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_NDS_DREZ/NDS-[DREZ]-[Native]-[ADV]-[Guest]-[Night].slangp";
ShaderPreset::try_parse(path) ShaderPreset::try_parse(path).expect(&format!("Failed to parse {}", path));
.expect(&format!("Failed to parse {}", path));
} }

View file

@ -27,7 +27,7 @@ rayon = "1.6.1"
array-concat = "0.5.2" array-concat = "0.5.2"
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.44.0" version = "0.48.0"
features = [ features = [
"Win32_Foundation", "Win32_Foundation",
"Win32_Graphics_Dxgi_Common", "Win32_Graphics_Dxgi_Common",
@ -35,12 +35,11 @@ features = [
"Win32_Graphics_Direct3D11", "Win32_Graphics_Direct3D11",
"Win32_Graphics_Direct3D_Fxc", "Win32_Graphics_Direct3D_Fxc",
"Win32_System_Threading", "Win32_System_Threading",
"Win32_System_WindowsProgramming",
"Win32_Security", "Win32_Security",
] ]
[target.'cfg(windows)'.dev-dependencies.windows] [target.'cfg(windows)'.dev-dependencies.windows]
version = "0.44.0" version = "0.48.0"
features = [ features = [
"Win32_Foundation", "Win32_Foundation",
"Win32_Graphics_Dxgi_Common", "Win32_Graphics_Dxgi_Common",
@ -51,7 +50,6 @@ features = [
"Win32_Security", "Win32_Security",
"Win32_System_LibraryLoader", "Win32_System_LibraryLoader",
"Win32_System_Threading", "Win32_System_Threading",
"Win32_System_WindowsProgramming",
"Win32_UI_WindowsAndMessaging", "Win32_UI_WindowsAndMessaging",
] ]

View file

@ -190,10 +190,10 @@ impl FilterPass {
} }
if ubo.stage_mask.contains(BindingStage::VERTEX) { if ubo.stage_mask.contains(BindingStage::VERTEX) {
unsafe { ctx.VSSetConstantBuffers(ubo.binding, Some(&[ubo.buffer.clone()])) } unsafe { ctx.VSSetConstantBuffers(ubo.binding, Some(&[Some(ubo.buffer.clone())])) }
} }
if ubo.stage_mask.contains(BindingStage::FRAGMENT) { if ubo.stage_mask.contains(BindingStage::FRAGMENT) {
unsafe { ctx.PSSetConstantBuffers(ubo.binding, Some(&[ubo.buffer.clone()])) } unsafe { ctx.PSSetConstantBuffers(ubo.binding, Some(&[Some(ubo.buffer.clone())])) }
} }
} }
@ -211,10 +211,14 @@ impl FilterPass {
} }
if push.stage_mask.contains(BindingStage::VERTEX) { if push.stage_mask.contains(BindingStage::VERTEX) {
unsafe { ctx.VSSetConstantBuffers(push.binding, Some(&[push.buffer.clone()])) } unsafe {
ctx.VSSetConstantBuffers(push.binding, Some(&[Some(push.buffer.clone())]))
}
} }
if push.stage_mask.contains(BindingStage::FRAGMENT) { if push.stage_mask.contains(BindingStage::FRAGMENT) {
unsafe { ctx.PSSetConstantBuffers(push.binding, Some(&[push.buffer.clone()])) } unsafe {
ctx.PSSetConstantBuffers(push.binding, Some(&[Some(push.buffer.clone())]))
}
} }
} }
@ -233,7 +237,7 @@ impl FilterPass {
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(&[output.output.handle.clone()]), None); ctx.OMSetRenderTargets(Some(&[Some(output.output.handle.clone())]), None);
ctx.RSSetViewports(Some(&[D3D11_VIEWPORT { ctx.RSSetViewports(Some(&[D3D11_VIEWPORT {
TopLeftX: output.x, TopLeftX: output.x,
TopLeftY: output.y, TopLeftY: output.y,

View file

@ -5,7 +5,7 @@ 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::Interface; use windows::core::ComInterface;
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,

View file

@ -145,7 +145,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: Into<windows::core::InParam<ID3D11ClassLinkage>>, L: windows::core::IntoParam<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.

View file

@ -489,10 +489,10 @@ pub mod d3d11_hello_triangle {
unsafe { unsafe {
self.context.VSSetConstantBuffers( self.context.VSSetConstantBuffers(
buffer_number, buffer_number,
Some(&[resources.triangle_uniforms.clone()]), Some(&[Some(resources.triangle_uniforms.clone())]),
); );
self.context.OMSetRenderTargets( self.context.OMSetRenderTargets(
Some(&[resources.renderbufffer_rtv.clone()]), Some(&[Some(resources.renderbufffer_rtv.clone())]),
&resources.depth_stencil_view, &resources.depth_stencil_view,
); );
self.context.RSSetViewports(Some(&[resources.viewport])) self.context.RSSetViewports(Some(&[resources.viewport]))
@ -845,7 +845,7 @@ pub mod d3d11_hello_triangle {
D3D11CreateDevice( D3D11CreateDevice(
None, None,
D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_HARDWARE,
HINSTANCE::default(), HMODULE::default(),
D3D11_CREATE_DEVICE_DEBUG, D3D11_CREATE_DEVICE_DEBUG,
Some(&feature_levels), Some(&feature_levels),
D3D11_SDK_VERSION, D3D11_SDK_VERSION,

View file

@ -33,7 +33,7 @@ array-concat = "0.5.2"
rayon = "1.6.1" rayon = "1.6.1"
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.44.0" version = "0.48.0"
features = [ features = [
"Win32_Foundation", "Win32_Foundation",
"Win32_Graphics_Dxgi_Common", "Win32_Graphics_Dxgi_Common",
@ -41,12 +41,11 @@ features = [
"Win32_Graphics_Direct3D12", "Win32_Graphics_Direct3D12",
"Win32_Graphics_Direct3D_Dxc", "Win32_Graphics_Direct3D_Dxc",
"Win32_System_Threading", "Win32_System_Threading",
"Win32_System_WindowsProgramming",
"Win32_Security", "Win32_Security",
] ]
[target.'cfg(windows)'.dev-dependencies.windows] [target.'cfg(windows)'.dev-dependencies.windows]
version = "0.44.0" version = "0.48.0"
features = [ features = [
"Win32_Foundation", "Win32_Foundation",
"Win32_Graphics_Dxgi_Common", "Win32_Graphics_Dxgi_Common",
@ -60,7 +59,6 @@ features = [
"Win32_System_Threading", "Win32_System_Threading",
"Win32_UI_WindowsAndMessaging", "Win32_UI_WindowsAndMessaging",
"Win32_System_Threading", "Win32_System_Threading",
"Win32_System_WindowsProgramming",
] ]
[[test]] [[test]]

View file

@ -29,8 +29,9 @@ use librashader_runtime::uniforms::UniformStorage;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use spirv_cross::hlsl::ShaderModel; use spirv_cross::hlsl::ShaderModel;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::mem::ManuallyDrop;
use std::path::Path; use std::path::Path;
use windows::core::Interface; use windows::core::ComInterface;
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,
@ -38,13 +39,12 @@ use windows::Win32::Graphics::Direct3D::Dxc::{
}; };
use windows::Win32::Graphics::Direct3D12::{ use windows::Win32::Graphics::Direct3D12::{
ID3D12CommandAllocator, ID3D12CommandQueue, ID3D12DescriptorHeap, ID3D12Device, ID3D12Fence, ID3D12CommandAllocator, ID3D12CommandQueue, ID3D12DescriptorHeap, ID3D12Device, ID3D12Fence,
ID3D12GraphicsCommandList, D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_DESC, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_COMMAND_LIST_TYPE_DIRECT,
D3D12_COMMAND_QUEUE_FLAG_NONE, D3D12_FENCE_FLAG_NONE, D3D12_COMMAND_QUEUE_DESC, D3D12_COMMAND_QUEUE_FLAG_NONE, D3D12_FENCE_FLAG_NONE,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET,
}; };
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_UNKNOWN; use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_UNKNOWN;
use windows::Win32::System::Threading::{CreateEventA, WaitForSingleObject}; use windows::Win32::System::Threading::{CreateEventA, WaitForSingleObject, INFINITE};
use windows::Win32::System::WindowsProgramming::INFINITE;
use librashader_cache::CachedCompilation; use librashader_cache::CachedCompilation;
use librashader_runtime::framebuffer::FramebufferInit; use librashader_runtime::framebuffer::FramebufferInit;
@ -101,6 +101,7 @@ pub(crate) struct FrameResiduals {
outputs: Vec<OutputDescriptor>, outputs: Vec<OutputDescriptor>,
mipmaps: Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>, mipmaps: Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>,
mipmap_luts: Vec<D3D12MipmapGen>, mipmap_luts: Vec<D3D12MipmapGen>,
resources: Vec<ManuallyDrop<Option<ID3D12Resource>>>,
} }
impl FrameResiduals { impl FrameResiduals {
@ -109,6 +110,7 @@ impl FrameResiduals {
outputs: Vec::new(), outputs: Vec::new(),
mipmaps: Vec::new(), mipmaps: Vec::new(),
mipmap_luts: Vec::new(), mipmap_luts: Vec::new(),
resources: Vec::new(),
} }
} }
@ -127,9 +129,16 @@ impl FrameResiduals {
self.mipmaps.extend(handles) self.mipmaps.extend(handles)
} }
pub fn dispose_resource(&mut self, resource: ManuallyDrop<Option<ID3D12Resource>>) {
self.resources.push(resource)
}
pub fn dispose(&mut self) { pub fn dispose(&mut self) {
self.outputs.clear(); self.outputs.clear();
self.mipmaps.clear(); self.mipmaps.clear();
for resource in self.resources.drain(..) {
drop(ManuallyDrop::into_inner(resource))
}
} }
} }
@ -178,7 +187,7 @@ impl FilterChainD3D12 {
let filter_chain = Self::load_from_preset_deferred(preset, device, &cmd, options)?; let filter_chain = Self::load_from_preset_deferred(preset, device, &cmd, options)?;
cmd.Close()?; cmd.Close()?;
queue.ExecuteCommandLists(&[cmd.cast()?]); queue.ExecuteCommandLists(&[Some(cmd.cast()?)]);
queue.Signal(&fence, 1)?; queue.Signal(&fence, 1)?;
if fence.GetCompletedValue() < 1 { if fence.GetCompletedValue() < 1 {
@ -338,7 +347,7 @@ impl FilterChainD3D12 {
cmd: &ID3D12GraphicsCommandList, cmd: &ID3D12GraphicsCommandList,
staging_heap: &mut D3D12DescriptorHeap<CpuStagingHeap>, staging_heap: &mut D3D12DescriptorHeap<CpuStagingHeap>,
mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>, mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
trash: &mut FrameResiduals, gc: &mut FrameResiduals,
textures: &[TextureConfig], textures: &[TextureConfig],
) -> error::Result<FxHashMap<usize, LutTexture>> { ) -> error::Result<FxHashMap<usize, LutTexture>> {
// use separate mipgen to load luts. // use separate mipgen to load luts.
@ -359,20 +368,26 @@ impl FilterChainD3D12 {
texture.filter_mode, texture.filter_mode,
texture.wrap_mode, texture.wrap_mode,
texture.mipmap, texture.mipmap,
gc
)?; )?;
luts.insert(index, texture); luts.insert(index, texture);
} }
let residual_mipmap = mipmap_gen.mipmapping_context(cmd, mipmap_heap, |context| { let (residual_mipmap, residual_barrier) =
for lut in luts.values() { mipmap_gen.mipmapping_context(cmd, mipmap_heap, |context| {
lut.generate_mipmaps(context)?; for lut in luts.values() {
} lut.generate_mipmaps(context)?;
}
Ok::<(), FilterChainError>(()) Ok::<(), FilterChainError>(())
})?; })?;
trash.dispose_mipmap_handles(residual_mipmap); gc.dispose_mipmap_handles(residual_mipmap);
trash.dispose_mipmap_gen(mipmap_gen); gc.dispose_mipmap_gen(mipmap_gen);
for barrier in residual_barrier {
gc.dispose_resource(barrier.pResource)
}
Ok(luts) Ok(luts)
} }
@ -530,7 +545,7 @@ impl FilterChainD3D12 {
); );
} }
unsafe { unsafe {
back.copy_from(cmd, input)?; back.copy_from(cmd, input, &mut self.residuals)?;
} }
self.history_framebuffers.push_front(back); self.history_framebuffers.push_front(back);
} }
@ -644,7 +659,10 @@ impl FilterChainD3D12 {
let (pass, last) = passes.split_at_mut(passes_len - 1); let (pass, last) = passes.split_at_mut(passes_len - 1);
unsafe { unsafe {
let heaps = [self.work_heap.clone(), self.sampler_heap.clone()]; let heaps = [
Some(self.work_heap.clone()),
Some(self.sampler_heap.clone()),
];
cmd.SetDescriptorHeaps(&heaps); cmd.SetDescriptorHeaps(&heaps);
cmd.SetGraphicsRootSignature(&self.common.root_signature.handle); cmd.SetGraphicsRootSignature(&self.common.root_signature.handle);
self.common.mipmap_gen.pin_root_signature(cmd); self.common.mipmap_gen.pin_root_signature(cmd);
@ -698,7 +716,7 @@ impl FilterChainD3D12 {
); );
if target.max_mipmap > 1 && !self.disable_mipmaps { if target.max_mipmap > 1 && !self.disable_mipmaps {
let residuals = self.common.mipmap_gen.mipmapping_context( let (residuals, residual_uav) = self.common.mipmap_gen.mipmapping_context(
cmd, cmd,
&mut self.mipmap_heap, &mut self.mipmap_heap,
|ctx| { |ctx| {
@ -713,6 +731,9 @@ impl FilterChainD3D12 {
)?; )?;
self.residuals.dispose_mipmap_handles(residuals); self.residuals.dispose_mipmap_handles(residuals);
for uav in residual_uav {
self.residuals.dispose_resource(uav.pResource)
}
} }
self.residuals.dispose_output(view.descriptor); self.residuals.dispose_output(view.descriptor);

View file

@ -17,7 +17,7 @@ use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage}; use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use std::ops::Deref; use std::ops::Deref;
use windows::core::Interface; use windows::core::ComInterface;
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,

View file

@ -1,13 +1,14 @@
use crate::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap, RenderTargetHeap}; use crate::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap, RenderTargetHeap};
use crate::error::{assume_d3d12_init, FilterChainError}; use crate::error::{assume_d3d12_init, FilterChainError};
use crate::filter_chain::FrameResiduals;
use crate::texture::{D3D12OutputView, InputTexture}; use crate::texture::{D3D12OutputView, InputTexture};
use crate::util::d3d12_get_closest_format; use crate::util::d3d12_get_closest_format;
use crate::{error, util}; use crate::{error, util};
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode}; use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
use librashader_presets::Scale2D; use librashader_presets::Scale2D;
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize}; use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
use std::mem::ManuallyDrop;
use std::ops::Deref; use std::ops::Deref;
use windows::Win32::Foundation::RECT;
use windows::Win32::Graphics::Direct3D12::{ use windows::Win32::Graphics::Direct3D12::{
ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_BOX, ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_BOX,
D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
@ -138,6 +139,7 @@ impl OwnedImage {
&self, &self,
cmd: &ID3D12GraphicsCommandList, cmd: &ID3D12GraphicsCommandList,
input: &InputTexture, input: &InputTexture,
gc: &mut FrameResiduals,
) -> error::Result<()> { ) -> error::Result<()> {
let barriers = [ let barriers = [
util::d3d12_get_resource_transition_subresource( util::d3d12_get_resource_transition_subresource(
@ -157,24 +159,28 @@ impl OwnedImage {
unsafe { unsafe {
cmd.ResourceBarrier(&barriers); cmd.ResourceBarrier(&barriers);
let dst = D3D12_TEXTURE_COPY_LOCATION {
pResource: ManuallyDrop::new(Some(self.handle.clone())),
Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
SubresourceIndex: 0,
},
};
let src = D3D12_TEXTURE_COPY_LOCATION {
pResource: ManuallyDrop::new(Some(input.resource.clone())),
Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
SubresourceIndex: 0,
},
};
cmd.CopyTextureRegion( cmd.CopyTextureRegion(
&D3D12_TEXTURE_COPY_LOCATION { &dst,
pResource: windows::core::ManuallyDrop::new(&self.handle),
Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
SubresourceIndex: 0,
},
},
0, 0,
0, 0,
0, 0,
&D3D12_TEXTURE_COPY_LOCATION { &src,
pResource: windows::core::ManuallyDrop::new(&input.resource),
Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
SubresourceIndex: 0,
},
},
Some(&D3D12_BOX { Some(&D3D12_BOX {
left: 0, left: 0,
top: 0, top: 0,
@ -184,6 +190,9 @@ impl OwnedImage {
back: 1, back: 1,
}), }),
); );
gc.dispose_resource(dst.pResource);
gc.dispose_resource(src.pResource);
} }
let barriers = [ let barriers = [
@ -204,6 +213,7 @@ impl OwnedImage {
unsafe { unsafe {
cmd.ResourceBarrier(&barriers); cmd.ResourceBarrier(&barriers);
} }
Ok(()) Ok(())
} }
@ -221,17 +231,7 @@ impl OwnedImage {
let rtv = self.create_render_target_view(heap)?; let rtv = self.create_render_target_view(heap)?;
let rect = RECT { unsafe { cmd.ClearRenderTargetView(*rtv.descriptor.as_ref(), CLEAR.as_ptr(), None) }
left: 0,
top: 0,
right: self.size.width as i32,
bottom: self.size.height as i32,
};
unsafe {
// todo: more efficient if we don't pass the rect but.. waiting on windows-rs updates
cmd.ClearRenderTargetView(*rtv.descriptor.as_ref(), CLEAR.as_ptr(), &[rect])
}
util::d3d12_resource_transition( util::d3d12_resource_transition(
cmd, cmd,

View file

@ -6,8 +6,10 @@ use librashader_cache::{cache_pipeline, cache_shader_object};
use librashader_reflect::back::cross::CrossHlslContext; use librashader_reflect::back::cross::CrossHlslContext;
use librashader_reflect::back::dxil::DxilObject; use librashader_reflect::back::dxil::DxilObject;
use librashader_reflect::back::ShaderCompilerOutput; use librashader_reflect::back::ShaderCompilerOutput;
use std::mem::ManuallyDrop;
use std::ops::Deref; use std::ops::Deref;
use widestring::u16cstr; use widestring::u16cstr;
use windows::core::ComInterface;
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,
@ -159,7 +161,7 @@ impl D3D12GraphicsPipeline {
let pipeline_state: ID3D12PipelineState = unsafe { let pipeline_state: ID3D12PipelineState = unsafe {
let pipeline_desc = D3D12_GRAPHICS_PIPELINE_STATE_DESC { let pipeline_desc = D3D12_GRAPHICS_PIPELINE_STATE_DESC {
pRootSignature: windows::core::ManuallyDrop::new(&root_signature.handle), pRootSignature: ManuallyDrop::new(Some(root_signature.handle.clone())),
VS: D3D12_SHADER_BYTECODE { VS: D3D12_SHADER_BYTECODE {
pShaderBytecode: vertex_dxil.GetBufferPointer(), pShaderBytecode: vertex_dxil.GetBufferPointer(),
BytecodeLength: vertex_dxil.GetBufferSize(), BytecodeLength: vertex_dxil.GetBufferSize(),
@ -224,7 +226,7 @@ impl D3D12GraphicsPipeline {
..Default::default() ..Default::default()
}; };
cache_pipeline( let pipeline = cache_pipeline(
"d3d12", "d3d12",
&[&vertex_dxil, &fragment_dxil, &render_format.0], &[&vertex_dxil, &fragment_dxil, &render_format.0],
|cached: Option<Vec<u8>>| { |cached: Option<Vec<u8>>| {
@ -234,12 +236,12 @@ impl D3D12GraphicsPipeline {
pCachedBlob: cached.as_ptr().cast(), pCachedBlob: cached.as_ptr().cast(),
CachedBlobSizeInBytes: cached.len(), CachedBlobSizeInBytes: cached.len(),
}, },
pRootSignature: windows::core::ManuallyDrop::new( pRootSignature: ManuallyDrop::new(Some(root_signature.handle.clone())),
&root_signature.handle,
),
..pipeline_desc ..pipeline_desc
}; };
device.CreateGraphicsPipelineState(&pipeline_desc) let pipeline_state = device.CreateGraphicsPipelineState(&pipeline_desc);
drop(ManuallyDrop::into_inner(pipeline_desc.pRootSignature));
pipeline_state
} else { } else {
device.CreateGraphicsPipelineState(&pipeline_desc) device.CreateGraphicsPipelineState(&pipeline_desc)
} }
@ -249,7 +251,12 @@ impl D3D12GraphicsPipeline {
Ok(cached_pso) Ok(cached_pso)
}, },
disable_cache, disable_cache,
)? )?;
// cleanup handle
drop(ManuallyDrop::into_inner(pipeline_desc.pRootSignature));
pipeline
}; };
unsafe { unsafe {
@ -293,8 +300,8 @@ impl D3D12GraphicsPipeline {
}; };
let mut new_pipeline = Self::new_from_blobs( let mut new_pipeline = Self::new_from_blobs(
device, device,
vertex.into(), vertex.cast()?,
fragment.into(), fragment.cast()?,
root_sig, root_sig,
format, format,
self.cache_disabled, self.cache_disabled,

View file

@ -22,6 +22,7 @@ use windows::Win32::Graphics::Direct3D12::{
D3D12_TEX2D_SRV, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_TEX2D_SRV, D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
}; };
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC; use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
use crate::filter_chain::FrameResiduals;
pub struct LutTexture { pub struct LutTexture {
resource: ID3D12Resource, resource: ID3D12Resource,
@ -31,7 +32,7 @@ pub struct LutTexture {
} }
impl LutTexture { impl LutTexture {
pub fn new( pub(crate) fn new(
device: &ID3D12Device, device: &ID3D12Device,
heap: &mut D3D12DescriptorHeap<CpuStagingHeap>, heap: &mut D3D12DescriptorHeap<CpuStagingHeap>,
cmd: &ID3D12GraphicsCommandList, cmd: &ID3D12GraphicsCommandList,
@ -39,6 +40,7 @@ impl LutTexture {
filter: FilterMode, filter: FilterMode,
wrap_mode: WrapMode, wrap_mode: WrapMode,
mipmap: bool, mipmap: bool,
gc: &mut FrameResiduals,
) -> error::Result<LutTexture> { ) -> error::Result<LutTexture> {
let miplevels = source.size.calculate_miplevels() as u16; let miplevels = source.size.calculate_miplevels() as u16;
let mut desc = D3D12_RESOURCE_DESC { let mut desc = D3D12_RESOURCE_DESC {
@ -170,7 +172,7 @@ impl LutTexture {
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_DEST,
); );
d3d12_update_subresources(cmd, &resource, &upload, 0, 0, 1, &subresource)?; d3d12_update_subresources(cmd, &resource, &upload, 0, 0, 1, &subresource, gc)?;
d3d12_resource_transition( d3d12_resource_transition(
cmd, cmd,

View file

@ -85,6 +85,7 @@ pub struct MipmapGenContext<'a> {
cmd: &'a ID3D12GraphicsCommandList, cmd: &'a ID3D12GraphicsCommandList,
heap: &'a mut D3D12DescriptorHeap<ResourceWorkHeap>, heap: &'a mut D3D12DescriptorHeap<ResourceWorkHeap>,
residuals: Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>, residuals: Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>,
residual_uav_descs: Vec<D3D12_RESOURCE_UAV_BARRIER>,
} }
impl<'a> MipmapGenContext<'a> { impl<'a> MipmapGenContext<'a> {
@ -98,6 +99,7 @@ impl<'a> MipmapGenContext<'a> {
cmd, cmd,
heap, heap,
residuals: Vec::new(), residuals: Vec::new(),
residual_uav_descs: Vec::new(),
} }
} }
@ -111,17 +113,23 @@ impl<'a> MipmapGenContext<'a> {
format: DXGI_FORMAT, format: DXGI_FORMAT,
) -> error::Result<()> { ) -> error::Result<()> {
unsafe { unsafe {
let residuals = self let (residuals_heap, residual_barriers) = self
.gen .gen
.generate_mipmaps(self.cmd, resource, miplevels, size, format, self.heap)?; .generate_mipmaps(self.cmd, resource, miplevels, size, format, self.heap)?;
self.residuals.extend(residuals) self.residuals.extend(residuals_heap);
self.residual_uav_descs.extend(residual_barriers);
} }
Ok(()) Ok(())
} }
fn close(self) -> Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>> { fn close(
self.residuals self,
) -> (
Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>,
Vec<D3D12_RESOURCE_UAV_BARRIER>,
) {
(self.residuals, self.residual_uav_descs)
} }
} }
@ -138,7 +146,7 @@ impl D3D12MipmapGen {
let root_signature: ID3D12RootSignature = device.CreateRootSignature(0, blob)?; let root_signature: ID3D12RootSignature = device.CreateRootSignature(0, blob)?;
let desc = D3D12_COMPUTE_PIPELINE_STATE_DESC { let desc = D3D12_COMPUTE_PIPELINE_STATE_DESC {
pRootSignature: windows::core::ManuallyDrop::new(&root_signature), pRootSignature: ManuallyDrop::new(Some(root_signature.clone())),
CS: D3D12_SHADER_BYTECODE { CS: D3D12_SHADER_BYTECODE {
pShaderBytecode: blob.as_ptr().cast(), pShaderBytecode: blob.as_ptr().cast(),
BytecodeLength: blob.len(), BytecodeLength: blob.len(),
@ -148,7 +156,7 @@ impl D3D12MipmapGen {
}; };
let pipeline = device.CreateComputePipelineState(&desc)?; let pipeline = device.CreateComputePipelineState(&desc)?;
drop(ManuallyDrop::into_inner(desc.pRootSignature));
Ok(D3D12MipmapGen { Ok(D3D12MipmapGen {
device: device.clone(), device: device.clone(),
root_signature, root_signature,
@ -184,7 +192,13 @@ impl D3D12MipmapGen {
cmd: &ID3D12GraphicsCommandList, cmd: &ID3D12GraphicsCommandList,
work_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>, work_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
mut f: F, mut f: F,
) -> Result<Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>, E> ) -> Result<
(
Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>,
Vec<D3D12_RESOURCE_UAV_BARRIER>,
),
E,
>
where where
F: FnMut(&mut MipmapGenContext) -> Result<(), E>, F: FnMut(&mut MipmapGenContext) -> Result<(), E>,
{ {
@ -194,7 +208,7 @@ impl D3D12MipmapGen {
if self.own_heaps { if self.own_heaps {
cmd.SetComputeRootSignature(&self.root_signature); cmd.SetComputeRootSignature(&self.root_signature);
cmd.SetDescriptorHeaps(&[heap]); cmd.SetDescriptorHeaps(&[Some(heap)]);
} }
} }
@ -214,7 +228,10 @@ impl D3D12MipmapGen {
size: Size<u32>, size: Size<u32>,
format: DXGI_FORMAT, format: DXGI_FORMAT,
work_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>, work_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
) -> error::Result<Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>> { ) -> error::Result<(
Vec<D3D12DescriptorHeapSlot<ResourceWorkHeap>>,
Vec<D3D12_RESOURCE_UAV_BARRIER>,
)> {
// create views for mipmap generation // create views for mipmap generation
let srv = work_heap.alloc_slot()?; let srv = work_heap.alloc_slot()?;
unsafe { unsafe {
@ -265,6 +282,7 @@ impl D3D12MipmapGen {
cmd.SetComputeRootDescriptorTable(0, *heap_slots[0].deref().as_ref()); cmd.SetComputeRootDescriptorTable(0, *heap_slots[0].deref().as_ref());
} }
let mut residual_uavs = Vec::new();
for i in 1..miplevels as u32 { for i in 1..miplevels as u32 {
let scaled = size.scale_mipmap(i); let scaled = size.scale_mipmap(i);
let mipmap_params = MipConstants { let mipmap_params = MipConstants {
@ -307,10 +325,8 @@ impl D3D12MipmapGen {
); );
} }
// todo: handle manuallyDrop properly.
let uav_barrier = ManuallyDrop::new(D3D12_RESOURCE_UAV_BARRIER { let uav_barrier = ManuallyDrop::new(D3D12_RESOURCE_UAV_BARRIER {
pResource: windows::core::ManuallyDrop::new(resource), pResource: ManuallyDrop::new(Some(resource.clone())),
}); });
let barriers = [ let barriers = [
@ -336,8 +352,15 @@ impl D3D12MipmapGen {
unsafe { unsafe {
cmd.ResourceBarrier(&barriers); cmd.ResourceBarrier(&barriers);
} }
let uav = unsafe {
let [barrier, ..] = barriers;
barrier.Anonymous.UAV
};
residual_uavs.push(ManuallyDrop::into_inner(uav))
} }
Ok(heap_slots) Ok((heap_slots, residual_uavs))
} }
} }

View file

@ -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::PCWSTR; use windows::core::{ComInterface, 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,
@ -20,6 +20,7 @@ use windows::Win32::Graphics::Direct3D12::{
D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
}; };
use windows::Win32::Graphics::Dxgi::Common::*; use windows::Win32::Graphics::Dxgi::Common::*;
use crate::filter_chain::FrameResiduals;
/// wtf retroarch? /// wtf retroarch?
const DXGI_FORMAT_EX_A4R4G4B4_UNORM: DXGI_FORMAT = DXGI_FORMAT(1000); const DXGI_FORMAT_EX_A4R4G4B4_UNORM: DXGI_FORMAT = DXGI_FORMAT(1000);
@ -166,7 +167,7 @@ pub fn dxc_validate_shader(
unsafe { unsafe {
let _result = validator.Validate(&blob, DxcValidatorFlags_InPlaceEdit)?; let _result = validator.Validate(&blob, DxcValidatorFlags_InPlaceEdit)?;
Ok(IDxcBlob::from(blob)) Ok(blob.cast()?)
} }
} }
@ -197,7 +198,7 @@ pub fn d3d12_get_resource_transition_subresource(
Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE,
Anonymous: D3D12_RESOURCE_BARRIER_0 { Anonymous: D3D12_RESOURCE_BARRIER_0 {
Transition: ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { Transition: ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER {
pResource: windows::core::ManuallyDrop::new(resource), pResource: ManuallyDrop::new(Some(resource.clone())),
Subresource: subresource, Subresource: subresource,
StateBefore: before, StateBefore: before,
StateAfter: after, StateAfter: after,
@ -223,7 +224,7 @@ pub fn d3d12_resource_transition_subresource(
unsafe { cmd.ResourceBarrier(&barrier) } unsafe { cmd.ResourceBarrier(&barrier) }
} }
pub fn d3d12_update_subresources( pub(crate) fn d3d12_update_subresources(
cmd: &ID3D12GraphicsCommandList, cmd: &ID3D12GraphicsCommandList,
destination_resource: &ID3D12Resource, destination_resource: &ID3D12Resource,
intermediate_resource: &ID3D12Resource, intermediate_resource: &ID3D12Resource,
@ -231,6 +232,7 @@ pub fn d3d12_update_subresources(
first_subresouce: u32, first_subresouce: u32,
num_subresources: u32, num_subresources: u32,
source: &[D3D12_SUBRESOURCE_DATA], source: &[D3D12_SUBRESOURCE_DATA],
gc: &mut FrameResiduals,
) -> error::Result<u64> { ) -> error::Result<u64> {
// let allocation_size = std::mem::size_of::<D3D12_PLACED_SUBRESOURCE_FOOTPRINT>() // let allocation_size = std::mem::size_of::<D3D12_PLACED_SUBRESOURCE_FOOTPRINT>()
// + std::mem::size_of::<u32>() // + std::mem::size_of::<u32>()
@ -271,6 +273,7 @@ pub fn d3d12_update_subresources(
&num_rows, &num_rows,
&row_sizes_in_bytes, &row_sizes_in_bytes,
source, source,
gc
) )
} }
} }
@ -287,6 +290,7 @@ fn update_subresources(
num_rows: &[u32], num_rows: &[u32],
row_sizes_in_bytes: &[u64], row_sizes_in_bytes: &[u64],
source_data: &[D3D12_SUBRESOURCE_DATA], source_data: &[D3D12_SUBRESOURCE_DATA],
gc: &mut FrameResiduals,
) -> error::Result<u64> { ) -> error::Result<u64> {
// ToDo: implement validation as in the original function // ToDo: implement validation as in the original function
@ -325,7 +329,7 @@ fn update_subresources(
} else { } else {
for i in 0..num_subresources as usize { for i in 0..num_subresources as usize {
let dest_location = D3D12_TEXTURE_COPY_LOCATION { let dest_location = D3D12_TEXTURE_COPY_LOCATION {
pResource: windows::core::ManuallyDrop::new(destination_resource), pResource: ManuallyDrop::new(Some(destination_resource.clone())),
Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
SubresourceIndex: i as u32 + first_subresouce, SubresourceIndex: i as u32 + first_subresouce,
@ -333,7 +337,7 @@ fn update_subresources(
}; };
let source_location = D3D12_TEXTURE_COPY_LOCATION { let source_location = D3D12_TEXTURE_COPY_LOCATION {
pResource: windows::core::ManuallyDrop::new(intermediate_resource), pResource: ManuallyDrop::new(Some(intermediate_resource.clone())),
Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT,
Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 {
PlacedFootprint: layouts[i], PlacedFootprint: layouts[i],
@ -341,6 +345,9 @@ fn update_subresources(
}; };
cmd.CopyTextureRegion(&dest_location, 0, 0, 0, &source_location, None); cmd.CopyTextureRegion(&dest_location, 0, 0, 0, &source_location, None);
gc.dispose_resource(dest_location.pResource);
gc.dispose_resource(source_location.pResource);
} }
} }
Ok(required_size) Ok(required_size)

View file

@ -4,7 +4,7 @@ use windows::{
core::*, Win32::Foundation::*, Win32::Graphics::Direct3D::Fxc::*, Win32::Graphics::Direct3D::*, core::*, Win32::Foundation::*, Win32::Graphics::Direct3D::Fxc::*, Win32::Graphics::Direct3D::*,
Win32::Graphics::Direct3D12::*, Win32::Graphics::Dxgi::Common::*, Win32::Graphics::Dxgi::*, Win32::Graphics::Direct3D12::*, Win32::Graphics::Dxgi::Common::*, Win32::Graphics::Dxgi::*,
Win32::System::LibraryLoader::*, Win32::System::Threading::*, Win32::System::LibraryLoader::*, Win32::System::Threading::*,
Win32::System::WindowsProgramming::*, Win32::UI::WindowsAndMessaging::*, Win32::UI::WindowsAndMessaging::*,
}; };
mod descriptor_heap; mod descriptor_heap;
@ -228,6 +228,7 @@ unsafe extern "system" fn debug_log(
} }
pub mod d3d12_hello_triangle { pub mod d3d12_hello_triangle {
use std::mem::ManuallyDrop;
use super::*; use super::*;
use crate::hello_triangle::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap}; use crate::hello_triangle::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap};
use librashader_common::{Size, Viewport}; use librashader_common::{Size, Viewport};
@ -511,7 +512,7 @@ pub mod d3d12_hello_triangle {
.unwrap(); .unwrap();
// Execute the command list. // Execute the command list.
let command_list = ID3D12CommandList::from(&resources.command_list); let command_list: Option<ID3D12CommandList> = resources.command_list.cast().ok();
unsafe { resources.command_queue.ExecuteCommandLists(&[command_list]) }; unsafe { resources.command_queue.ExecuteCommandLists(&[command_list]) };
// Present the frame. // Present the frame.
@ -570,7 +571,7 @@ pub mod d3d12_hello_triangle {
// Record commands. // Record commands.
unsafe { unsafe {
// TODO: workaround for https://github.com/microsoft/win32metadata/issues/1006 // TODO: workaround for https://github.com/microsoft/win32metadata/issues/1006
command_list.ClearRenderTargetView(rtv_handle, &*[0.3, 0.4, 0.6, 1.0].as_ptr(), &[]); command_list.ClearRenderTargetView(rtv_handle, &*[0.3, 0.4, 0.6, 1.0].as_ptr(), Some(&[]));
command_list.IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); command_list.IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
command_list.IASetVertexBuffers(0, Some(&[resources.vbv])); command_list.IASetVertexBuffers(0, Some(&[resources.vbv]));
command_list.DrawInstanced(3, 1, 0, 0); command_list.DrawInstanced(3, 1, 0, 0);
@ -654,8 +655,8 @@ pub mod d3d12_hello_triangle {
Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION,
Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE,
Anonymous: D3D12_RESOURCE_BARRIER_0 { Anonymous: D3D12_RESOURCE_BARRIER_0 {
Transition: std::mem::ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { Transition: ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER {
pResource: ManuallyDrop::new(resource), pResource: ManuallyDrop::new(Some(resource.clone())),
StateBefore: state_before, StateBefore: state_before,
StateAfter: state_after, StateAfter: state_after,
Subresource: D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, Subresource: D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
@ -768,7 +769,7 @@ pub mod d3d12_hello_triangle {
pInputElementDescs: input_element_descs.as_mut_ptr(), pInputElementDescs: input_element_descs.as_mut_ptr(),
NumElements: input_element_descs.len() as u32, NumElements: input_element_descs.len() as u32,
}, },
pRootSignature: ManuallyDrop::new(root_signature), pRootSignature: ManuallyDrop::new(Some(root_signature.clone())),
VS: D3D12_SHADER_BYTECODE { VS: D3D12_SHADER_BYTECODE {
pShaderBytecode: unsafe { vertex_shader.GetBufferPointer() }, pShaderBytecode: unsafe { vertex_shader.GetBufferPointer() },
BytecodeLength: unsafe { vertex_shader.GetBufferSize() }, BytecodeLength: unsafe { vertex_shader.GetBufferSize() },

View file

@ -5,13 +5,13 @@ use crate::hello_triangle::{DXSample, SampleCommandLine};
#[test] #[test]
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/slang-shaders/crt/crt-lottes.slangp", "../test/shaders_slang/crt/crt-lottes.slangp",
// "../test/basic.slangp", // "../test/basic.slangp",
// "../test/slang-shaders/handheld/console-border/gbc-lcd-grid-v2.slangp", // "../test/slang-shaders/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/slang-shaders/test/history.slangp", // "../test/slang-shaders/test/history.slangp",
// "../test/slang-shaders/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 {
use_warp_device: false, use_warp_device: false,

View file

@ -28,7 +28,7 @@ librashader-cache = { path = "../librashader-cache", version = "0.1.3" }
ash = { version = "0.37.1+1.3.235", optional = true } ash = { version = "0.37.1+1.3.235", optional = true }
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.44.0" version = "0.48.0"
optional = true optional = true
[features] [features]