Skip to content

Commit 22e66a0

Browse files
trigpolynomjorge-ortega
authored andcommitted
clippy ran successfully
1 parent 16344c0 commit 22e66a0

File tree

7 files changed

+40
-50
lines changed

7 files changed

+40
-50
lines changed

crates/optix/examples/rust/ex04_mesh_gpu/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use cuda_std::kernel;
44
use optix_device::{
55
closesthit, get_launch_index,
66
glam::*,
7-
misc::*,
87
payload,
98
trace::TraversableHandle,
109
trace::{trace, RayFlags},

crates/optix/src/acceleration.rs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -703,16 +703,13 @@ bitflags::bitflags! {
703703
#[cfg_attr(windows, repr(i32))]
704704
#[cfg_attr(unix, repr(u32))]
705705
#[derive(Debug, Copy, Clone, PartialEq)]
706+
#[derive(Default)]
706707
pub enum BuildOperation {
708+
#[default]
707709
Build = sys::OptixBuildOperation_OPTIX_BUILD_OPERATION_BUILD,
708710
Update = sys::OptixBuildOperation_OPTIX_BUILD_OPERATION_UPDATE,
709711
}
710712

711-
impl Default for BuildOperation {
712-
fn default() -> Self {
713-
BuildOperation::Build
714-
}
715-
}
716713

717714
/// Configure how to handle ray times that are outside of the provided motion keys.
718715
///
@@ -983,7 +980,7 @@ pub struct CurveArray<'v, 'w, 'i> {
983980
primitive_index_offset: u32,
984981
}
985982

986-
impl<'v, 'w, 'i> Hash for CurveArray<'v, 'w, 'i> {
983+
impl Hash for CurveArray<'_, '_, '_> {
987984
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
988985
self.curve_type.hash(state);
989986
state.write_u32(self.num_primitives);
@@ -1088,7 +1085,7 @@ impl<'v, 'w, 'i> CurveArray<'v, 'w, 'i> {
10881085
}
10891086
}
10901087

1091-
impl<'v, 'w, 'i> BuildInput for CurveArray<'v, 'w, 'i> {
1088+
impl BuildInput for CurveArray<'_, '_, '_> {
10921089
fn to_sys(&self) -> sys::OptixBuildInput {
10931090
sys::OptixBuildInput {
10941091
type_: sys::OptixBuildInputType_OPTIX_BUILD_INPUT_TYPE_CURVES,
@@ -1139,13 +1136,13 @@ impl From<CurveType> for sys::OptixPrimitiveType {
11391136
#[repr(u32)]
11401137
#[derive(Copy, Clone, PartialEq)]
11411138
pub enum VertexFormat {
1142-
None = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_NONE as u32,
1143-
Float3 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_FLOAT3 as u32,
1144-
Float2 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_FLOAT2 as u32,
1145-
Half3 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_HALF3 as u32,
1146-
Half2 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_HALF2 as u32,
1147-
SNorm16 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_SNORM16_3 as u32,
1148-
SNorm32 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_SNORM16_2 as u32,
1139+
None = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_NONE,
1140+
Float3 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_FLOAT3,
1141+
Float2 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_FLOAT2,
1142+
Half3 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_HALF3,
1143+
Half2 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_HALF2,
1144+
SNorm16 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_SNORM16_3,
1145+
SNorm32 = sys::OptixVertexFormat_OPTIX_VERTEX_FORMAT_SNORM16_2,
11491146
}
11501147

11511148
/// Specifies the type of index data
@@ -1299,15 +1296,15 @@ impl<'v, 'g, V: Vertex> TriangleArray<'v, 'g, V> {
12991296
}
13001297
}
13011298

1302-
impl<'v, 'g, V: Vertex> Hash for TriangleArray<'v, 'g, V> {
1299+
impl<V: Vertex> Hash for TriangleArray<'_, '_, V> {
13031300
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
13041301
state.write_u32(self.num_vertices);
13051302
state.write_usize(self.d_vertex_buffers.len());
13061303
self.geometry_flags.hash(state);
13071304
}
13081305
}
13091306

1310-
impl<'v, 'g, V: Vertex> BuildInput for TriangleArray<'v, 'g, V> {
1307+
impl<V: Vertex> BuildInput for TriangleArray<'_, '_, V> {
13111308
fn to_sys(&self) -> sys::OptixBuildInput {
13121309
sys::OptixBuildInput {
13131310
type_: sys::OptixBuildInputType_OPTIX_BUILD_INPUT_TYPE_TRIANGLES,
@@ -1382,7 +1379,7 @@ impl<'v, 'i, V: Vertex, I: IndexTriple> IndexedTriangleArray<'v, 'i, V, I> {
13821379
}
13831380
}
13841381

1385-
impl<'v, 'i, V: Vertex, I: IndexTriple> Hash for IndexedTriangleArray<'v, 'i, V, I> {
1382+
impl<V: Vertex, I: IndexTriple> Hash for IndexedTriangleArray<'_, '_, V, I> {
13861383
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
13871384
state.write_u32(self.num_vertices);
13881385
state.write_usize(self.d_vertex_buffers.len());
@@ -1391,7 +1388,7 @@ impl<'v, 'i, V: Vertex, I: IndexTriple> Hash for IndexedTriangleArray<'v, 'i, V,
13911388
}
13921389
}
13931390

1394-
impl<'v, 'i, V: Vertex, I: IndexTriple> BuildInput for IndexedTriangleArray<'v, 'i, V, I> {
1391+
impl<V: Vertex, I: IndexTriple> BuildInput for IndexedTriangleArray<'_, '_, V, I> {
13951392
fn to_sys(&self) -> sys::OptixBuildInput {
13961393
sys::OptixBuildInput {
13971394
type_: sys::OptixBuildInputType_OPTIX_BUILD_INPUT_TYPE_TRIANGLES,
@@ -1439,7 +1436,7 @@ pub struct CustomPrimitiveArray<'a, 's> {
14391436
primitive_index_offset: u32,
14401437
}
14411438

1442-
impl<'a, 'g, 's> Hash for CustomPrimitiveArray<'a, 's> {
1439+
impl<'g> Hash for CustomPrimitiveArray<'_, '_> {
14431440
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
14441441
state.write_usize(self.aabb_buffers.len());
14451442
state.write_u32(self.num_primitives);
@@ -1509,7 +1506,7 @@ impl<'a, 's> CustomPrimitiveArray<'a, 's> {
15091506
}
15101507
}
15111508

1512-
impl<'a, 's> BuildInput for CustomPrimitiveArray<'a, 's> {
1509+
impl BuildInput for CustomPrimitiveArray<'_, '_> {
15131510
fn to_sys(&self) -> sys::OptixBuildInput {
15141511
sys::OptixBuildInput {
15151512
type_: sys::OptixBuildInputType_OPTIX_BUILD_INPUT_TYPE_CUSTOM_PRIMITIVES,
@@ -1646,13 +1643,13 @@ impl<'i, 'a> InstanceArray<'i, 'a> {
16461643
}
16471644
}
16481645

1649-
impl<'i, 'a> Hash for InstanceArray<'i, 'a> {
1646+
impl Hash for InstanceArray<'_, '_> {
16501647
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
16511648
state.write_usize(self.instances.len());
16521649
}
16531650
}
16541651

1655-
impl<'i, 'a> BuildInput for InstanceArray<'i, 'a> {
1652+
impl BuildInput for InstanceArray<'_, '_> {
16561653
fn to_sys(&self) -> sys::OptixBuildInput {
16571654
cfg_if::cfg_if! {
16581655
if #[cfg(any(feature="optix72", feature="optix73"))] {
@@ -1692,13 +1689,13 @@ impl<'i> InstancePointerArray<'i> {
16921689
}
16931690
}
16941691

1695-
impl<'i> Hash for InstancePointerArray<'i> {
1692+
impl Hash for InstancePointerArray<'_> {
16961693
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
16971694
state.write_usize(self.instances.len());
16981695
}
16991696
}
17001697

1701-
impl<'i> BuildInput for InstancePointerArray<'i> {
1698+
impl BuildInput for InstancePointerArray<'_> {
17021699
fn to_sys(&self) -> sys::OptixBuildInput {
17031700
cfg_if::cfg_if! {
17041701
if #[cfg(any(feature="optix72", feature="optix73"))] {
@@ -1865,7 +1862,7 @@ impl MatrixMotionTransform {
18651862
cust::memory::memcpy_htod(
18661863
transform_ptr.as_raw(),
18671864
transforms.as_ptr() as *const c_void,
1868-
std::mem::size_of::<RowMatrix3x4<f32>>() * num_keys,
1865+
std::mem::size_of_val(transforms),
18691866
)?;
18701867

18711868
let hnd = convert_pointer_to_traversable_handle(
@@ -2014,7 +2011,7 @@ impl SrtMotionTransform {
20142011
cust::memory::memcpy_htod(
20152012
transform_ptr.as_raw(),
20162013
srt_data.as_ptr() as *const c_void,
2017-
std::mem::size_of::<SrtData>() * num_keys,
2014+
std::mem::size_of_val(srt_data),
20182015
)?;
20192016

20202017
let hnd = convert_pointer_to_traversable_handle(

crates/optix/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl DeviceContext {
107107
Ok(optix_call!(optixDeviceContextGetCacheDatabaseSizes(
108108
self.raw, &mut low, &mut high,
109109
))
110-
.map(|_| (low as usize, high as usize))?)
110+
.map(|_| (low, high))?)
111111
}
112112
}
113113

crates/optix/src/denoiser.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ impl Denoiser {
222222
stream.as_inner(),
223223
width,
224224
height,
225-
state.as_device_ptr().as_raw() as u64,
225+
state.as_device_ptr().as_raw(),
226226
state_size,
227-
scratch.as_device_ptr().as_raw() as u64,
227+
scratch.as_device_ptr().as_raw(),
228228
scratch_size
229229
))?;
230230
}
@@ -373,7 +373,7 @@ impl Denoiser {
373373
let raw_params = parameters.to_raw();
374374

375375
let mut out = input_image.to_raw();
376-
out.data = out_buffer.as_device_ptr().as_raw() as u64;
376+
out.data = out_buffer.as_device_ptr().as_raw();
377377

378378
let layer = sys::OptixDenoiserLayer {
379379
input: input_image.to_raw(),
@@ -388,14 +388,14 @@ impl Denoiser {
388388
self.raw,
389389
stream.as_inner(),
390390
&raw_params as *const _,
391-
state.state.as_device_ptr().as_raw() as u64,
391+
state.state.as_device_ptr().as_raw(),
392392
state.state.len(),
393393
&cloned as *const _,
394394
&layer as *const _,
395395
1, // num-layers
396396
0, // offsetX
397397
0, // offsetY
398-
state.scratch.as_device_ptr().as_raw() as u64,
398+
state.scratch.as_device_ptr().as_raw(),
399399
state.scratch.len()
400400
))?;
401401
}
@@ -426,11 +426,11 @@ impl DenoiserParams<'_> {
426426
denoiseAlpha: self.denoise_alpha as u32,
427427
hdrIntensity: self
428428
.hdr_intensity
429-
.map(|x| x.as_device_ptr().as_raw() as u64)
429+
.map(|x| x.as_device_ptr().as_raw())
430430
.unwrap_or_default(),
431431
hdrAverageColor: self
432432
.hdr_average_color
433-
.map(|x| x.as_device_ptr().as_raw() as u64)
433+
.map(|x| x.as_device_ptr().as_raw())
434434
.unwrap_or_default(),
435435
blendFactor: self.blend_factor,
436436
}
@@ -581,7 +581,7 @@ impl<'a> Image<'a> {
581581
let buf_size = std::mem::size_of::<T>() * bytes.len();
582582

583583
assert!(
584-
buf_size >= required_size as usize,
584+
buf_size >= required_size,
585585
"Buffer for {}x{} {:?} image is not large enough, expected {} bytes, found {}",
586586
width,
587587
height,
@@ -605,7 +605,7 @@ impl<'a> Image<'a> {
605605
let required_bytes = Self::required_buffer_size(format, width, height);
606606
let t_size = std::mem::size_of::<T>();
607607
// round-up division
608-
let buf_size = (required_bytes + t_size - 1) / t_size;
608+
let buf_size = required_bytes.div_ceil(t_size);
609609

610610
UnifiedBuffer::new(&T::default(), buf_size)
611611
}
@@ -630,7 +630,7 @@ impl<'a> Image<'a> {
630630
rowStrideInBytes: self.row_stride_in_bytes(),
631631
pixelStrideInBytes: self.pixel_stride_in_bytes(),
632632
format: self.format.to_raw(),
633-
data: self.buffer.as_raw() as u64,
633+
data: self.buffer.as_raw(),
634634
}
635635
}
636636

crates/optix/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub unsafe fn launch<M: DeviceMemory>(
177177
Ok(optix_call!(optixLaunch(
178178
pipeline.raw,
179179
stream.as_inner(),
180-
pipeline_params.as_raw_ptr() as u64,
180+
pipeline_params.as_raw_ptr(),
181181
pipeline_params.size_in_bytes(),
182182
&sbt.0,
183183
width,

crates/optix/src/pipeline.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,35 +135,29 @@ pub struct Module {
135135
#[cfg_attr(windows, repr(i32))]
136136
#[cfg_attr(unix, repr(u32))]
137137
#[derive(Debug, Hash, PartialEq, Copy, Clone)]
138+
#[derive(Default)]
138139
pub enum CompileOptimizationLevel {
140+
#[default]
139141
Default = sys::OptixCompileOptimizationLevel::OPTIX_COMPILE_OPTIMIZATION_DEFAULT,
140142
Level0 = sys::OptixCompileOptimizationLevel::OPTIX_COMPILE_OPTIMIZATION_LEVEL_0,
141143
Level1 = sys::OptixCompileOptimizationLevel::OPTIX_COMPILE_OPTIMIZATION_LEVEL_1,
142144
Level2 = sys::OptixCompileOptimizationLevel::OPTIX_COMPILE_OPTIMIZATION_LEVEL_2,
143145
Level3 = sys::OptixCompileOptimizationLevel::OPTIX_COMPILE_OPTIMIZATION_LEVEL_3,
144146
}
145147

146-
impl Default for CompileOptimizationLevel {
147-
fn default() -> Self {
148-
CompileOptimizationLevel::Default
149-
}
150-
}
151148

152149
/// Module compilation debug level
153150
#[cfg_attr(windows, repr(i32))]
154151
#[cfg_attr(unix, repr(u32))]
155152
#[derive(Debug, Hash, PartialEq, Copy, Clone)]
153+
#[derive(Default)]
156154
pub enum CompileDebugLevel {
155+
#[default]
157156
None = sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_NONE,
158157
LineInfo = sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO,
159158
Full = sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_FULL,
160159
}
161160

162-
impl Default for CompileDebugLevel {
163-
fn default() -> Self {
164-
CompileDebugLevel::None
165-
}
166-
}
167161

168162
cfg_if::cfg_if! {
169163
if #[cfg(any(feature="optix72", feature="optix73"))] {

examples/cuda/cpu/add/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4545
// current CUDA device/architecture.
4646
let (_, block_size) = func.suggested_launch_configuration(0, 0.into())?;
4747

48-
let grid_size = (NUMBERS_LEN as u32 + block_size - 1) / block_size;
48+
let grid_size = (NUMBERS_LEN as u32).div_ceil(block_size);
4949

5050
println!(
5151
"using {} blocks and {} threads per block",

0 commit comments

Comments
 (0)