fmt: cargo fmt

This commit is contained in:
chyyran 2024-02-03 02:04:39 -05:00 committed by Ronny Chan
parent 60fac06332
commit 80325fda9e
8 changed files with 52 additions and 34 deletions

View file

@ -332,7 +332,7 @@ where
expected, expected,
received: offset, received: offset,
ty: offset_type, ty: offset_type,
pass: pass_number pass: pass_number,
}); });
} }
if meta.size != typeinfo.size { if meta.size != typeinfo.size {
@ -367,7 +367,7 @@ where
expected, expected,
received: offset, received: offset,
ty: offset_type, ty: offset_type,
pass: pass_number pass: pass_number,
}); });
} }
if meta.size != typeinfo.size * typeinfo.columns { if meta.size != typeinfo.size * typeinfo.columns {
@ -416,7 +416,7 @@ where
expected, expected,
received: offset, received: offset,
ty: offset_type, ty: offset_type,
pass: pass_number pass: pass_number,
}); });
} }

View file

@ -265,7 +265,9 @@ impl FilterChainD3D11 {
disable_cache, disable_cache,
)?; )?;
let ubo_cbuffer = if let Some(ubo) = &reflection.ubo && ubo.size != 0 { let ubo_cbuffer = if let Some(ubo) = &reflection.ubo
&& ubo.size != 0
{
let buffer = FilterChainD3D11::create_constant_buffer(device, ubo.size)?; let buffer = FilterChainD3D11::create_constant_buffer(device, ubo.size)?;
Some(ConstantBufferBinding { Some(ConstantBufferBinding {
binding: ubo.binding, binding: ubo.binding,
@ -277,7 +279,9 @@ impl FilterChainD3D11 {
None None
}; };
let push_cbuffer = if let Some(push) = &reflection.push_constant && push.size != 0 { let push_cbuffer = if let Some(push) = &reflection.push_constant
&& push.size != 0
{
let buffer = FilterChainD3D11::create_constant_buffer(device, push.size)?; let buffer = FilterChainD3D11::create_constant_buffer(device, push.size)?;
Some(ConstantBufferBinding { Some(ConstantBufferBinding {
binding: if ubo_cbuffer.is_some() { 1 } else { 0 }, binding: if ubo_cbuffer.is_some() { 1 } else { 0 },

View file

@ -97,7 +97,8 @@ pub fn d3d11_get_closest_format(
for supported in format_support_list { for supported in format_support_list {
unsafe { unsafe {
if let Ok(supported_format) = device.CheckFormatSupport(*supported) if let Ok(supported_format) = device.CheckFormatSupport(*supported)
&& (supported_format & format_support_mask) == format_support_mask { && (supported_format & format_support_mask) == format_support_mask
{
return *supported; return *supported;
} }
} }

View file

@ -477,33 +477,32 @@ impl FilterChainD3D12 {
.into(); .into();
// incredibly cursed. // incredibly cursed.
let (reflection, graphics_pipeline) = if !force_hlsl && let (reflection, graphics_pipeline) = if !force_hlsl
let Ok(graphics_pipeline) = && let Ok(graphics_pipeline) = D3D12GraphicsPipeline::new_from_dxil(
D3D12GraphicsPipeline::new_from_dxil(
device, device,
library, library,
validator, validator,
&dxil, &dxil,
root_signature, root_signature,
render_format, render_format,
disable_cache disable_cache,
) { ) {
(dxil_reflection, graphics_pipeline) (dxil_reflection, graphics_pipeline)
} else { } else {
let hlsl_reflection = hlsl.reflect(index, semantics)?; let hlsl_reflection = hlsl.reflect(index, semantics)?;
let hlsl = hlsl.compile(Some(ShaderModel::V6_0))?; let hlsl = hlsl.compile(Some(ShaderModel::V6_0))?;
let graphics_pipeline = D3D12GraphicsPipeline::new_from_hlsl( let graphics_pipeline = D3D12GraphicsPipeline::new_from_hlsl(
device, device,
library, library,
compiler, compiler,
&hlsl, &hlsl,
root_signature, root_signature,
render_format, render_format,
disable_cache disable_cache,
)?; )?;
(hlsl_reflection, graphics_pipeline) (hlsl_reflection, graphics_pipeline)
}; };
// minimum size here has to be 1 byte. // minimum size here has to be 1 byte.
let ubo_size = reflection.ubo.as_ref().map_or(1, |ubo| ubo.size as usize); let ubo_size = reflection.ubo.as_ref().map_or(1, |ubo| ubo.size as usize);

View file

@ -68,10 +68,14 @@ where
&& location.bindable() && location.bindable()
{ {
if location.is_valid(BindingStage::VERTEX) { if location.is_valid(BindingStage::VERTEX) {
unsafe { T::FACTORY(location.vertex, value); } unsafe {
T::FACTORY(location.vertex, value);
}
} }
if location.is_valid(BindingStage::FRAGMENT) { if location.is_valid(BindingStage::FRAGMENT) {
unsafe { T::FACTORY(location.fragment, value); } unsafe {
T::FACTORY(location.fragment, value);
}
} }
Some(()) Some(())
} else { } else {

View file

@ -27,12 +27,14 @@ impl FilterChainGL {
options: Option<&FilterChainOptionsGL>, options: Option<&FilterChainOptionsGL>,
) -> Result<Self> { ) -> Result<Self> {
let result = catch_unwind(|| { let result = catch_unwind(|| {
if let Some(options) = options && options.use_dsa { if let Some(options) = options
&& options.use_dsa
{
return Ok(Self { return Ok(Self {
filter: FilterChainDispatch::DirectStateAccess(unsafe { filter: FilterChainDispatch::DirectStateAccess(unsafe {
FilterChainImpl::load_from_preset(preset, Some(options))? FilterChainImpl::load_from_preset(preset, Some(options))?
}) }),
}) });
} }
Ok(Self { Ok(Self {
filter: FilterChainDispatch::Compatibility(unsafe { filter: FilterChainDispatch::Compatibility(unsafe {

View file

@ -188,7 +188,8 @@ impl FrameResiduals {
} }
for framebuffer in self.framebuffers.drain(0..) { for framebuffer in self.framebuffers.drain(0..) {
if let Some(framebuffer) = framebuffer if let Some(framebuffer) = framebuffer
&& framebuffer != vk::Framebuffer::null() { && framebuffer != vk::Framebuffer::null()
{
unsafe { unsafe {
self.device.destroy_framebuffer(framebuffer, None); self.device.destroy_framebuffer(framebuffer, None);
} }
@ -697,8 +698,13 @@ impl FilterChainVulkan {
// try to hint the optimizer // try to hint the optimizer
assert_eq!(last.len(), 1); assert_eq!(last.len(), 1);
if let Some(pass) = last.iter_mut().next() { if let Some(pass) = last.iter_mut().next() {
if let Some(format) = pass.graphics_pipeline.render_pass.as_ref().map(|r| r.format) if let Some(format) = pass
&& format != viewport.output.format { .graphics_pipeline
.render_pass
.as_ref()
.map(|r| r.format)
&& format != viewport.output.format
{
// need to recompile // need to recompile
pass.graphics_pipeline.recompile(viewport.output.format)?; pass.graphics_pipeline.recompile(viewport.output.format)?;
} }

View file

@ -31,7 +31,9 @@ impl PipelineDescriptors {
} }
pub fn add_ubo_binding(&mut self, ubo_meta: Option<&UboReflection>) { pub fn add_ubo_binding(&mut self, ubo_meta: Option<&UboReflection>) {
if let Some(ubo_meta) = ubo_meta && !ubo_meta.stage_mask.is_empty() { if let Some(ubo_meta) = ubo_meta
&& !ubo_meta.stage_mask.is_empty()
{
let ubo_mask = util::binding_stage_to_vulkan_stage(ubo_meta.stage_mask); let ubo_mask = util::binding_stage_to_vulkan_stage(ubo_meta.stage_mask);
self.layout_bindings.push(vk::DescriptorSetLayoutBinding { self.layout_bindings.push(vk::DescriptorSetLayoutBinding {