Skip to content

Commit

Permalink
Cleaning up warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
entropylost committed Sep 16, 2023
1 parent 6a60997 commit 737ea64
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 deletions.
22 changes: 10 additions & 12 deletions luisa_compute/src/lang/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::HashSet;
use std::marker::PhantomData;
use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
use std::{any::Any, fmt::Debug, rc::Rc, sync::Arc};
use std::{env, unreachable};

use crate::lang::traits::VarCmp;
Expand All @@ -12,19 +11,16 @@ use crate::{rtx, ResourceTracker};
use bumpalo::Bump;
use indexmap::IndexMap;
pub use ir::ir::NodeRef;
use ir::ir::{
new_node, BasicBlock, Binding, Capture, Const, CpuCustomOp, Func, Instruction, IrBuilder,
KernelModule, Module, ModuleKind, Node, PhiIncoming,
};
use ir::ir::{
ArrayType, CallableModule, CallableModuleRef, ModuleFlags, ModulePools, SwitchCase,
UserNodeData, INVALID_REF,
};
pub use ir::CArc;
use ir::Pooled;
use ir::{
ir::{
new_node, BasicBlock, Binding, Capture, Const, CpuCustomOp, Func, Instruction, IrBuilder,
KernelModule, Module, ModuleKind, Node, PhiIncoming,
},
transform::{self, Transform},
};

use luisa_compute_ir as ir;

Expand All @@ -34,10 +30,9 @@ pub use luisa_compute_ir::{
ir::{StructType, Type},
TypeOf,
};
use math::Uint3;
use std::cell::{Cell, RefCell, UnsafeCell};
use std::cell::{Cell, RefCell};
use std::ffi::CString;
use std::ops::{Bound, Deref, DerefMut, RangeBounds};
use std::ops::{Deref, DerefMut};
use std::sync::atomic::AtomicUsize;
// use self::math::Uint3;
pub mod math;
Expand All @@ -50,12 +45,15 @@ pub use math::*;
pub use poly::*;
pub use printer::*;

#[allow(dead_code)]
pub(crate) static KERNEL_ID: AtomicUsize = AtomicUsize::new(0);
// prevent node being shared across kernels
// TODO: replace NodeRef with SafeNodeRef
#[derive(Clone, Copy, Debug)]
pub(crate) struct SafeNodeRef {
#[allow(dead_code)]
pub(crate) node: NodeRef,
#[allow(dead_code)]
pub(crate) kernel_id: usize,
}
pub trait Value: Copy + ir::TypeOf + 'static {
Expand Down
6 changes: 4 additions & 2 deletions luisa_compute/src/lang/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::sync::atomic::AtomicBool;

pub type LogFn = Box<dyn Fn(&[*const u32]) + Send + Sync>;
struct PrinterItem {
#[allow(dead_code)]
level: log::Level,
log_fn: LogFn,
count: usize,
Expand Down Expand Up @@ -123,7 +124,8 @@ impl Printer {
let item_id = items.len() as u32;

if_!(
offset.cmplt(data.len().uint()) & (offset + 1 + args.count as u32).cmple(data.len().uint()),
offset.cmplt(data.len().uint())
& (offset + 1 + args.count as u32).cmple(data.len().uint()),
{
data.atomic_fetch_add(0, 1);
data.write(offset, item_id);
Expand Down Expand Up @@ -194,7 +196,7 @@ impl<'a> Scope<'a> {
let items = data.items.read();
let mut i = 2;
let item_count = host_data[0] as usize;
for j in 0..item_count {
for _j in 0..item_count {
if i >= host_data.len() {
break;
}
Expand Down
10 changes: 6 additions & 4 deletions luisa_compute/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,9 @@ impl_storage_texel!([f16; 4], Byte4, f32, Float2, Float4, Int2, Int4, Uint2, Uin
// `T` is the read out type of the texture, which is not necessarily the same as the storage type
// In fact, the texture can be stored in any format as long as it can be converted to `T`
pub struct Tex2d<T: IoTexel> {
#[allow(dead_code)]
pub(crate) width: u32,
#[allow(dead_code)]
pub(crate) height: u32,
pub(crate) handle: Arc<TextureHandle>,
pub(crate) marker: std::marker::PhantomData<T>,
Expand All @@ -1013,8 +1015,11 @@ pub struct Tex2d<T: IoTexel> {
// `T` is the read out type of the texture, which is not necessarily the same as the storage type
// In fact, the texture can be stored in any format as long as it can be converted to `T`
pub struct Tex3d<T: IoTexel> {
#[allow(dead_code)]
pub(crate) width: u32,
#[allow(dead_code)]
pub(crate) height: u32,
#[allow(dead_code)]
pub(crate) depth: u32,
pub(crate) handle: Arc<TextureHandle>,
pub(crate) marker: std::marker::PhantomData<T>,
Expand Down Expand Up @@ -1573,10 +1578,7 @@ impl BindlessArrayVar {
};
v
}
pub fn byte_address_buffer(
&self,
buffer_index: impl Into<Expr<u32>>,
) -> BindlessByteBufferVar {
pub fn byte_address_buffer(&self, buffer_index: impl Into<Expr<u32>>) -> BindlessByteBufferVar {
let v = BindlessByteBufferVar {
array: self.node,
buffer_index: buffer_index.into(),
Expand Down
13 changes: 9 additions & 4 deletions luisa_compute/src/rtx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub(crate) struct ProceduralPrimitiveHandle {
pub(crate) device: Device,
pub(crate) handle: api::ProceduralPrimitive,
pub(crate) native_handle: *mut std::ffi::c_void,
#[allow(dead_code)]
pub(crate) aabb_buffer: Arc<BufferHandle>,
}
impl Drop for ProceduralPrimitiveHandle {
Expand Down Expand Up @@ -85,7 +86,9 @@ pub(crate) struct MeshHandle {
pub(crate) device: Device,
pub(crate) handle: api::Mesh,
pub(crate) native_handle: *mut std::ffi::c_void,
#[allow(dead_code)]
pub(crate) vbuffer: Arc<BufferHandle>,
#[allow(dead_code)]
pub(crate) ibuffer: Arc<BufferHandle>,
}
impl Drop for MeshHandle {
Expand Down Expand Up @@ -148,7 +151,8 @@ impl Accel {
let mut flags =
api::AccelBuildModificationFlags::PRIMITIVE | AccelBuildModificationFlags::TRANSFORM;

flags |= api::AccelBuildModificationFlags::VISIBILITY | api::AccelBuildModificationFlags::USER_ID;
flags |= api::AccelBuildModificationFlags::VISIBILITY
| api::AccelBuildModificationFlags::USER_ID;

if opaque {
flags |= api::AccelBuildModificationFlags::OPAQUE_ON;
Expand Down Expand Up @@ -183,7 +187,8 @@ impl Accel {
) {
let mut flags = api::AccelBuildModificationFlags::PRIMITIVE;
dbg!(flags);
flags |= api::AccelBuildModificationFlags::VISIBILITY | api::AccelBuildModificationFlags::USER_ID;
flags |= api::AccelBuildModificationFlags::VISIBILITY
| api::AccelBuildModificationFlags::USER_ID;

if opaque {
flags |= api::AccelBuildModificationFlags::OPAQUE_ON;
Expand Down Expand Up @@ -372,8 +377,8 @@ pub enum HitType {

pub fn offset_ray_origin(p: Expr<Float3>, n: Expr<Float3>) -> Expr<Float3> {
lazy_static! {
static ref F: Callable<fn(Expr<Float3>, Expr<Float3>)-> Expr<Float3>> =
create_static_callable::<fn(Expr<Float3>, Expr<Float3>)->Expr<Float3>>(|p, n| {
static ref F: Callable<fn(Expr<Float3>, Expr<Float3>) -> Expr<Float3>> =
create_static_callable::<fn(Expr<Float3>, Expr<Float3>) -> Expr<Float3>>(|p, n| {
const ORIGIN: f32 = 1.0f32 / 32.0f32;
const FLOAT_SCALE: f32 = 1.0f32 / 65536.0f32;
const INT_SCALE: f32 = 256.0f32;
Expand Down
4 changes: 3 additions & 1 deletion luisa_compute/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl Device {
modifications: RwLock::new(HashMap::new()),
}
}
pub fn create_callable<'a, S: CallableSignature<'a>>(&self, f:S::Fn) -> S::Callable {
pub fn create_callable<'a, S: CallableSignature<'a>>(&self, f: S::Fn) -> S::Callable {
let mut builder = KernelBuilder::new(Some(self.clone()), false);
let raw_callable = CallableBuildFn::build_callable(&f, None, &mut builder);
S::wrap_raw_callable(raw_callable)
Expand Down Expand Up @@ -835,6 +835,7 @@ impl<'a> CommandList<'a> {
pub fn extend<I: IntoIterator<Item = Command<'a>>>(&mut self, commands: I) {
self.commands.extend(commands);
}
#[allow(dead_code)]
pub fn push(&mut self, command: Command<'a>) {
self.commands.push(command);
}
Expand Down Expand Up @@ -864,6 +865,7 @@ pub struct Command<'a> {
pub(crate) struct AsyncShaderArtifact {
shader: Option<api::CreatedShaderInfo>,
// strange naming, huh?
#[allow(dead_code)]
name: Arc<CString>,
}

Expand Down

0 comments on commit 737ea64

Please sign in to comment.