fmt: run clippy
This commit is contained in:
parent
0506733dad
commit
b81b2b1d25
|
@ -38,15 +38,14 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut shaders = Vec::new();
|
let mut shaders = Vec::new();
|
||||||
let shader_count = remove_if(&mut values, |v| matches!(*v, Value::ShaderCount(_)))
|
let shader_count =
|
||||||
.map(|value| {
|
remove_if(&mut values, |v| matches!(*v, Value::ShaderCount(_))).map_or(0, |value| {
|
||||||
if let Value::ShaderCount(count) = value {
|
if let Value::ShaderCount(count) = value {
|
||||||
count
|
count
|
||||||
} else {
|
} else {
|
||||||
unreachable!("value should be of type shader_count")
|
unreachable!("value should be of type shader_count")
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.unwrap_or(0);
|
|
||||||
|
|
||||||
#[cfg(feature = "parse_legacy_glsl")]
|
#[cfg(feature = "parse_legacy_glsl")]
|
||||||
let feedback_pass = remove_if(&mut values, |v| matches!(*v, Value::FeedbackPass(_)))
|
let feedback_pass = remove_if(&mut values, |v| matches!(*v, Value::FeedbackPass(_)))
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl CompileShader<DXIL> for WriteSpirV {
|
||||||
ValidatorVersion::None,
|
ValidatorVersion::None,
|
||||||
config.clone(),
|
config.clone(),
|
||||||
)
|
)
|
||||||
.map_err(|s| ShaderCompileError::SpirvToDxilCompileError(s))?;
|
.map_err(ShaderCompileError::SpirvToDxilCompileError)?;
|
||||||
|
|
||||||
let fragment = spirv_to_dxil::spirv_to_dxil(
|
let fragment = spirv_to_dxil::spirv_to_dxil(
|
||||||
&self.fragment,
|
&self.fragment,
|
||||||
|
@ -81,7 +81,7 @@ impl CompileShader<DXIL> for WriteSpirV {
|
||||||
ValidatorVersion::None,
|
ValidatorVersion::None,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
.map_err(|s| ShaderCompileError::SpirvToDxilCompileError(s))?;
|
.map_err(ShaderCompileError::SpirvToDxilCompileError)?;
|
||||||
|
|
||||||
Ok(ShaderCompilerOutput {
|
Ok(ShaderCompilerOutput {
|
||||||
vertex,
|
vertex,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
||||||
use crate::front::GlslangCompilation;
|
use crate::front::GlslangCompilation;
|
||||||
use crate::front::NagaCompilation;
|
use crate::front::NagaCompilation;
|
||||||
use crate::reflect::helper::SemanticErrorBlame;
|
|
||||||
use crate::reflect::semantics::MAX_BINDINGS_COUNT;
|
|
||||||
use naga::front::spv::Options;
|
use naga::front::spv::Options;
|
||||||
use naga::{Arena, GlobalVariable, Handle, Module, ResourceBinding, StructMember, Type, TypeInner};
|
use naga::{GlobalVariable, Module, StructMember, Type, TypeInner};
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -94,7 +93,7 @@ impl NagaReflect {
|
||||||
u32::MAX,
|
u32::MAX,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
(Some(vert), Some(frag)) => {
|
(Some(_vert), Some(_frag)) => {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -115,7 +114,7 @@ mod test {
|
||||||
let compilation = crate::front::GlslangCompilation::try_from(&result).unwrap();
|
let compilation = crate::front::GlslangCompilation::try_from(&result).unwrap();
|
||||||
|
|
||||||
let mut loader = rspirv::dr::Loader::new();
|
let mut loader = rspirv::dr::Loader::new();
|
||||||
rspirv::binary::parse_words(&compilation.vertex.as_binary(), &mut loader).unwrap();
|
rspirv::binary::parse_words(compilation.vertex.as_binary(), &mut loader).unwrap();
|
||||||
let module = loader.module();
|
let module = loader.module();
|
||||||
|
|
||||||
let outputs: Vec<&Instruction> = module
|
let outputs: Vec<&Instruction> = module
|
||||||
|
@ -124,6 +123,6 @@ mod test {
|
||||||
.filter(|i| i.class.opcode == Op::Variable)
|
.filter(|i| i.class.opcode == Op::Variable)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
println!("{:#?}", outputs);
|
println!("{outputs:#?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,7 @@ use librashader_presets::{ShaderPreset, TextureConfig};
|
||||||
use librashader_reflect::back::targets::HLSL;
|
use librashader_reflect::back::targets::HLSL;
|
||||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||||
use librashader_reflect::front::GlslangCompilation;
|
use librashader_reflect::front::GlslangCompilation;
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{BindingMeta, ShaderSemantics};
|
||||||
BindingMeta, ShaderSemantics, TextureSemantics, UniformBinding,
|
|
||||||
};
|
|
||||||
use librashader_reflect::reflect::ReflectShader;
|
use librashader_reflect::reflect::ReflectShader;
|
||||||
use librashader_runtime::image::{Image, UVDirection};
|
use librashader_runtime::image::{Image, UVDirection};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
@ -93,7 +91,7 @@ impl FilterChainD3D11 {
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(preset.shaders, &preset.textures)?;
|
>(preset.shaders, &preset.textures)?;
|
||||||
|
|
||||||
let use_deferred_context = options.map(|f| f.use_deferred_context).unwrap_or(false);
|
let use_deferred_context = options.map_or(false, |f| f.use_deferred_context);
|
||||||
|
|
||||||
let samplers = SamplerSet::new(device)?;
|
let samplers = SamplerSet::new(device)?;
|
||||||
|
|
||||||
|
@ -274,16 +272,11 @@ impl FilterChainD3D11 {
|
||||||
};
|
};
|
||||||
|
|
||||||
let uniform_storage = UniformStorage::new(
|
let uniform_storage = UniformStorage::new(
|
||||||
reflection
|
reflection.ubo.as_ref().map_or(0, |ubo| ubo.size as usize),
|
||||||
.ubo
|
|
||||||
.as_ref()
|
|
||||||
.map(|ubo| ubo.size as usize)
|
|
||||||
.unwrap_or(0),
|
|
||||||
reflection
|
reflection
|
||||||
.push_constant
|
.push_constant
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|push| push.size as usize)
|
.map_or(0, |push| push.size as usize),
|
||||||
.unwrap_or(0),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
||||||
|
@ -310,7 +303,7 @@ impl FilterChainD3D11 {
|
||||||
context: &ID3D11DeviceContext,
|
context: &ID3D11DeviceContext,
|
||||||
filters: &Vec<FilterPass>,
|
filters: &Vec<FilterPass>,
|
||||||
) -> error::Result<(VecDeque<OwnedFramebuffer>, Box<[Option<InputTexture>]>)> {
|
) -> error::Result<(VecDeque<OwnedFramebuffer>, Box<[Option<InputTexture>]>)> {
|
||||||
let mut required_images =
|
let required_images =
|
||||||
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
||||||
|
|
||||||
// not using frame history;
|
// not using frame history;
|
||||||
|
@ -409,7 +402,7 @@ impl FilterChainD3D11 {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame_direction = options.map(|f| f.frame_direction).unwrap_or(1);
|
let frame_direction = options.map_or(1, |f| f.frame_direction);
|
||||||
let filter = passes[0].config.filter;
|
let filter = passes[0].config.filter;
|
||||||
let wrap_mode = passes[0].config.wrap_mode;
|
let wrap_mode = passes[0].config.wrap_mode;
|
||||||
|
|
||||||
|
@ -450,8 +443,7 @@ impl FilterChainD3D11 {
|
||||||
while let Some((index, pass)) = iterator.next() {
|
while let Some((index, pass)) = iterator.next() {
|
||||||
let should_mipmap = iterator
|
let should_mipmap = iterator
|
||||||
.peek()
|
.peek()
|
||||||
.map(|(_, p)| p.config.mipmap_input)
|
.map_or(false, |(_, p)| p.config.mipmap_input);
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
let next_size = self.output_framebuffers[index].scale(
|
let next_size = self.output_framebuffers[index].scale(
|
||||||
pass.config.scaling.clone(),
|
pass.config.scaling.clone(),
|
||||||
|
|
|
@ -78,17 +78,15 @@ impl D3D12Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map(&mut self, range: Option<Range<usize>>) -> error::Result<D3D12BufferMapHandle> {
|
pub fn map(&mut self, range: Option<Range<usize>>) -> error::Result<D3D12BufferMapHandle> {
|
||||||
let (range, size) = range
|
let (range, size) = range.map_or((D3D12_RANGE { Begin: 0, End: 0 }, self.size), |range| {
|
||||||
.map(|range| {
|
(
|
||||||
(
|
D3D12_RANGE {
|
||||||
D3D12_RANGE {
|
Begin: range.start,
|
||||||
Begin: range.start,
|
End: range.end,
|
||||||
End: range.end,
|
},
|
||||||
},
|
range.end - range.start,
|
||||||
range.end - range.start,
|
)
|
||||||
)
|
});
|
||||||
})
|
|
||||||
.unwrap_or((D3D12_RANGE { Begin: 0, End: 0 }, self.size));
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut ptr = std::ptr::null_mut();
|
let mut ptr = std::ptr::null_mut();
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::cell::RefCell;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
|
||||||
use windows::Win32::Graphics::Direct3D12::{
|
use windows::Win32::Graphics::Direct3D12::{
|
||||||
ID3D12DescriptorHeap, ID3D12Device, D3D12_CPU_DESCRIPTOR_HANDLE, D3D12_DESCRIPTOR_HEAP_DESC,
|
ID3D12DescriptorHeap, ID3D12Device, D3D12_CPU_DESCRIPTOR_HANDLE, D3D12_DESCRIPTOR_HEAP_DESC,
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAG_NONE, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE,
|
D3D12_DESCRIPTOR_HEAP_FLAG_NONE, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::buffer::{D3D12Buffer, D3D12ConstantBuffer};
|
use crate::buffer::{D3D12Buffer, D3D12ConstantBuffer};
|
||||||
use crate::descriptor_heap::{
|
use crate::descriptor_heap::{
|
||||||
CpuStagingHeap, D3D12DescriptorHeap, RenderTargetHeap, ResourceWorkHeap, SamplerWorkHeap,
|
CpuStagingHeap, D3D12DescriptorHeap, RenderTargetHeap, ResourceWorkHeap,
|
||||||
};
|
};
|
||||||
use crate::filter_pass::FilterPass;
|
use crate::filter_pass::FilterPass;
|
||||||
use crate::framebuffer::OwnedImage;
|
use crate::framebuffer::OwnedImage;
|
||||||
|
@ -12,20 +12,19 @@ use crate::quad_render::DrawQuad;
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::{InputTexture, OutputDescriptor, OutputTexture};
|
use crate::texture::{InputTexture, OutputDescriptor, OutputTexture};
|
||||||
use crate::{error, graphics_pipeline, util};
|
use crate::{error, util};
|
||||||
use librashader_common::{ImageFormat, Size, Viewport};
|
use librashader_common::{ImageFormat, Size, Viewport};
|
||||||
use librashader_presets::{ShaderPreset, TextureConfig};
|
use librashader_presets::{ShaderPreset, TextureConfig};
|
||||||
use librashader_reflect::back::targets::{DXIL, HLSL};
|
use librashader_reflect::back::targets::{DXIL, HLSL};
|
||||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||||
use librashader_reflect::front::GlslangCompilation;
|
use librashader_reflect::front::GlslangCompilation;
|
||||||
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{BindingMeta, ShaderSemantics, MAX_BINDINGS_COUNT};
|
||||||
BindingMeta, ShaderSemantics, TextureSemantics, UniformBinding, MAX_BINDINGS_COUNT,
|
|
||||||
};
|
|
||||||
use librashader_reflect::reflect::ReflectShader;
|
use librashader_reflect::reflect::ReflectShader;
|
||||||
use librashader_runtime::binding::{BindingUtil, TextureInput};
|
use librashader_runtime::binding::{BindingUtil, TextureInput};
|
||||||
use librashader_runtime::image::{Image, UVDirection};
|
use librashader_runtime::image::{Image, UVDirection};
|
||||||
use librashader_runtime::quad::{QuadType, DEFAULT_MVP, IDENTITY_MVP};
|
use librashader_runtime::quad::{QuadType, DEFAULT_MVP};
|
||||||
|
use librashader_runtime::scaling::MipmapSize;
|
||||||
use librashader_runtime::uniforms::UniformStorage;
|
use librashader_runtime::uniforms::UniformStorage;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use spirv_cross::hlsl::ShaderModel;
|
use spirv_cross::hlsl::ShaderModel;
|
||||||
|
@ -37,19 +36,17 @@ use windows::w;
|
||||||
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,
|
||||||
IDxcLibrary, IDxcUtils, IDxcValidator,
|
IDxcUtils, IDxcValidator,
|
||||||
};
|
};
|
||||||
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, D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_DESC,
|
||||||
D3D12_COMMAND_QUEUE_FLAG_NONE, D3D12_FENCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_COMMAND_QUEUE_FLAG_NONE, D3D12_FENCE_FLAG_NONE,
|
||||||
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||||
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, ResetEvent, WaitForSingleObject};
|
use windows::Win32::System::Threading::{CreateEventA, ResetEvent, WaitForSingleObject};
|
||||||
use windows::Win32::System::WindowsProgramming::INFINITE;
|
use windows::Win32::System::WindowsProgramming::INFINITE;
|
||||||
use librashader_runtime::scaling::MipmapSize;
|
|
||||||
|
|
||||||
type DxilShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<DXIL, GlslangCompilation>>;
|
type DxilShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<DXIL, GlslangCompilation>>;
|
||||||
type HlslShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation>>;
|
type HlslShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation>>;
|
||||||
|
@ -135,7 +132,7 @@ impl FilterChainD3D12 {
|
||||||
device,
|
device,
|
||||||
(MAX_BINDINGS_COUNT as usize) * shader_count + 2048 + lut_count,
|
(MAX_BINDINGS_COUNT as usize) * shader_count + 2048 + lut_count,
|
||||||
)?;
|
)?;
|
||||||
let mut rtv_heap = D3D12DescriptorHeap::new(
|
let rtv_heap = D3D12DescriptorHeap::new(
|
||||||
device,
|
device,
|
||||||
(MAX_BINDINGS_COUNT as usize) * shader_count + 2048 + lut_count,
|
(MAX_BINDINGS_COUNT as usize) * shader_count + 2048 + lut_count,
|
||||||
)?;
|
)?;
|
||||||
|
@ -188,7 +185,7 @@ impl FilterChainD3D12 {
|
||||||
let (history_framebuffers, history_textures) =
|
let (history_framebuffers, history_textures) =
|
||||||
FilterChainD3D12::init_history(device, &filters)?;
|
FilterChainD3D12::init_history(device, &filters)?;
|
||||||
|
|
||||||
let mut mipmap_heap: D3D12DescriptorHeap<ResourceWorkHeap> =
|
let mipmap_heap: D3D12DescriptorHeap<ResourceWorkHeap> =
|
||||||
D3D12DescriptorHeap::new(device, u16::MAX as usize)?;
|
D3D12DescriptorHeap::new(device, u16::MAX as usize)?;
|
||||||
Ok(FilterChainD3D12 {
|
Ok(FilterChainD3D12 {
|
||||||
common: FilterCommon {
|
common: FilterCommon {
|
||||||
|
@ -228,7 +225,7 @@ impl FilterChainD3D12 {
|
||||||
device: &ID3D12Device,
|
device: &ID3D12Device,
|
||||||
filters: &Vec<FilterPass>,
|
filters: &Vec<FilterPass>,
|
||||||
) -> error::Result<(VecDeque<OwnedImage>, Box<[Option<InputTexture>]>)> {
|
) -> error::Result<(VecDeque<OwnedImage>, Box<[Option<InputTexture>]>)> {
|
||||||
let mut required_images =
|
let required_images =
|
||||||
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
||||||
|
|
||||||
// not using frame history;
|
// not using frame history;
|
||||||
|
@ -401,7 +398,7 @@ impl FilterChainD3D12 {
|
||||||
}
|
}
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
eprintln!("building pipeline for pass {:?}", index);
|
eprintln!("building pipeline for pass {index:?}");
|
||||||
|
|
||||||
/// incredibly cursed.
|
/// incredibly cursed.
|
||||||
let (reflection, graphics_pipeline) = if !force_hlsl &&
|
let (reflection, graphics_pipeline) = if !force_hlsl &&
|
||||||
|
@ -416,7 +413,7 @@ impl FilterChainD3D12 {
|
||||||
) {
|
) {
|
||||||
(dxil_reflection, graphics_pipeline)
|
(dxil_reflection, graphics_pipeline)
|
||||||
} else {
|
} else {
|
||||||
eprintln!("falling back to hlsl for {:?}", index);
|
eprintln!("falling back to hlsl for {index:?}");
|
||||||
let graphics_pipeline = D3D12GraphicsPipeline::new_from_hlsl(
|
let graphics_pipeline = D3D12GraphicsPipeline::new_from_hlsl(
|
||||||
device,
|
device,
|
||||||
&library,
|
&library,
|
||||||
|
@ -429,16 +426,11 @@ impl FilterChainD3D12 {
|
||||||
};
|
};
|
||||||
|
|
||||||
let uniform_storage = UniformStorage::new(
|
let uniform_storage = UniformStorage::new(
|
||||||
reflection
|
reflection.ubo.as_ref().map_or(0, |ubo| ubo.size as usize),
|
||||||
.ubo
|
|
||||||
.as_ref()
|
|
||||||
.map(|ubo| ubo.size as usize)
|
|
||||||
.unwrap_or(0),
|
|
||||||
reflection
|
reflection
|
||||||
.push_constant
|
.push_constant
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|push| push.size as usize)
|
.map_or(0, |push| push.size as usize),
|
||||||
.unwrap_or(0),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let ubo_cbuffer = if let Some(ubo) = &reflection.ubo && ubo.size != 0 {
|
let ubo_cbuffer = if let Some(ubo) = &reflection.ubo && ubo.size != 0 {
|
||||||
|
@ -505,10 +497,10 @@ impl FilterChainD3D12 {
|
||||||
pub fn frame(
|
pub fn frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
cmd: &ID3D12GraphicsCommandList,
|
cmd: &ID3D12GraphicsCommandList,
|
||||||
mut input: InputTexture,
|
input: InputTexture,
|
||||||
viewport: &Viewport<OutputTexture>,
|
viewport: &Viewport<OutputTexture>,
|
||||||
frame_count: usize,
|
frame_count: usize,
|
||||||
options: Option<&()>,
|
_options: Option<&()>,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
drop(self.residuals.drain(..));
|
drop(self.residuals.drain(..));
|
||||||
|
|
||||||
|
@ -560,8 +552,7 @@ impl FilterChainD3D12 {
|
||||||
while let Some((index, pass)) = iterator.next() {
|
while let Some((index, pass)) = iterator.next() {
|
||||||
let should_mipmap = iterator
|
let should_mipmap = iterator
|
||||||
.peek()
|
.peek()
|
||||||
.map(|(_, p)| p.config.mipmap_input)
|
.map_or(false, |(_, p)| p.config.mipmap_input);
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
let next_size = self.output_framebuffers[index].scale(
|
let next_size = self.output_framebuffers[index].scale(
|
||||||
pass.config.scaling.clone(),
|
pass.config.scaling.clone(),
|
||||||
|
@ -612,18 +603,25 @@ impl FilterChainD3D12 {
|
||||||
if pass.config.mipmap_input && !self.disable_mipmaps {
|
if pass.config.mipmap_input && !self.disable_mipmaps {
|
||||||
unsafe {
|
unsafe {
|
||||||
// this is so bad.
|
// this is so bad.
|
||||||
self.common.mipmap_gen.mipmapping_context(cmd, &mut self.mipmap_heap, |ctx| {
|
self.common.mipmap_gen.mipmapping_context(
|
||||||
ctx.generate_mipmaps(&source.resource,
|
cmd,
|
||||||
source.size().calculate_miplevels() as u16, source.size,
|
&mut self.mipmap_heap,
|
||||||
source.format.into())?;
|
|ctx| {
|
||||||
Ok::<(), Box<dyn Error>>(())
|
ctx.generate_mipmaps(
|
||||||
})?;
|
&source.resource,
|
||||||
|
source.size().calculate_miplevels() as u16,
|
||||||
|
source.size,
|
||||||
|
source.format,
|
||||||
|
)?;
|
||||||
|
Ok::<(), Box<dyn Error>>(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = &self.output_framebuffers[index];
|
let target = &self.output_framebuffers[index];
|
||||||
util::d3d12_resource_transition(
|
util::d3d12_resource_transition(
|
||||||
&cmd,
|
cmd,
|
||||||
&target.handle,
|
&target.handle,
|
||||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
||||||
D3D12_RESOURCE_STATE_RENDER_TARGET,
|
D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||||
|
@ -659,7 +657,7 @@ impl FilterChainD3D12 {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
util::d3d12_resource_transition(
|
util::d3d12_resource_transition(
|
||||||
&cmd,
|
cmd,
|
||||||
&target.handle,
|
&target.handle,
|
||||||
D3D12_RESOURCE_STATE_RENDER_TARGET,
|
D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
||||||
|
@ -705,7 +703,7 @@ impl FilterChainD3D12 {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.push_history(&cmd, &original)?;
|
self.push_history(cmd, &original)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use crate::buffer::D3D12ConstantBuffer;
|
use crate::buffer::D3D12ConstantBuffer;
|
||||||
use crate::descriptor_heap::{
|
use crate::descriptor_heap::{D3D12DescriptorHeapSlot, ResourceWorkHeap, SamplerWorkHeap};
|
||||||
D3D12DescriptorHeap, D3D12DescriptorHeapSlot, ResourceWorkHeap, SamplerWorkHeap,
|
use crate::error;
|
||||||
};
|
|
||||||
use crate::filter_chain::FilterCommon;
|
use crate::filter_chain::FilterCommon;
|
||||||
use crate::graphics_pipeline::D3D12GraphicsPipeline;
|
use crate::graphics_pipeline::D3D12GraphicsPipeline;
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::{InputTexture, OutputTexture};
|
use crate::texture::{InputTexture, OutputTexture};
|
||||||
use crate::{error, util};
|
|
||||||
use librashader_common::{ImageFormat, Size, Viewport};
|
use librashader_common::{ImageFormat, Size, Viewport};
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
use librashader_presets::ShaderPassConfig;
|
||||||
|
@ -21,10 +19,10 @@ use std::ops::Deref;
|
||||||
use windows::core::Interface;
|
use windows::core::Interface;
|
||||||
use windows::Win32::Foundation::RECT;
|
use windows::Win32::Foundation::RECT;
|
||||||
use windows::Win32::Graphics::Direct3D12::{
|
use windows::Win32::Graphics::Direct3D12::{
|
||||||
ID3D12CommandList, ID3D12Device, ID3D12GraphicsCommandList, ID3D12GraphicsCommandList4,
|
ID3D12GraphicsCommandList, ID3D12GraphicsCommandList4, D3D12_RENDER_PASS_BEGINNING_ACCESS,
|
||||||
D3D12_RENDER_PASS_BEGINNING_ACCESS, D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD,
|
D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD, D3D12_RENDER_PASS_ENDING_ACCESS,
|
||||||
D3D12_RENDER_PASS_ENDING_ACCESS, D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE,
|
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE, D3D12_RENDER_PASS_FLAG_NONE,
|
||||||
D3D12_RENDER_PASS_FLAG_NONE, D3D12_RENDER_PASS_RENDER_TARGET_DESC, D3D12_VIEWPORT,
|
D3D12_RENDER_PASS_RENDER_TARGET_DESC, D3D12_VIEWPORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) struct FilterPass {
|
pub(crate) struct FilterPass {
|
||||||
|
|
|
@ -12,16 +12,15 @@ use windows::Win32::Graphics::Direct3D12::{
|
||||||
D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
|
D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
|
||||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT, D3D12_FORMAT_SUPPORT1_MIP,
|
D3D12_FEATURE_DATA_FORMAT_SUPPORT, D3D12_FORMAT_SUPPORT1_MIP,
|
||||||
D3D12_FORMAT_SUPPORT1_RENDER_TARGET, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE,
|
D3D12_FORMAT_SUPPORT1_RENDER_TARGET, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE,
|
||||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D, D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE, D3D12_HEAP_FLAG_NONE,
|
D3D12_FORMAT_SUPPORT1_TEXTURE2D, D3D12_HEAP_FLAG_NONE, D3D12_HEAP_PROPERTIES,
|
||||||
D3D12_HEAP_PROPERTIES, D3D12_HEAP_TYPE_DEFAULT, D3D12_MEMORY_POOL_UNKNOWN,
|
D3D12_HEAP_TYPE_DEFAULT, D3D12_MEMORY_POOL_UNKNOWN, D3D12_RENDER_TARGET_VIEW_DESC,
|
||||||
D3D12_RENDER_TARGET_VIEW_DESC, D3D12_RENDER_TARGET_VIEW_DESC_0, D3D12_RESOURCE_DESC,
|
D3D12_RENDER_TARGET_VIEW_DESC_0, D3D12_RESOURCE_DESC, D3D12_RESOURCE_DIMENSION_TEXTURE2D,
|
||||||
D3D12_RESOURCE_DIMENSION_TEXTURE2D, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET,
|
D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS,
|
||||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE,
|
||||||
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RTV_DIMENSION_TEXTURE2D,
|
||||||
D3D12_RTV_DIMENSION_TEXTURE2D, D3D12_SHADER_RESOURCE_VIEW_DESC,
|
D3D12_SHADER_RESOURCE_VIEW_DESC, D3D12_SHADER_RESOURCE_VIEW_DESC_0,
|
||||||
D3D12_SHADER_RESOURCE_VIEW_DESC_0, D3D12_SRV_DIMENSION_TEXTURE2D, D3D12_TEX2D_RTV,
|
D3D12_SRV_DIMENSION_TEXTURE2D, D3D12_TEX2D_RTV, D3D12_TEX2D_SRV, D3D12_TEXTURE_COPY_LOCATION,
|
||||||
D3D12_TEX2D_SRV, D3D12_TEXTURE_COPY_LOCATION, D3D12_TEXTURE_COPY_LOCATION_0,
|
D3D12_TEXTURE_COPY_LOCATION_0, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
|
||||||
D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
|
|
||||||
};
|
};
|
||||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
|
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,7 @@ use librashader_reflect::back::dxil::DxilObject;
|
||||||
use librashader_reflect::back::ShaderCompilerOutput;
|
use librashader_reflect::back::ShaderCompilerOutput;
|
||||||
use librashader_reflect::reflect::semantics::BindingStage;
|
use librashader_reflect::reflect::semantics::BindingStage;
|
||||||
use windows::Win32::Foundation::BOOL;
|
use windows::Win32::Foundation::BOOL;
|
||||||
use windows::Win32::Graphics::Direct3D::Dxc::{
|
use windows::Win32::Graphics::Direct3D::Dxc::{IDxcBlob, IDxcCompiler, IDxcUtils, IDxcValidator};
|
||||||
IDxcBlob, IDxcCompiler, IDxcLibrary, IDxcUtils, IDxcValidator,
|
|
||||||
};
|
|
||||||
use windows::Win32::Graphics::Direct3D12::{
|
use windows::Win32::Graphics::Direct3D12::{
|
||||||
D3D12SerializeRootSignature, ID3D12Device, ID3D12PipelineState, ID3D12RootSignature,
|
D3D12SerializeRootSignature, ID3D12Device, ID3D12PipelineState, ID3D12RootSignature,
|
||||||
D3D12_BLEND_DESC, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, D3D12_BLEND_SRC_ALPHA,
|
D3D12_BLEND_DESC, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, D3D12_BLEND_SRC_ALPHA,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use crate::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap, D3D12DescriptorHeapSlot};
|
use crate::descriptor_heap::{CpuStagingHeap, D3D12DescriptorHeap};
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::error::assume_d3d12_init;
|
use crate::error::assume_d3d12_init;
|
||||||
use crate::mipmap::MipmapGenContext;
|
use crate::mipmap::MipmapGenContext;
|
||||||
use crate::texture::InputTexture;
|
use crate::texture::InputTexture;
|
||||||
use crate::util::{d3d12_get_closest_format, d3d12_resource_transition, d3d12_update_subresources};
|
use crate::util::{d3d12_get_closest_format, d3d12_resource_transition, d3d12_update_subresources};
|
||||||
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
use librashader_common::{FilterMode, ImageFormat, WrapMode};
|
||||||
use librashader_runtime::image::Image;
|
use librashader_runtime::image::Image;
|
||||||
use librashader_runtime::scaling::MipmapSize;
|
use librashader_runtime::scaling::MipmapSize;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
@ -12,15 +12,14 @@ use windows::Win32::Graphics::Direct3D12::{
|
||||||
ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
||||||
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, D3D12_FEATURE_DATA_FORMAT_SUPPORT,
|
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, D3D12_FEATURE_DATA_FORMAT_SUPPORT,
|
||||||
D3D12_FORMAT_SUPPORT1_MIP, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE,
|
D3D12_FORMAT_SUPPORT1_MIP, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE,
|
||||||
D3D12_FORMAT_SUPPORT1_TEXTURE2D, D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE, D3D12_HEAP_FLAG_NONE,
|
D3D12_FORMAT_SUPPORT1_TEXTURE2D, D3D12_HEAP_FLAG_NONE, D3D12_HEAP_PROPERTIES,
|
||||||
D3D12_HEAP_PROPERTIES, D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD,
|
D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD, D3D12_MEMORY_POOL_UNKNOWN,
|
||||||
D3D12_MEMORY_POOL_UNKNOWN, D3D12_PLACED_SUBRESOURCE_FOOTPRINT, D3D12_RESOURCE_DESC,
|
D3D12_PLACED_SUBRESOURCE_FOOTPRINT, D3D12_RESOURCE_DESC, D3D12_RESOURCE_DIMENSION_BUFFER,
|
||||||
D3D12_RESOURCE_DIMENSION_BUFFER, D3D12_RESOURCE_DIMENSION_TEXTURE2D,
|
D3D12_RESOURCE_DIMENSION_TEXTURE2D, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS,
|
||||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||||
D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_SHADER_RESOURCE_VIEW_DESC,
|
||||||
D3D12_SHADER_RESOURCE_VIEW_DESC, D3D12_SHADER_RESOURCE_VIEW_DESC_0,
|
D3D12_SHADER_RESOURCE_VIEW_DESC_0, D3D12_SRV_DIMENSION_TEXTURE2D, D3D12_SUBRESOURCE_DATA,
|
||||||
D3D12_SRV_DIMENSION_TEXTURE2D, D3D12_SUBRESOURCE_DATA, D3D12_TEX2D_SRV,
|
D3D12_TEX2D_SRV, D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
|
||||||
D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
|
|
||||||
};
|
};
|
||||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
|
use windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::error::assume_d3d12_init;
|
use crate::error::assume_d3d12_init;
|
||||||
use librashader_reflect::reflect::semantics::BindingStage;
|
use librashader_reflect::reflect::semantics::BindingStage;
|
||||||
use std::ffi::CStr;
|
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use windows::core::{Interface, PCSTR, PCWSTR};
|
use windows::core::{Interface, PCSTR, PCWSTR};
|
||||||
use windows::Win32::Graphics::Direct3D::Dxc::{
|
use windows::Win32::Graphics::Direct3D::Dxc::{
|
||||||
DxcValidatorFlags_Default, DxcValidatorFlags_InPlaceEdit, DxcValidatorFlags_ModuleOnly,
|
DxcValidatorFlags_InPlaceEdit, IDxcBlob, IDxcBlobUtf8, IDxcCompiler, IDxcUtils, IDxcValidator,
|
||||||
DxcValidatorFlags_ValidMask, IDxcBlob, IDxcBlobUtf8, IDxcCompiler, IDxcLibrary, IDxcUtils,
|
DXC_CP, DXC_CP_UTF8,
|
||||||
IDxcValidator, DXC_CP, DXC_CP_UTF8,
|
|
||||||
};
|
};
|
||||||
use windows::Win32::Graphics::Direct3D::Fxc::{
|
use windows::Win32::Graphics::Direct3D::Fxc::{
|
||||||
D3DCompile, D3DCOMPILE_DEBUG, D3DCOMPILE_SKIP_OPTIMIZATION,
|
D3DCompile, D3DCOMPILE_DEBUG, D3DCOMPILE_SKIP_OPTIMIZATION,
|
||||||
|
@ -202,8 +201,8 @@ pub fn dxc_compile_shader(
|
||||||
let buf =
|
let buf =
|
||||||
std::slice::from_raw_parts(buf.GetBufferPointer().cast(), buf.GetBufferSize());
|
std::slice::from_raw_parts(buf.GetBufferPointer().cast(), buf.GetBufferSize());
|
||||||
let str = std::str::from_utf8_unchecked(buf);
|
let str = std::str::from_utf8_unchecked(buf);
|
||||||
if str.len() != 0 {
|
if !str.is_empty() {
|
||||||
eprintln!("{}", str);
|
eprintln!("{str}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,8 +234,8 @@ pub fn dxc_validate_shader(
|
||||||
let buf =
|
let buf =
|
||||||
std::slice::from_raw_parts(buf.GetBufferPointer().cast(), buf.GetBufferSize());
|
std::slice::from_raw_parts(buf.GetBufferPointer().cast(), buf.GetBufferSize());
|
||||||
let str = std::str::from_utf8_unchecked(buf);
|
let str = std::str::from_utf8_unchecked(buf);
|
||||||
if str.len() != 0 {
|
if !str.is_empty() {
|
||||||
eprintln!("{}", str);
|
eprintln!("{str}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,7 @@ use librashader_reflect::back::cross::GlslVersion;
|
||||||
use librashader_reflect::back::targets::GLSL;
|
use librashader_reflect::back::targets::GLSL;
|
||||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||||
use librashader_reflect::front::GlslangCompilation;
|
use librashader_reflect::front::GlslangCompilation;
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{BindingMeta, ShaderSemantics, UniformMeta};
|
||||||
BindingMeta, ShaderSemantics, TextureSemantics, UniformBinding, UniformMeta,
|
|
||||||
};
|
|
||||||
|
|
||||||
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||||
use librashader_reflect::reflect::ReflectShader;
|
use librashader_reflect::reflect::ReflectShader;
|
||||||
|
@ -100,9 +98,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(preset.shaders, &preset.textures)?;
|
>(preset.shaders, &preset.textures)?;
|
||||||
|
|
||||||
let version = options
|
let version = options.map_or_else(gl_get_version, |o| gl_u16_to_version(o.gl_version));
|
||||||
.map(|o| gl_u16_to_version(o.gl_version))
|
|
||||||
.unwrap_or_else(gl_get_version);
|
|
||||||
|
|
||||||
// initialize passes
|
// initialize passes
|
||||||
let filters = Self::init_passes(version, passes, &semantics)?;
|
let filters = Self::init_passes(version, passes, &semantics)?;
|
||||||
|
@ -240,16 +236,11 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let uniform_storage = GlUniformStorage::new(
|
let uniform_storage = GlUniformStorage::new(
|
||||||
reflection
|
reflection.ubo.as_ref().map_or(0, |ubo| ubo.size as usize),
|
||||||
.ubo
|
|
||||||
.as_ref()
|
|
||||||
.map(|ubo| ubo.size as usize)
|
|
||||||
.unwrap_or(0),
|
|
||||||
reflection
|
reflection
|
||||||
.push_constant
|
.push_constant
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|push| push.size as usize)
|
.map_or(0, |push| push.size as usize),
|
||||||
.unwrap_or(0),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let uniform_bindings = reflection.meta.create_binding_map(|param| {
|
let uniform_bindings = reflection.meta.create_binding_map(|param| {
|
||||||
|
@ -280,7 +271,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
filter: FilterMode,
|
filter: FilterMode,
|
||||||
wrap_mode: WrapMode,
|
wrap_mode: WrapMode,
|
||||||
) -> (VecDeque<Framebuffer>, Box<[InputTexture]>) {
|
) -> (VecDeque<Framebuffer>, Box<[InputTexture]>) {
|
||||||
let mut required_images =
|
let required_images =
|
||||||
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
||||||
|
|
||||||
// not using frame history;
|
// not using frame history;
|
||||||
|
@ -346,7 +337,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
if passes.is_empty() {
|
if passes.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let frame_direction = options.map(|f| f.frame_direction).unwrap_or(1);
|
let frame_direction = options.map_or(1, |f| f.frame_direction);
|
||||||
|
|
||||||
// do not need to rebind FBO 0 here since first `draw` will
|
// do not need to rebind FBO 0 here since first `draw` will
|
||||||
// bind automatically.
|
// bind automatically.
|
||||||
|
@ -393,8 +384,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
while let Some((index, pass)) = iterator.next() {
|
while let Some((index, pass)) = iterator.next() {
|
||||||
let should_mipmap = iterator
|
let should_mipmap = iterator
|
||||||
.peek()
|
.peek()
|
||||||
.map(|(_, p)| p.config.mipmap_input)
|
.map_or(false, |(_, p)| p.config.mipmap_input);
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
let next_size = self.output_framebuffers[index].scale::<T::FramebufferInterface>(
|
let next_size = self.output_framebuffers[index].scale::<T::FramebufferInterface>(
|
||||||
pass.config.scaling.clone(),
|
pass.config.scaling.clone(),
|
||||||
|
|
|
@ -20,9 +20,7 @@ use librashader_reflect::back::targets::SPIRV;
|
||||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||||
use librashader_reflect::front::GlslangCompilation;
|
use librashader_reflect::front::GlslangCompilation;
|
||||||
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{BindingMeta, ShaderSemantics};
|
||||||
BindingMeta, ShaderSemantics, TextureSemantics, UniformBinding,
|
|
||||||
};
|
|
||||||
use librashader_reflect::reflect::ReflectShader;
|
use librashader_reflect::reflect::ReflectShader;
|
||||||
use librashader_runtime::binding::BindingUtil;
|
use librashader_runtime::binding::BindingUtil;
|
||||||
use librashader_runtime::image::{Image, UVDirection};
|
use librashader_runtime::image::{Image, UVDirection};
|
||||||
|
@ -230,7 +228,7 @@ impl FilterChainVulkan {
|
||||||
>(preset.shaders, &preset.textures)?;
|
>(preset.shaders, &preset.textures)?;
|
||||||
let device = vulkan.try_into()?;
|
let device = vulkan.try_into()?;
|
||||||
|
|
||||||
let mut frames_in_flight = options.map(|o| o.frames_in_flight).unwrap_or(0);
|
let mut frames_in_flight = options.map_or(0, |o| o.frames_in_flight);
|
||||||
if frames_in_flight == 0 {
|
if frames_in_flight == 0 {
|
||||||
frames_in_flight = 3;
|
frames_in_flight = 3;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +239,7 @@ impl FilterChainVulkan {
|
||||||
passes,
|
passes,
|
||||||
&semantics,
|
&semantics,
|
||||||
frames_in_flight,
|
frames_in_flight,
|
||||||
options.map(|o| o.use_render_pass).unwrap_or(false),
|
options.map_or(false, |o| o.use_render_pass),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let luts = FilterChainVulkan::load_luts(&device, &preset.textures)?;
|
let luts = FilterChainVulkan::load_luts(&device, &preset.textures)?;
|
||||||
|
@ -318,11 +316,7 @@ impl FilterChainVulkan {
|
||||||
let reflection = reflect.reflect(index, semantics)?;
|
let reflection = reflect.reflect(index, semantics)?;
|
||||||
let spirv_words = reflect.compile(None)?;
|
let spirv_words = reflect.compile(None)?;
|
||||||
|
|
||||||
let ubo_size = reflection
|
let ubo_size = reflection.ubo.as_ref().map_or(0, |ubo| ubo.size as usize);
|
||||||
.ubo
|
|
||||||
.as_ref()
|
|
||||||
.map(|ubo| ubo.size as usize)
|
|
||||||
.unwrap_or(0);
|
|
||||||
let uniform_storage = UniformStorage::new_with_storage(
|
let uniform_storage = UniformStorage::new_with_storage(
|
||||||
RawVulkanBuffer::new(
|
RawVulkanBuffer::new(
|
||||||
&vulkan.device,
|
&vulkan.device,
|
||||||
|
@ -333,8 +327,7 @@ impl FilterChainVulkan {
|
||||||
reflection
|
reflection
|
||||||
.push_constant
|
.push_constant
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|push| push.size as usize)
|
.map_or(0, |push| push.size as usize),
|
||||||
.unwrap_or(0),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
||||||
|
@ -445,7 +438,7 @@ impl FilterChainVulkan {
|
||||||
vulkan: &VulkanObjects,
|
vulkan: &VulkanObjects,
|
||||||
filters: &[FilterPass],
|
filters: &[FilterPass],
|
||||||
) -> error::Result<(VecDeque<OwnedImage>, Box<[Option<InputImage>]>)> {
|
) -> error::Result<(VecDeque<OwnedImage>, Box<[Option<InputImage>]>)> {
|
||||||
let mut required_images =
|
let required_images =
|
||||||
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
BindingMeta::calculate_required_history(filters.iter().map(|f| &f.reflection.meta));
|
||||||
|
|
||||||
// not using frame history;
|
// not using frame history;
|
||||||
|
@ -625,8 +618,7 @@ impl FilterChainVulkan {
|
||||||
while let Some((index, pass)) = iterator.next() {
|
while let Some((index, pass)) = iterator.next() {
|
||||||
let should_mipmap = iterator
|
let should_mipmap = iterator
|
||||||
.peek()
|
.peek()
|
||||||
.map(|(_, p)| p.config.mipmap_input)
|
.map_or(false, |(_, p)| p.config.mipmap_input);
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
// needs a barrier to SHADER_READ_ONLY_OPTIMAL otherwise any non-filled in output framebuffers
|
// needs a barrier to SHADER_READ_ONLY_OPTIMAL otherwise any non-filled in output framebuffers
|
||||||
// (like the final one which is just held there and not ever written to, but needs to be
|
// (like the final one which is just held there and not ever written to, but needs to be
|
||||||
|
@ -678,7 +670,7 @@ impl FilterChainVulkan {
|
||||||
let passes_len = passes.len();
|
let passes_len = passes.len();
|
||||||
let (pass, last) = passes.split_at_mut(passes_len - 1);
|
let (pass, last) = passes.split_at_mut(passes_len - 1);
|
||||||
|
|
||||||
let frame_direction = options.map(|f| f.frame_direction).unwrap_or(1);
|
let frame_direction = options.map_or(1, |f| f.frame_direction);
|
||||||
|
|
||||||
for (index, pass) in pass.iter_mut().enumerate() {
|
for (index, pass) in pass.iter_mut().enumerate() {
|
||||||
let target = &self.output_framebuffers[index];
|
let target = &self.output_framebuffers[index];
|
||||||
|
|
|
@ -243,10 +243,7 @@ where
|
||||||
{
|
{
|
||||||
let id = id.as_str();
|
let id = id.as_str();
|
||||||
|
|
||||||
let default = parameter_defaults
|
let default = parameter_defaults.get(id).map_or(0f32, |f| f.initial);
|
||||||
.get(id)
|
|
||||||
.map(|f| f.initial)
|
|
||||||
.unwrap_or(0f32);
|
|
||||||
|
|
||||||
let value = *runtime_parameters.get(id).unwrap_or(&default);
|
let value = *runtime_parameters.get(id).unwrap_or(&default);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue