Skip to content

Commit

Permalink
Add c'' string usage for vulkan
Browse files Browse the repository at this point in the history
  • Loading branch information
elftausend committed Aug 25, 2024
1 parent febdc36 commit 3d7ccb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ min-cl = { git = "https://github.com/elftausend/min-cl", optional = true }

[features]
# default = ["cpu", "opencl", "cuda", "blas", "static-api", "stack", "macro", "nnapi", "untyped", "autograd", "autograd", "cached", "lazy", "fork", "graph", "serde"]
default = ["cpu", "untyped", "lazy", "graph", "opencl", "cached", "autograd", "cuda"]
default = ["cpu", "untyped", "lazy", "graph", "cached", "autograd", "cuda", "vulkan"]
# default = ["opencl"]
# default = ["untyped", "cpu", "lazy", "graph", "autograd", "fork", "serde", "json", "half", "cached", "static-api", "stack", "opencl", "nnapi"]

Expand Down
14 changes: 3 additions & 11 deletions src/devices/vulkan/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ pub fn validation_layers<'a>() -> Vec<&'a CStr> {
.parse::<bool>()
.unwrap_or_default();

// TODO: rust 1.77 stabilized c"strings" (no unsafe, no null-termination)
if use_validation_layer {
unsafe {
vec![CStr::from_bytes_with_nul_unchecked(
b"VK_LAYER_KHRONOS_validation\0",
)]
}
vec![c"VK_LAYER_KHRONOS_validation"]
} else {
vec![]
}
Expand All @@ -48,7 +43,7 @@ impl Context {
#[inline]
pub fn new(device_idx: usize) -> crate::Result<Self> {
let entry = unsafe { Entry::load()? };
let app_name = unsafe { CStr::from_bytes_with_nul_unchecked(b"custos\0") };
let app_name = c"custos";
let app_info = vk::ApplicationInfo::default()
.application_name(app_name)
.application_version(0)
Expand All @@ -63,10 +58,7 @@ impl Context {
.map(|raw_name| raw_name.as_ptr())
.collect();

// TODO: rust 1.77 stabilized c"strings" (no unsafe, no null-termination)
let extensions = vec![unsafe {
CStr::from_bytes_with_nul_unchecked(b"VK_KHR_storage_buffer_storage_class\0")
}];
let extensions = vec![c"VK_KHR_storage_buffer_storage_class"];

let extensions_raw: Vec<*const c_char> = extensions
.iter()
Expand Down

0 comments on commit 3d7ccb5

Please sign in to comment.