Make sure it is possible to log 32bit PhysX (#374)

This commit is contained in:
Andrzej Janik
2025-07-08 19:19:49 +02:00
committed by GitHub
parent 9bd8125c53
commit 059b8ca0f6
12 changed files with 19 additions and 52 deletions

View File

@ -227,7 +227,7 @@ dark_api! {
[1] = get_module_from_cubin(
module: *mut cuda_types::cuda::CUmodule,
fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper
) -> (),
) -> cuda_types::cuda::CUresult,
[2] = cudart_interface_fn2(
pctx: *mut cuda_types::cuda::CUcontext,
dev: cuda_types::cuda::CUdevice

View File

@ -428,8 +428,9 @@ impl CudaDisplay for CUmemcpy3DOperand_st {
CudaDisplay::write(unsafe { &self.op.ptr }, fn_name, index, writer)?;
}
_ => {
const CU_MEMCPY_3D_OP_SIZE: usize = mem::size_of::<CUmemcpy3DOperand_st__bindgen_ty_1>();
CudaDisplay::write(
&unsafe { mem::transmute::<_, [u8; 32]>(self.op) },
&unsafe { mem::transmute::<_, [u8; CU_MEMCPY_3D_OP_SIZE]>(self.op) },
fn_name,
index,
writer,

View File

@ -500,7 +500,7 @@ macro_rules! dynamic_fns {
$(
#[allow(dead_code)]
unsafe fn $fn_name(&self, $($arg_id : $arg_type),*) -> Result<$ret_type, libloading::Error> {
let func = unsafe { self.lib.get::<unsafe extern "system" fn ($($arg_type),*) -> $ret_type>(concat!(stringify!($fn_name), "\0").as_bytes()) };
let func = unsafe { self.lib.get::<unsafe extern $abi fn ($($arg_type),*) -> $ret_type>(concat!(stringify!($fn_name), "\0").as_bytes()) };
func.map(|f| f($($arg_id),*) )
}
)*

View File

@ -106,7 +106,7 @@ impl ::dark_api::cuda::CudaDarkApi for DarkApi {
unsafe extern "system" fn get_module_from_cubin(
module: *mut cuda_types::cuda::CUmodule,
fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper,
) -> () {
) -> cuda_types::cuda::CUresult {
todo!()
}

View File

@ -286,7 +286,7 @@ impl DarkApiDump {
fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper,
state: &mut trace::StateTracker,
fn_logger: &mut FnCallLog,
_result: (),
_result: CUresult,
) {
fn_logger.try_(|fn_logger| unsafe {
trace::record_submodules_from_wrapped_fatbin(*module, fatbinc_wrapper, fn_logger, state)
@ -391,7 +391,7 @@ impl ::dark_api::cuda::CudaDarkApi for DarkApiDump {
[1] = get_module_from_cubin(
module: *mut cuda_types::cuda::CUmodule,
fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper // FatbincWrapper
) -> (),
) -> cuda_types::cuda::CUresult,
[6] = get_module_from_cubin_ext1(
result: *mut cuda_types::cuda::CUmodule,
fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper, // FatbincWrapper

View File

@ -380,7 +380,7 @@ impl Display for ErrorEntry {
observed,
} => write!(
f,
"Unexpected field {}. Expected one of: {{{}}}, observed: {}",
"Unexpected field {}. Expected one of: [{}], observed: {}",
field_name,
expected
.iter()

View File

@ -1,6 +1,6 @@
use cuda_types::cuda::{CUerror, CUresult, CUresultConsts, CUuuid};
use dark_api::ByteVecFfi;
use std::{num::NonZero, ptr, sync::LazyLock};
use std::{ffi::c_void, num::NonZero, ptr, sync::LazyLock};
pub fn get_export_table() -> Option<::dark_api::zluda_dump::ZludaDumpInternal> {
static CU_GET_EXPORT_TABLE: LazyLock<
@ -117,7 +117,7 @@ impl<T> ReprUsize for *const T {
extern "C" fn format_status(x: usize) -> ByteVecFfi {
let mut writer = Vec::new();
format::CudaDisplay::write(&x, "", 0, &mut writer).ok();
format::CudaDisplay::write(&Self::from_usize(x).cast::<c_void>(), "", 0, &mut writer).ok();
ByteVecFfi::new(writer)
}
}
@ -169,15 +169,9 @@ impl ReprUsize for () {
()
}
extern "C" fn format_status(x: usize) -> ByteVecFfi {
extern "C" fn format_status(_: usize) -> ByteVecFfi {
let mut writer = Vec::new();
format::CudaDisplay::write(
&cuda_types::cublas::cublasStatus_t::from_usize(x),
"",
0,
&mut writer,
)
.ok();
format::CudaDisplay::write(&(), "", 0, &mut writer).ok();
ByteVecFfi::new(writer)
}
}
@ -193,13 +187,7 @@ impl ReprUsize for u32 {
extern "C" fn format_status(x: usize) -> ByteVecFfi {
let mut writer = Vec::new();
format::CudaDisplay::write(
&cuda_types::cublas::cublasStatus_t::from_usize(x),
"",
0,
&mut writer,
)
.ok();
format::CudaDisplay::write(&Self::from_usize(x), "", 0, &mut writer).ok();
ByteVecFfi::new(writer)
}
}
@ -215,13 +203,7 @@ impl ReprUsize for i32 {
extern "C" fn format_status(x: usize) -> ByteVecFfi {
let mut writer = Vec::new();
format::CudaDisplay::write(
&cuda_types::cublas::cublasStatus_t::from_usize(x),
"",
0,
&mut writer,
)
.ok();
format::CudaDisplay::write(&Self::from_usize(x), "", 0, &mut writer).ok();
ByteVecFfi::new(writer)
}
}
@ -237,13 +219,7 @@ impl ReprUsize for u64 {
extern "C" fn format_status(x: usize) -> ByteVecFfi {
let mut writer = Vec::new();
format::CudaDisplay::write(
&cuda_types::cublas::cublasStatus_t::from_usize(x),
"",
0,
&mut writer,
)
.ok();
format::CudaDisplay::write(&Self::from_usize(x), "", 0, &mut writer).ok();
ByteVecFfi::new(writer)
}
}
@ -259,13 +235,7 @@ impl ReprUsize for *mut std::ffi::c_void {
extern "C" fn format_status(x: usize) -> ByteVecFfi {
let mut writer = Vec::new();
format::CudaDisplay::write(
&cuda_types::cublas::cublasStatus_t::from_usize(x),
"",
0,
&mut writer,
)
.ok();
format::CudaDisplay::write(&Self::from_usize(x), "", 0, &mut writer).ok();
ByteVecFfi::new(writer)
}
}

View File

@ -43,7 +43,6 @@ fn main() -> Result<(), VarError> {
rustc_cmd.arg(r"-lucrt");
}
rustc_cmd
.arg("-ldylib=nvcuda")
.arg("-C")
.arg(format!("opt-level={}", opt_level))
.arg("-L")

View File

@ -1,5 +1,6 @@
#![crate_type = "bin"]
#[link(name = "nvcuda", kind = "raw-dylib")]
extern "system" {
fn cuInit(flags: u32) -> u32;
}

View File

@ -1,5 +1,6 @@
#![crate_type = "cdylib"]
#[link(name = "nvcuda", kind = "raw-dylib")]
extern "system" {
fn cuInit(flags: u32) -> u32;
}

View File

@ -720,12 +720,7 @@ fn get_payload(guid: &detours_sys::GUID) -> Option<&'static [u8]> {
let mut size = 0;
let payload_ptr = unsafe { detours_sys::DetourFindPayloadEx(guid, &mut size) };
if payload_ptr != ptr::null_mut() {
Some(unsafe {
slice::from_raw_parts(
payload_ptr as *const _,
(size as usize) / mem::size_of::<u16>(),
)
})
Some(unsafe { slice::from_raw_parts(payload_ptr as *const _, size as usize) })
} else {
None
}