extensions/amd: Remove unnecessary CString allocations in fn load

Following the changes in a053c6a ("Remove unnecessary CString allocation
when loading functions (#379)") this addresses the remainder of string
allocations in manual extension loading code.
This commit is contained in:
Marijn Suijten 2021-12-28 00:11:22 +01:00 committed by Benjamin Saunders
parent ab36e84bac
commit 57303f52dc

View file

@ -409,9 +409,9 @@ impl AmdGpaInterfaceFn {
stringify!(create_gpa_session_amd) stringify!(create_gpa_session_amd)
)) ))
} }
let raw_name = stringify!(vkCreateGpaSessionAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCreateGpaSessionAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
create_gpa_session_amd create_gpa_session_amd
} else { } else {
@ -429,9 +429,9 @@ impl AmdGpaInterfaceFn {
stringify!(destroy_gpa_session_amd) stringify!(destroy_gpa_session_amd)
)) ))
} }
let raw_name = stringify!(vkDestroyGpaSessionAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkDestroyGpaSessionAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
destroy_gpa_session_amd destroy_gpa_session_amd
} else { } else {
@ -448,9 +448,10 @@ impl AmdGpaInterfaceFn {
stringify!(set_gpa_device_clock_mode_amd) stringify!(set_gpa_device_clock_mode_amd)
)) ))
} }
let raw_name = stringify!(vkSetGpaDeviceClockModeAMD); let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked(
let cname = ::std::ffi::CString::new(raw_name).unwrap(); b"vkSetGpaDeviceClockModeAMD\0",
let val = _f(&cname); );
let val = _f(cname);
if val.is_null() { if val.is_null() {
set_gpa_device_clock_mode_amd set_gpa_device_clock_mode_amd
} else { } else {
@ -467,9 +468,9 @@ impl AmdGpaInterfaceFn {
stringify!(cmd_begin_gpa_session_amd) stringify!(cmd_begin_gpa_session_amd)
)) ))
} }
let raw_name = stringify!(vkCmdBeginGpaSessionAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdBeginGpaSessionAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
cmd_begin_gpa_session_amd cmd_begin_gpa_session_amd
} else { } else {
@ -486,9 +487,9 @@ impl AmdGpaInterfaceFn {
stringify!(cmd_end_gpa_session_amd) stringify!(cmd_end_gpa_session_amd)
)) ))
} }
let raw_name = stringify!(vkCmdEndGpaSessionAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSessionAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
cmd_end_gpa_session_amd cmd_end_gpa_session_amd
} else { } else {
@ -507,9 +508,9 @@ impl AmdGpaInterfaceFn {
stringify!(cmd_begin_gpa_sample_amd) stringify!(cmd_begin_gpa_sample_amd)
)) ))
} }
let raw_name = stringify!(vkCmdBeginGpaSampleAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdBeginGpaSampleAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
cmd_begin_gpa_sample_amd cmd_begin_gpa_sample_amd
} else { } else {
@ -527,9 +528,9 @@ impl AmdGpaInterfaceFn {
stringify!(cmd_end_gpa_sample_amd) stringify!(cmd_end_gpa_sample_amd)
)) ))
} }
let raw_name = stringify!(vkCmdEndGpaSampleAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSampleAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
cmd_end_gpa_sample_amd cmd_end_gpa_sample_amd
} else { } else {
@ -546,9 +547,9 @@ impl AmdGpaInterfaceFn {
stringify!(get_gpa_session_status_amd) stringify!(get_gpa_session_status_amd)
)) ))
} }
let raw_name = stringify!(vkGetGpaSessionStatusAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkGetGpaSessionStatusAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
get_gpa_session_status_amd get_gpa_session_status_amd
} else { } else {
@ -568,9 +569,9 @@ impl AmdGpaInterfaceFn {
stringify!(get_gpa_session_results_amd) stringify!(get_gpa_session_results_amd)
)) ))
} }
let raw_name = stringify!(vkGetGpaSessionResultsAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkGetGpaSessionResultsAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
get_gpa_session_results_amd get_gpa_session_results_amd
} else { } else {
@ -587,9 +588,9 @@ impl AmdGpaInterfaceFn {
stringify!(reset_gpa_session_amd) stringify!(reset_gpa_session_amd)
)) ))
} }
let raw_name = stringify!(vkCmdEndGpaSampleAMD); let cname =
let cname = ::std::ffi::CString::new(raw_name).unwrap(); ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSampleAMD\0");
let val = _f(&cname); let val = _f(cname);
if val.is_null() { if val.is_null() {
reset_gpa_session_amd reset_gpa_session_amd
} else { } else {
@ -606,9 +607,10 @@ impl AmdGpaInterfaceFn {
stringify!(cmd_copy_gpa_session_results_amd) stringify!(cmd_copy_gpa_session_results_amd)
)) ))
} }
let raw_name = stringify!(vkCmdCopyGpaSessionResultsAMD); let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked(
let cname = ::std::ffi::CString::new(raw_name).unwrap(); b"vkCmdCopyGpaSessionResultsAMD\0",
let val = _f(&cname); );
let val = _f(cname);
if val.is_null() { if val.is_null() {
cmd_copy_gpa_session_results_amd cmd_copy_gpa_session_results_amd
} else { } else {