Skip to content

Commit

Permalink
Pass clippy when running with default features.
Browse files Browse the repository at this point in the history
  • Loading branch information
manon-traverse committed Apr 18, 2024
1 parent 7364349 commit 87c8365
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
17 changes: 10 additions & 7 deletions src/components/fsr3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
use crate::backends::{CommandList, Device};
use crate::error::{FfxError, Result};
pub use crate::interface::Interface;
use fidelityfx_sys::FFX_MESSAGE_TYPE_WARNING;
use log::{error, warn};

// pub use fidelityfx_sys::Device;
Expand All @@ -58,6 +57,8 @@ unsafe fn u16_ptr_to_string(ptr: *const u16) -> OsString {
OsString::from_wide(slice)
}

/// # Safety
///
pub unsafe extern "C" fn msg_callback_func(
msg_type: MsgType,
message: *const widestring::WideChar,
Expand Down Expand Up @@ -148,7 +149,6 @@ impl From<&ContextDescription<'_>> for fidelityfx_sys::Fsr3ContextDescription {

pub struct DispatchDescription<'a> {
pub cmd_list: CommandList<'a>,
pub output: Resource,

pub color: Resource,
pub depth: Resource,
Expand Down Expand Up @@ -194,7 +194,6 @@ impl<'a> DispatchDescription<'a> {
color: Resource,
depth: Resource,
motion_vectors: Resource,
output: Resource,
frame_time_delta: f32,
render_size: [u32; 2],
upscale_output: Resource,
Expand All @@ -208,7 +207,6 @@ impl<'a> DispatchDescription<'a> {
motion_vectors,
reactive: None,
transparency_and_composition: None,
output,
enable_auto_reactive: false,
enable_sharpening: false,
auto_reactive_max: 0.0,
Expand Down Expand Up @@ -236,10 +234,10 @@ impl<'a> DispatchDescription<'a> {

// TODO(YIGIT): For some reason FSR3 does not accept f32::MAX as FLT_MAX
if near == f32::MAX {
self.camera_near = 3.402823466e+38;
self.camera_near = 3.402_823_5e38;
}
if far == f32::MAX {
self.camera_far = 3.402823466e+38;
self.camera_far = 3.402_823_5e38;
}

self.camera_fov_y = fov_y;
Expand Down Expand Up @@ -311,7 +309,6 @@ impl From<DispatchDescription<'_>> for fidelityfx_sys::Fsr3DispatchUpscaleDescri
fn from(val: DispatchDescription<'_>) -> Self {
Self {
commandList: val.cmd_list.0,
// output: val.output,
color: val.color,
transparencyAndComposition: val.transparency_and_composition.unwrap_or_default(),
// colorOpaqueOnly: val.color_opaque_only.unwrap_or_default(),
Expand Down Expand Up @@ -351,6 +348,8 @@ impl From<DispatchDescription<'_>> for fidelityfx_sys::Fsr3DispatchUpscaleDescri
}

impl Context {
/// # Safety
/// Context must be destroyed using the [`Self::destroy`] function.
pub unsafe fn new(desc: ContextDescription<'_>) -> Result<Self> {
let mut context = Box::<fidelityfx_sys::Fsr3Context>::default();
let error =
Expand All @@ -365,6 +364,8 @@ impl Context {
})
}

/// # Safety
/// [`Context`]` and references resources must outlive usage on the GPU timeline.
pub unsafe fn dispatch(&mut self, desc: DispatchDescription<'_>) -> Result<()> {
let error = unsafe {
fidelityfx_sys::Fsr3ContextDispatchUpscale(self.context.as_mut(), &desc.into())
Expand All @@ -375,6 +376,8 @@ impl Context {
Ok(())
}

/// # Safety
/// Must be called once after `new` and after all `dispatch` calls are finished on the GPU timeline.
// TODO This should be in Drop
pub unsafe fn destroy(&mut self) -> Result<()> {
let error = unsafe { fidelityfx_sys::Fsr3ContextDestroy(self.context.as_mut()) };
Expand Down
4 changes: 4 additions & 0 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl ScratchBuffer {
pub fn len(&self) -> usize {
self.layout.size()
}

pub fn is_empty(&self) -> bool {
self.len() == 0
}
}

unsafe impl Send for ScratchBuffer {}
Expand Down
1 change: 0 additions & 1 deletion sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod bindgen;

use std::path::Path;

use cc;
use glob::glob;

fn build_fsr3(api_dir: &Path, vk_include_dir: &Path) {
Expand Down
2 changes: 0 additions & 2 deletions sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#![allow(non_snake_case)]
#![allow(clippy::excessive_precision)]

type widechar = widestring::WideChar;

include!("bindings.rs");

#[cfg(feature = "vulkan")]
Expand Down

0 comments on commit 87c8365

Please sign in to comment.