fmt: cargo fmt
This commit is contained in:
parent
b09a5295ab
commit
f5da7d8421
|
@ -17,8 +17,8 @@ impl<T: ShaderCompilation + for<'de> serde::Deserialize<'de> + serde::Serialize
|
|||
|
||||
let Ok(cache) = cache else {
|
||||
return Ok(CachedCompilation {
|
||||
compilation: T::compile(source)?
|
||||
})
|
||||
compilation: T::compile(source)?,
|
||||
});
|
||||
};
|
||||
|
||||
let key = {
|
||||
|
|
|
@ -18,7 +18,9 @@ impl CacheKey for windows::Win32::Graphics::Direct3D::Dxc::IDxcBlob {
|
|||
|
||||
impl Cacheable for windows::Win32::Graphics::Direct3D::ID3DBlob {
|
||||
fn from_bytes(bytes: &[u8]) -> Option<Self> {
|
||||
let Some(blob) = (unsafe { windows::Win32::Graphics::Direct3D::Fxc::D3DCreateBlob(bytes.len()).ok() }) else {
|
||||
let Some(blob) =
|
||||
(unsafe { windows::Win32::Graphics::Direct3D::Fxc::D3DCreateBlob(bytes.len()).ok() })
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
|
||||
|
@ -44,11 +46,18 @@ impl Cacheable for windows::Win32::Graphics::Direct3D::Dxc::IDxcBlob {
|
|||
fn from_bytes(bytes: &[u8]) -> Option<Self> {
|
||||
let Some(blob) = (unsafe {
|
||||
windows::Win32::Graphics::Direct3D::Dxc::DxcCreateInstance(
|
||||
&windows::Win32::Graphics::Direct3D::Dxc::CLSID_DxcLibrary)
|
||||
.and_then(|library: windows::Win32::Graphics::Direct3D::Dxc::IDxcUtils| {
|
||||
library.CreateBlob(bytes.as_ptr().cast(), bytes.len() as u32,
|
||||
windows::Win32::Graphics::Direct3D::Dxc::DXC_CP(0))
|
||||
}).ok()
|
||||
&windows::Win32::Graphics::Direct3D::Dxc::CLSID_DxcLibrary,
|
||||
)
|
||||
.and_then(
|
||||
|library: windows::Win32::Graphics::Direct3D::Dxc::IDxcUtils| {
|
||||
library.CreateBlob(
|
||||
bytes.as_ptr().cast(),
|
||||
bytes.len() as u32,
|
||||
windows::Win32::Graphics::Direct3D::Dxc::DXC_CP(0),
|
||||
)
|
||||
},
|
||||
)
|
||||
.ok()
|
||||
}) else {
|
||||
return None;
|
||||
};
|
||||
|
|
|
@ -67,7 +67,7 @@ pub type PFN_libra_error_errno = extern "C" fn(error: libra_error_t) -> LIBRA_ER
|
|||
/// - `error` must be valid and initialized.
|
||||
pub unsafe extern "C" fn libra_error_errno(error: libra_error_t) -> LIBRA_ERRNO {
|
||||
let Some(error) = error else {
|
||||
return LIBRA_ERRNO::UNKNOWN_ERROR
|
||||
return LIBRA_ERRNO::UNKNOWN_ERROR;
|
||||
};
|
||||
|
||||
unsafe { error.as_ref().get_code() }
|
||||
|
@ -82,9 +82,7 @@ pub type PFN_libra_error_print = extern "C" fn(error: libra_error_t) -> i32;
|
|||
/// ## Safety
|
||||
/// - `error` must be a valid and initialized instance of `libra_error_t`.
|
||||
pub unsafe extern "C" fn libra_error_print(error: libra_error_t) -> i32 {
|
||||
let Some(error) = error else {
|
||||
return 1
|
||||
};
|
||||
let Some(error) = error else { return 1 };
|
||||
unsafe {
|
||||
let error = error.as_ref();
|
||||
println!("{error:?}: {error}");
|
||||
|
@ -130,9 +128,7 @@ pub unsafe extern "C" fn libra_error_write(
|
|||
error: libra_error_t,
|
||||
out: *mut MaybeUninit<*mut c_char>,
|
||||
) -> i32 {
|
||||
let Some(error) = error else {
|
||||
return 1
|
||||
};
|
||||
let Some(error) = error else { return 1 };
|
||||
if out.is_null() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -140,7 +136,7 @@ pub unsafe extern "C" fn libra_error_write(
|
|||
unsafe {
|
||||
let error = error.as_ref();
|
||||
let Ok(cstring) = CString::new(format!("{error:?}: {error}")) else {
|
||||
return 1
|
||||
return 1;
|
||||
};
|
||||
|
||||
out.write(MaybeUninit::new(cstring.into_raw()))
|
||||
|
|
|
@ -25,7 +25,7 @@ fn read_file(path: impl AsRef<Path>) -> Result<String, PreprocessError> {
|
|||
let buf = e.into_bytes();
|
||||
let decoder = WINDOWS_1252.new_decoder();
|
||||
let Some(len) = decoder.max_utf8_buffer_length_without_replacement(buf.len()) else {
|
||||
return Err(PreprocessError::EncodingError(path.to_path_buf()))
|
||||
return Err(PreprocessError::EncodingError(path.to_path_buf()));
|
||||
};
|
||||
|
||||
let mut latin1_string = String::with_capacity(len);
|
||||
|
|
|
@ -24,7 +24,7 @@ librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.4"
|
|||
librashader-presets = { path = "../librashader-presets", version = "0.1.4" }
|
||||
|
||||
spirv_cross = { package = "librashader-spirv-cross", version = "0.23", optional = true }
|
||||
spirv-to-dxil = { version = "0.3", optional = true }
|
||||
spirv-to-dxil = { version = "0.4", optional = true }
|
||||
naga = { version = "0.11.0", features = ["glsl-in", "spv-in", "spv-out", "glsl-out", "wgsl-out"], optional = true }
|
||||
|
||||
rspirv = { version = "0.11.0+1.5.4", optional = true }
|
||||
|
|
|
@ -54,10 +54,26 @@ pub(crate) type GlslReflect = CrossReflect<glsl::Target>;
|
|||
|
||||
impl ValidateTypeSemantics<Type> for UniqueSemantics {
|
||||
fn validate_type(&self, ty: &Type) -> Option<TypeInfo> {
|
||||
let (Type::Float { ref array, vecsize, columns, .. }
|
||||
| Type::Int { ref array, vecsize, columns, .. }
|
||||
| Type::UInt { ref array, vecsize, columns, .. }) = *ty else {
|
||||
return None
|
||||
let (Type::Float {
|
||||
ref array,
|
||||
vecsize,
|
||||
columns,
|
||||
..
|
||||
}
|
||||
| Type::Int {
|
||||
ref array,
|
||||
vecsize,
|
||||
columns,
|
||||
..
|
||||
}
|
||||
| Type::UInt {
|
||||
ref array,
|
||||
vecsize,
|
||||
columns,
|
||||
..
|
||||
}) = *ty
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
|
||||
if !array.is_empty() {
|
||||
|
@ -93,8 +109,14 @@ impl ValidateTypeSemantics<Type> for UniqueSemantics {
|
|||
|
||||
impl ValidateTypeSemantics<Type> for TextureSemantics {
|
||||
fn validate_type(&self, ty: &Type) -> Option<TypeInfo> {
|
||||
let Type::Float { ref array, vecsize, columns, .. } = *ty else {
|
||||
return None
|
||||
let Type::Float {
|
||||
ref array,
|
||||
vecsize,
|
||||
columns,
|
||||
..
|
||||
} = *ty
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
|
||||
if !array.is_empty() {
|
||||
|
@ -295,7 +317,7 @@ where
|
|||
|
||||
if let Some(parameter) = semantics.uniform_semantics.get_unique_semantic(&name) {
|
||||
let Some(typeinfo) = parameter.semantics.validate_type(&range_type) else {
|
||||
return Err(blame.error(SemanticsErrorKind::InvalidTypeForSemantic(name)))
|
||||
return Err(blame.error(SemanticsErrorKind::InvalidTypeForSemantic(name)));
|
||||
};
|
||||
|
||||
match ¶meter.semantics {
|
||||
|
@ -372,7 +394,7 @@ where
|
|||
}
|
||||
} else if let Some(texture) = semantics.uniform_semantics.get_texture_semantic(&name) {
|
||||
let Some(_typeinfo) = texture.semantics.validate_type(&range_type) else {
|
||||
return Err(blame.error(SemanticsErrorKind::InvalidTypeForSemantic(name)))
|
||||
return Err(blame.error(SemanticsErrorKind::InvalidTypeForSemantic(name)));
|
||||
};
|
||||
|
||||
if let TextureSemantics::PassOutput = texture.semantics {
|
||||
|
@ -488,8 +510,15 @@ where
|
|||
semantics: &ShaderSemantics,
|
||||
meta: &mut BindingMeta,
|
||||
) -> Result<(), ShaderReflectError> {
|
||||
let Some(semantic) = semantics.texture_semantics.get_texture_semantic(texture.name) else {
|
||||
return Err(SemanticErrorBlame::Fragment.error(SemanticsErrorKind::UnknownSemantics(texture.name.to_string())))
|
||||
let Some(semantic) = semantics
|
||||
.texture_semantics
|
||||
.get_texture_semantic(texture.name)
|
||||
else {
|
||||
return Err(
|
||||
SemanticErrorBlame::Fragment.error(SemanticsErrorKind::UnknownSemantics(
|
||||
texture.name.to_string(),
|
||||
)),
|
||||
);
|
||||
};
|
||||
|
||||
if semantic.semantics == TextureSemantics::PassOutput && semantic.index >= pass_number {
|
||||
|
|
|
@ -361,7 +361,9 @@ impl TextureSemanticMap for FxHashMap<String, Semantic<TextureSemantics>> {
|
|||
{
|
||||
if semantics.is_indexed() {
|
||||
let index = &name[semantics.texture_name().len()..];
|
||||
let Ok(index) = usize::from_str(index) else {return None};
|
||||
let Ok(index) = usize::from_str(index) else {
|
||||
return None;
|
||||
};
|
||||
return Some(Semantic {
|
||||
semantics: *semantics,
|
||||
index,
|
||||
|
|
|
@ -249,7 +249,8 @@ impl FilterChainD3D12 {
|
|||
let shader_copy = preset.shaders.clone();
|
||||
let disable_cache = options.map_or(false, |o| o.disable_cache);
|
||||
|
||||
let (passes, semantics) = compile_passes_dxil(preset.shaders, &preset.textures, disable_cache)?;
|
||||
let (passes, semantics) =
|
||||
compile_passes_dxil(preset.shaders, &preset.textures, disable_cache)?;
|
||||
let (hlsl_passes, _) = compile_passes_hlsl(shader_copy, &preset.textures, disable_cache)?;
|
||||
|
||||
let samplers = SamplerSet::new(device)?;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap};
|
||||
use crate::error;
|
||||
use crate::error::assume_d3d12_init;
|
||||
use crate::filter_chain::FrameResiduals;
|
||||
use crate::mipmap::MipmapGenContext;
|
||||
use crate::texture::InputTexture;
|
||||
use crate::util::{d3d12_get_closest_format, d3d12_resource_transition, d3d12_update_subresources};
|
||||
|
@ -22,7 +23,6 @@ use windows::Win32::Graphics::Direct3D12::{
|
|||
D3D12_TEX2D_SRV, D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
|
||||
};
|
||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
|
||||
use crate::filter_chain::FrameResiduals;
|
||||
|
||||
pub struct LutTexture {
|
||||
resource: ID3D12Resource,
|
||||
|
|
|
@ -10,6 +10,7 @@ use windows::Win32::Graphics::Direct3D::Dxc::{
|
|||
DXC_CP_UTF8,
|
||||
};
|
||||
|
||||
use crate::filter_chain::FrameResiduals;
|
||||
use windows::Win32::Graphics::Direct3D12::{
|
||||
ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_FEATURE_DATA_FORMAT_SUPPORT,
|
||||
D3D12_FEATURE_FORMAT_SUPPORT, D3D12_MEMCPY_DEST, D3D12_PLACED_SUBRESOURCE_FOOTPRINT,
|
||||
|
@ -20,7 +21,6 @@ use windows::Win32::Graphics::Direct3D12::{
|
|||
D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
|
||||
};
|
||||
use windows::Win32::Graphics::Dxgi::Common::*;
|
||||
use crate::filter_chain::FrameResiduals;
|
||||
|
||||
/// wtf retroarch?
|
||||
const DXGI_FORMAT_EX_A4R4G4B4_UNORM: DXGI_FORMAT = DXGI_FORMAT(1000);
|
||||
|
@ -273,7 +273,7 @@ pub(crate) fn d3d12_update_subresources(
|
|||
&num_rows,
|
||||
&row_sizes_in_bytes,
|
||||
source,
|
||||
gc
|
||||
gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,11 +228,11 @@ unsafe extern "system" fn debug_log(
|
|||
}
|
||||
|
||||
pub mod d3d12_hello_triangle {
|
||||
use std::mem::ManuallyDrop;
|
||||
use super::*;
|
||||
use crate::hello_triangle::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap};
|
||||
use librashader_common::{Size, Viewport};
|
||||
use librashader_runtime_d3d12::{D3D12InputImage, D3D12OutputView, FilterChainD3D12};
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::ops::Deref;
|
||||
use std::path::Path;
|
||||
|
||||
|
@ -571,7 +571,11 @@ pub mod d3d12_hello_triangle {
|
|||
// Record commands.
|
||||
unsafe {
|
||||
// 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(), Some(&[]));
|
||||
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.IASetVertexBuffers(0, Some(&[resources.vbv]));
|
||||
command_list.DrawInstanced(3, 1, 0, 0);
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
//! See [`librashader::runtime::gl`](https://docs.rs/librashader/latest/librashader/runtime/gl/index.html) instead.
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
#![feature(strict_provenance)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_assoc_type)]
|
||||
|
||||
mod binding;
|
||||
mod filter_chain;
|
||||
|
|
|
@ -100,10 +100,10 @@ impl VulkanBuffer {
|
|||
|
||||
pub fn as_mut_slice(&mut self) -> error::Result<&mut [u8]> {
|
||||
let Some(allocation) = self.memory.as_mut() else {
|
||||
return Err(FilterChainError::AllocationDoesNotExist)
|
||||
return Err(FilterChainError::AllocationDoesNotExist);
|
||||
};
|
||||
let Some(allocation) = allocation.mapped_slice_mut() else {
|
||||
return Err(FilterChainError::AllocationDoesNotExist)
|
||||
return Err(FilterChainError::AllocationDoesNotExist);
|
||||
};
|
||||
Ok(allocation)
|
||||
}
|
||||
|
@ -147,11 +147,8 @@ impl RawVulkanBuffer {
|
|||
) -> error::Result<Self> {
|
||||
let buffer = ManuallyDrop::new(VulkanBuffer::new(device, allocator, usage, size)?);
|
||||
|
||||
let Some(ptr) = buffer.memory
|
||||
.as_ref()
|
||||
.map(|m| m.mapped_ptr())
|
||||
.flatten() else {
|
||||
return Err(FilterChainError::AllocationDoesNotExist)
|
||||
let Some(ptr) = buffer.memory.as_ref().map(|m| m.mapped_ptr()).flatten() else {
|
||||
return Err(FilterChainError::AllocationDoesNotExist);
|
||||
};
|
||||
|
||||
Ok(RawVulkanBuffer { buffer, ptr })
|
||||
|
|
Loading…
Reference in a new issue