Skip to content

Commit 1697114

Browse files
jorge-ortegaLegNeato
authored andcommitted
optix: Fix bitflags derive macros for optix enums/flags.
Updated `bitflags` has a few breaking changes: - it no longer adds traits like `Clone`, `Copy`, etc.. Add those explicitly. - An internal wrapper over the underlying flag type is used that isn't `DeviceCopy`. Define the struct wrapping the underlying type explictly, and use `bitflags!` to define the impl.
1 parent 8fea329 commit 1697114

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

crates/optix/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl_half=["cust/impl_half", "half"]
1919
cust = { version = "0.3", path = "../cust", features=["impl_mint"] }
2020
cust_raw = { version = "0.11.2", path = "../cust_raw" }
2121
cfg-if = "1.0.0"
22-
bitflags = "2.8"
22+
bitflags = "2.9.0"
2323
glam = { version = "0.29", features=["cuda", "libm"], default-features=false, optional=true }
2424
half = { version = "2.4.1", optional = true }
2525
memoffset = "0.9.1"

crates/optix/src/acceleration.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ bitflags::bitflags! {
688688
/// an AH programs on the device. May affect the performance of the accel (seems to be larger).
689689
///
690690
/// Note that `PREFER_FAST_TRACE` and `PREFER_FAST_BUILD` are mutually exclusive.
691-
#[derive(Default)]
691+
#[derive(Default, Clone, Copy, PartialEq, Eq, Debug)]
692692
pub struct BuildFlags: OptixEnumBaseType {
693693
const NONE = sys::OptixBuildFlags_OPTIX_BUILD_FLAG_NONE;
694694
const ALLOW_UPDATE = sys::OptixBuildFlags_OPTIX_BUILD_FLAG_ALLOW_UPDATE;
@@ -714,18 +714,20 @@ impl Default for BuildOperation {
714714
}
715715
}
716716

717+
/// Configure how to handle ray times that are outside of the provided motion keys.
718+
///
719+
/// By default, the object will appear static (clamped) to the nearest motion
720+
/// key for rays outside of the range of key times.
721+
///
722+
/// * `START_VANISH` - The object will be invisible to rays with a time less
723+
/// than the first provided motion key
724+
/// * `END_VANISH` - The object will be invisible to rays with a time less
725+
/// than the first provided motion key
726+
#[derive(DeviceCopy, Clone, Copy, PartialEq, Eq, Debug)]
727+
pub struct MotionFlags(u16);
728+
717729
bitflags::bitflags! {
718-
/// Configure how to handle ray times that are outside of the provided motion keys.
719-
///
720-
/// By default, the object will appear static (clamped) to the nearest motion
721-
/// key for rays outside of the range of key times.
722-
///
723-
/// * `START_VANISH` - The object will be invisible to rays with a time less
724-
/// than the first provided motion key
725-
/// * `END_VANISH` - The object will be invisible to rays with a time less
726-
/// than the first provided motion key
727-
#[derive(DeviceCopy)]
728-
pub struct MotionFlags: u16 {
730+
impl MotionFlags: u16 {
729731
const NONE = sys::OptixMotionFlags_OPTIX_MOTION_FLAG_NONE as u16;
730732
const START_VANISH = sys::OptixMotionFlags_OPTIX_MOTION_FLAG_START_VANISH as u16;
731733
const END_VANISH = sys::OptixMotionFlags_OPTIX_MOTION_FLAG_END_VANISH as u16;
@@ -1558,9 +1560,10 @@ const_assert_eq!(
15581560
std::mem::size_of::<sys::OptixInstance>()
15591561
);
15601562

1563+
#[derive(DeviceCopy, Clone, Copy, PartialEq, Eq, Debug)]
1564+
pub struct InstanceFlags(OptixEnumBaseType);
15611565
bitflags::bitflags! {
1562-
#[derive(DeviceCopy)]
1563-
pub struct InstanceFlags: OptixEnumBaseType {
1566+
impl InstanceFlags: OptixEnumBaseType {
15641567
const NONE = sys::OptixInstanceFlags_OPTIX_INSTANCE_FLAG_NONE;
15651568
const DISABLE_TRIANGLE_FACE_CULLING = sys::OptixInstanceFlags_OPTIX_INSTANCE_FLAG_DISABLE_TRIANGLE_FACE_CULLING;
15661569
const FLIP_TRIANGLE_FACING = sys::OptixInstanceFlags_OPTIX_INSTANCE_FLAG_FLIP_TRIANGLE_FACING;

crates/optix/src/pipeline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ cfg_if::cfg_if! {
208208
}
209209

210210
bitflags::bitflags! {
211-
#[derive(Default)]
211+
#[derive(Default, Hash, Clone, Copy, PartialEq, Eq, Debug)]
212212
pub struct TraversableGraphFlags: OptixEnumBaseType {
213213
const ALLOW_ANY = sys::OptixTraversableGraphFlags::OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_ANY;
214214
const ALLOW_SINGLE_GAS = sys::OptixTraversableGraphFlags::OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_SINGLE_GAS;
@@ -217,7 +217,7 @@ bitflags::bitflags! {
217217
}
218218

219219
bitflags::bitflags! {
220-
#[derive(Default)]
220+
#[derive(Default, Hash, Clone, Copy, PartialEq, Eq, Debug)]
221221
pub struct ExceptionFlags: OptixEnumBaseType {
222222
const NONE = sys::OptixExceptionFlags::OPTIX_EXCEPTION_FLAG_NONE;
223223
const STACK_OVERFLOW = sys::OptixExceptionFlags::OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW;
@@ -228,7 +228,7 @@ bitflags::bitflags! {
228228
}
229229

230230
bitflags::bitflags! {
231-
#[derive(Default)]
231+
#[derive(Default, Hash, Clone, Copy, PartialEq, Eq, Debug)]
232232
pub struct PrimitiveTypeFlags: i32 {
233233
const DEFAULT = 0;
234234
const CUSTOM = sys::OptixPrimitiveTypeFlags_OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM;

0 commit comments

Comments
 (0)