Skip to content

Fix build errors caused by optix-sys #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions crates/optix/src/acceleration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl Accel {
/// If this acceleration structure is copied multiple times, the same
/// [`AccelRelocationInfo`] can also be used on all copies.
pub fn get_relocation_info(&self, ctx: &DeviceContext) -> Result<AccelRelocationInfo> {
let mut inner = optix_sys::OptixAccelRelocationInfo::default();
let mut inner = optix_sys::OptixRelocationInfo::default();
unsafe {
Ok(optix_call!(optixAccelGetRelocationInfo(
ctx.raw,
Expand Down Expand Up @@ -828,7 +828,7 @@ impl AccelBuildOptions {
#[repr(transparent)]
pub struct AccelRelocationInfo {
#[allow(dead_code)]
inner: optix_sys::OptixAccelRelocationInfo,
inner: optix_sys::OptixRelocationInfo,
}

/// Struct used for OptiX to communicate the necessary buffer sizes for accel
Expand Down Expand Up @@ -1096,6 +1096,7 @@ impl BuildInput for CurveArray<'_, '_, '_> {
indexStrideInBytes: self.index_stride_in_bytes,
flag: self.flags as u32,
primitiveIndexOffset: self.primitive_index_offset,
endcapFlags: optix_sys::OptixCurveEndcapFlags::OPTIX_CURVE_ENDCAP_DEFAULT as u32,
};
};
v
Expand Down Expand Up @@ -1328,6 +1329,8 @@ impl<V: Vertex> BuildInput for TriangleArray<'_, '_, V> {
} else {
optix_sys::OptixTransformFormat::OPTIX_TRANSFORM_FORMAT_NONE
},
opacityMicromap: optix_sys::OptixBuildInputOpacityMicromap::default(),
displacementMicromap: optix_sys::OptixBuildInputDisplacementMicromap::default(),
};
};
v
Expand Down Expand Up @@ -1414,6 +1417,8 @@ impl<V: Vertex, I: IndexTriple> BuildInput for IndexedTriangleArray<'_, '_, V, I
} else {
optix_sys::OptixTransformFormat::OPTIX_TRANSFORM_FORMAT_NONE
},
opacityMicromap: optix_sys::OptixBuildInputOpacityMicromap::default(),
displacementMicromap: optix_sys::OptixBuildInputDisplacementMicromap::default(),
};
};
v
Expand Down Expand Up @@ -1563,7 +1568,8 @@ bitflags::bitflags! {
const FLIP_TRIANGLE_FACING = optix_sys::OptixInstanceFlags::OPTIX_INSTANCE_FLAG_FLIP_TRIANGLE_FACING as i32;
const DISABLE_ANYHIT = optix_sys::OptixInstanceFlags::OPTIX_INSTANCE_FLAG_DISABLE_ANYHIT as i32;
const ENFORCE_ANYHIT = optix_sys::OptixInstanceFlags::OPTIX_INSTANCE_FLAG_ENFORCE_ANYHIT as i32;
const DISABLE_TRANSFORM = optix_sys::OptixInstanceFlags::OPTIX_INSTANCE_FLAG_DISABLE_TRANSFORM as i32;
const FORCE_OPACITY_MICROMAP_2_STATE = optix_sys::OptixInstanceFlags::OPTIX_INSTANCE_FLAG_FORCE_OPACITY_MICROMAP_2_STATE as i32;
const DISABLE_OPACITY_MICROMAPS = optix_sys::OptixInstanceFlags::OPTIX_INSTANCE_FLAG_DISABLE_OPACITY_MICROMAPS as i32;
}
}

Expand Down Expand Up @@ -1656,10 +1662,7 @@ impl BuildInput for InstanceArray<'_, '_> {
*v.__bindgen_anon_1.instanceArray.as_mut() = optix_sys::OptixBuildInputInstanceArray {
instances: self.instances.as_device_ptr().as_raw(),
numInstances: self.instances.len() as u32,
#[cfg(optix_build_input_instance_array_aabbs)]
aabbs: 0,
#[cfg(optix_build_input_instance_array_aabbs)]
numAabbs: 0,
instanceStride: 0,
};
};
v
Expand Down Expand Up @@ -1692,10 +1695,7 @@ impl BuildInput for InstancePointerArray<'_> {
*v.__bindgen_anon_1.instanceArray.as_mut() = optix_sys::OptixBuildInputInstanceArray {
instances: self.instances.as_device_ptr().as_raw(),
numInstances: self.instances.len() as u32,
#[cfg(optix_build_input_instance_array_aabbs)]
aabbs: 0,
#[cfg(optix_build_input_instance_array_aabbs)]
numAabbs: 0,
instanceStride: 0,
};
};
v
Expand Down
7 changes: 6 additions & 1 deletion crates/optix/src/denoiser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl DenoiserOptions {
optix_sys::OptixDenoiserOptions {
guideAlbedo: self.guide_albedo as u32,
guideNormal: self.guide_normal as u32,
denoiseAlpha: optix_sys::OptixDenoiserAlphaMode::OPTIX_DENOISER_ALPHA_MODE_COPY,
}
}
}
Expand Down Expand Up @@ -376,6 +377,7 @@ impl Denoiser {
out.data = out_buffer.as_device_ptr().as_raw();

let layer = optix_sys::OptixDenoiserLayer {
type_: optix_sys::OptixDenoiserAOVType::OPTIX_DENOISER_AOV_TYPE_BEAUTY,
input: input_image.to_raw(),
previousOutput: null_optix_image(),
output: out,
Expand Down Expand Up @@ -423,7 +425,6 @@ pub struct DenoiserParams<'a> {
impl DenoiserParams<'_> {
pub fn to_raw(self) -> optix_sys::OptixDenoiserParams {
optix_sys::OptixDenoiserParams {
denoiseAlpha: self.denoise_alpha as u32,
hdrIntensity: self
.hdr_intensity
.map(|x| x.as_device_ptr().as_raw())
Expand All @@ -433,6 +434,7 @@ impl DenoiserParams<'_> {
.map(|x| x.as_device_ptr().as_raw())
.unwrap_or_default(),
blendFactor: self.blend_factor,
temporalModeUsePreviousLayers: 0,
}
}
}
Expand Down Expand Up @@ -471,6 +473,9 @@ impl DenoiserGuideImages<'_> {
.flow
.map(|i| i.to_raw())
.unwrap_or_else(null_optix_image),
previousOutputInternalGuideLayer: null_optix_image(),
outputInternalGuideLayer: null_optix_image(),
flowTrustworthiness: null_optix_image(),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/optix/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl OptixError {
InvalidDeviceContext => optix_sys::OptixResult::OPTIX_ERROR_INVALID_DEVICE_CONTEXT,
CudaNotInitialized => optix_sys::OptixResult::OPTIX_ERROR_CUDA_NOT_INITIALIZED,
ValidationFailure => optix_sys::OptixResult::OPTIX_ERROR_VALIDATION_FAILURE,
InvalidPtx => optix_sys::OptixResult::OPTIX_ERROR_INVALID_PTX,
InvalidPtx => optix_sys::OptixResult::OPTIX_ERROR_INVALID_INPUT,
InvalidLaunchParameter => optix_sys::OptixResult::OPTIX_ERROR_INVALID_LAUNCH_PARAMETER,
InvalidPayloadAccess => optix_sys::OptixResult::OPTIX_ERROR_INVALID_PAYLOAD_ACCESS,
InvalidAttributeAccess => optix_sys::OptixResult::OPTIX_ERROR_INVALID_ATTRIBUTE_ACCESS,
Expand All @@ -88,7 +88,7 @@ impl OptixError {
InternalCompilerError => optix_sys::OptixResult::OPTIX_ERROR_INTERNAL_COMPILER_ERROR,
DenoiserModelNotSet => optix_sys::OptixResult::OPTIX_ERROR_DENOISER_MODEL_NOT_SET,
DenoiserNotInitialized => optix_sys::OptixResult::OPTIX_ERROR_DENOISER_NOT_INITIALIZED,
AccelNotCompatible => optix_sys::OptixResult::OPTIX_ERROR_ACCEL_NOT_COMPATIBLE,
AccelNotCompatible => optix_sys::OptixResult::OPTIX_ERROR_NOT_COMPATIBLE,
NotSupported => optix_sys::OptixResult::OPTIX_ERROR_NOT_SUPPORTED,
UnsupportedAbiVersion => optix_sys::OptixResult::OPTIX_ERROR_UNSUPPORTED_ABI_VERSION,
FunctionTableSizeMismatch => {
Expand Down Expand Up @@ -165,7 +165,7 @@ impl ToResult for optix_sys::OptixResult {
optix_sys::OptixResult::OPTIX_ERROR_INVALID_DEVICE_CONTEXT => InvalidDeviceContext,
optix_sys::OptixResult::OPTIX_ERROR_CUDA_NOT_INITIALIZED => CudaNotInitialized,
optix_sys::OptixResult::OPTIX_ERROR_VALIDATION_FAILURE => ValidationFailure,
optix_sys::OptixResult::OPTIX_ERROR_INVALID_PTX => InvalidPtx,
optix_sys::OptixResult::OPTIX_ERROR_INVALID_INPUT => InvalidPtx,
optix_sys::OptixResult::OPTIX_ERROR_INVALID_LAUNCH_PARAMETER => InvalidLaunchParameter,
optix_sys::OptixResult::OPTIX_ERROR_INVALID_PAYLOAD_ACCESS => InvalidPayloadAccess,
optix_sys::OptixResult::OPTIX_ERROR_INVALID_ATTRIBUTE_ACCESS => InvalidAttributeAccess,
Expand All @@ -183,7 +183,7 @@ impl ToResult for optix_sys::OptixResult {
optix_sys::OptixResult::OPTIX_ERROR_INTERNAL_COMPILER_ERROR => InternalCompilerError,
optix_sys::OptixResult::OPTIX_ERROR_DENOISER_MODEL_NOT_SET => DenoiserModelNotSet,
optix_sys::OptixResult::OPTIX_ERROR_DENOISER_NOT_INITIALIZED => DenoiserNotInitialized,
optix_sys::OptixResult::OPTIX_ERROR_ACCEL_NOT_COMPATIBLE => AccelNotCompatible,
optix_sys::OptixResult::OPTIX_ERROR_NOT_COMPATIBLE => AccelNotCompatible,
optix_sys::OptixResult::OPTIX_ERROR_NOT_SUPPORTED => NotSupported,
optix_sys::OptixResult::OPTIX_ERROR_UNSUPPORTED_ABI_VERSION => UnsupportedAbiVersion,
optix_sys::OptixResult::OPTIX_ERROR_FUNCTION_TABLE_SIZE_MISMATCH => {
Expand Down
4 changes: 3 additions & 1 deletion crates/optix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ pub fn optix_is_initialized() -> bool {
}

extern "C" {
pub(crate) static g_optixFunctionTable: optix_sys::OptixFunctionTable;
pub(crate) static g_optixFunctionTable_105: optix_sys::OptixFunctionTable;
}
#[allow(non_upper_case_globals)]
pub(crate) use g_optixFunctionTable_105 as g_optixFunctionTable;

/// Call a raw OptiX sys function, making sure that OptiX is initialized. Returning
/// an OptixNotInitialized error if it is not initialized. See [`optix_is_initialized`].
Expand Down
31 changes: 14 additions & 17 deletions crates/optix/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ impl From<PipelineLinkOptions> for optix_sys::OptixPipelineLinkOptions {
fn from(o: PipelineLinkOptions) -> Self {
optix_sys::OptixPipelineLinkOptions {
maxTraceDepth: o.max_trace_depth,
debugLevel: o.debug_level as _,
}
}
}
Expand Down Expand Up @@ -143,7 +142,7 @@ pub enum CompileOptimizationLevel {
pub enum CompileDebugLevel {
#[default]
None = optix_sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_NONE as i32,
LineInfo = optix_sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO as i32,
LineInfo = optix_sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_MINIMAL as i32,
Full = optix_sys::OptixCompileDebugLevel::OPTIX_COMPILE_DEBUG_LEVEL_FULL as i32,
}

Expand All @@ -165,12 +164,16 @@ impl From<&ModuleCompileOptions> for optix_sys::OptixModuleCompileOptions {
debugLevel: o.debug_level as _,
boundValues: std::ptr::null(),
numBoundValues: 0,
numPayloadTypes: 0,
payloadTypes: std::ptr::null(),
}
} else {
optix_sys::OptixModuleCompileOptions {
maxRegisterCount: o.max_register_count,
optLevel: o.opt_level as _,
debugLevel: o.debug_level as _,
numPayloadTypes: 0,
payloadTypes: std::ptr::null(),
}
}
}
Expand All @@ -193,7 +196,6 @@ bitflags::bitflags! {
const STACK_OVERFLOW = optix_sys::OptixExceptionFlags::OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW as i32;
const TRACE_DEPTH = optix_sys::OptixExceptionFlags::OPTIX_EXCEPTION_FLAG_TRACE_DEPTH as i32;
const USER = optix_sys::OptixExceptionFlags::OPTIX_EXCEPTION_FLAG_USER as i32;
const DEBUG = optix_sys::OptixExceptionFlags::OPTIX_EXCEPTION_FLAG_DEBUG as i32;
}
}

Expand Down Expand Up @@ -260,10 +262,8 @@ impl PipelineCompileOptions {
std::ptr::null()
},
usesPrimitiveTypeFlags: self.primitive_type_flags.bits() as u32,
#[cfg(optix_pipeline_compile_options_reserved)]
reserved: 0,
#[cfg(optix_pipeline_compile_options_reserved)]
reserved2: 0,
allowOpacityMicromaps: 0,
allowClusteredGeometry: 0,
}
}

Expand Down Expand Up @@ -317,7 +317,7 @@ impl Module {

let mut raw = std::ptr::null_mut();
let res = unsafe {
optix_call!(optixModuleCreateFromPTX(
optix_call!(optixModuleCreate(
ctx.raw,
&mopt as *const _,
&popt,
Expand Down Expand Up @@ -363,6 +363,8 @@ impl Module {
PrimitiveType::Triangle => OPTIX_PRIMITIVE_TYPE_TRIANGLE,
},
usesMotionBlur: if uses_motion_blur { 1 } else { 0 },
buildFlags: 0,
curveEndcapFlags: 0,
};

let mut raw = std::ptr::null_mut();
Expand Down Expand Up @@ -501,7 +503,8 @@ impl ProgramGroup {
unsafe {
Ok(optix_call!(optixProgramGroupGetStackSize(
self.raw,
&mut stack_sizes as *mut _ as *mut _
&mut stack_sizes as *mut _ as *mut _,
std::ptr::null_mut()
))
.map(|_| stack_sizes)?)
}
Expand All @@ -523,10 +526,7 @@ impl ProgramGroup {
desc: &[ProgramGroupDesc],
) -> Result<(Vec<ProgramGroup>, String)> {
let pg_options = optix_sys::OptixProgramGroupOptions {
#[cfg(optix_program_group_options_reserved)]
reserved: 0,
#[cfg(not(optix_program_group_options_reserved))]
placeholder: 0,
payloadType: std::ptr::null(),
};

let mut log = [0u8; 4096];
Expand Down Expand Up @@ -569,10 +569,7 @@ impl ProgramGroup {
desc: &ProgramGroupDesc,
) -> Result<(ProgramGroup, String)> {
let pg_options = optix_sys::OptixProgramGroupOptions {
#[cfg(optix_program_group_options_reserved)]
reserved: 0,
#[cfg(not(optix_program_group_options_reserved))]
placeholder: 0,
payloadType: std::ptr::null(),
};

let mut log = [0u8; 4096];
Expand Down
Loading