From 9e7c1bff629f9f5a964fa2f83e70ff7a65cdb957 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 27 Dec 2021 23:52:23 +0100 Subject: [PATCH 1/5] Release ash 0.35 and ash-window 0.9 without default compile-time linking (#529) --- Changelog.md | 7 +++++-- ash-window/Cargo.toml | 4 ++-- ash-window/Changelog.md | 10 ++++++++++ ash-window/README.md | 5 ++--- ash/Cargo.toml | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Changelog.md b/Changelog.md index 62ced5bf7..2da459c94 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [Unreleased] - ReleaseDate + +## [0.35.0] - 2021-12-27 ### Changed @@ -258,7 +260,8 @@ flags: vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER_BIT, can write to aligned memory. -[Unreleased]: https://github.com/MaikKlein/ash/compare/0.34.0...HEAD +[Unreleased]: https://github.com/MaikKlein/ash/compare/0.35.0...HEAD +[0.35.0]: https://github.com/MaikKlein/ash/releases/tag/0.35.0 [0.34.0]: https://github.com/MaikKlein/ash/releases/tag/0.34.0 [0.33.3]: https://github.com/MaikKlein/ash/releases/tag/0.33.3 [0.33.2]: https://github.com/MaikKlein/ash/releases/tag/0.33.2 diff --git a/ash-window/Cargo.toml b/ash-window/Cargo.toml index 4dbb60f3d..3eb3499fb 100644 --- a/ash-window/Cargo.toml +++ b/ash-window/Cargo.toml @@ -14,7 +14,7 @@ exclude = [".github/*"] workspace = ".." [dependencies] -ash = { path = "../ash", version = "0.34", default-features = false } +ash = { path = "../ash", version = "0.35", default-features = false } raw-window-handle = "0.3" [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] @@ -22,7 +22,7 @@ raw-window-metal = "0.1" [dev-dependencies] winit = "0.19.4" -ash = { path = "../ash", version = "0.34", default-features = false, features = ["linked"] } +ash = { path = "../ash", version = "0.35", default-features = false, features = ["linked"] } [[example]] name = "winit" diff --git a/ash-window/Changelog.md b/ash-window/Changelog.md index ce5d96806..1ca08d797 100644 --- a/ash-window/Changelog.md +++ b/ash-window/Changelog.md @@ -1,5 +1,13 @@ ### Changelog +## [Unreleased] - ReleaseDate + +## [0.9.0] - 2021-12-27 + +### Changed + +- Bumped `ash` version to [`0.35`](https://github.com/MaikKlein/ash/releases/tag/0.35.0) + ## [0.8.0] - 2021-12-22 ### Changed @@ -49,6 +57,8 @@ ## Version 0.1.0 Initial release for `raw-window-handle = "0.3"` with Windows, Linux, Android, MacOS/iOS support. +[Unreleased]: https://github.com/MaikKlein/ash/compare/ash-window-0.9.0...HEAD +[0.9.0]: https://github.com/MaikKlein/ash/releases/tag/ash-window-0.9.0 [0.8.0]: https://github.com/MaikKlein/ash/releases/tag/ash-window-0.8.0 [0.7.0]: https://github.com/MaikKlein/ash/releases/tag/ash-window-0.7.0 [0.6.0]: https://github.com/MaikKlein/ash/releases/tag/ash-window-0.6.0 diff --git a/ash-window/README.md b/ash-window/README.md index f05a46621..7d4cf61c2 100644 --- a/ash-window/README.md +++ b/ash-window/README.md @@ -14,7 +14,7 @@ Interoperability between [`ash`](https://github.com/MaikKlein/ash) and [`raw-win ## Usage ```toml -ash-window = "0.7" +ash-window = "0.9" ``` The library exposes two functions: @@ -33,8 +33,7 @@ The library exposes two functions: ## Versions ```toml -ash = "0.33" -raw-window-handle = "0.3" +ash = "0.35" ``` ## Support diff --git a/ash/Cargo.toml b/ash/Cargo.toml index 9cc9c4f7f..86c827cc7 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ash" -version = "0.34.0+1.2.203" +version = "0.35.0+1.2.203" authors = ["maik klein "] description = "Vulkan bindings for Rust" license = "MIT" From ab36e84bac7e22a12e37410b25564bfcf1a9f1ca Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 27 Dec 2021 23:54:09 +0100 Subject: [PATCH 2/5] ash-window: Bump to 0.9.0 This change missed out from 9e7c1bff629f9f5a964fa2f83e70ff7a65cdb957. --- ash-window/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ash-window/Cargo.toml b/ash-window/Cargo.toml index 3eb3499fb..dbc29c0cf 100644 --- a/ash-window/Cargo.toml +++ b/ash-window/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ash-window" -version = "0.8.0" +version = "0.9.0" authors = ["msiglreith "] edition = "2018" license = "MIT OR Apache-2.0" From 57303f52dc4820d1f1939c75ccb8c39da3625685 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 28 Dec 2021 00:11:22 +0100 Subject: [PATCH 3/5] 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. --- ash/src/extensions/experimental/amd.rs | 68 +++++++++++++------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/ash/src/extensions/experimental/amd.rs b/ash/src/extensions/experimental/amd.rs index c39c5a777..818e98412 100644 --- a/ash/src/extensions/experimental/amd.rs +++ b/ash/src/extensions/experimental/amd.rs @@ -409,9 +409,9 @@ impl AmdGpaInterfaceFn { stringify!(create_gpa_session_amd) )) } - let raw_name = stringify!(vkCreateGpaSessionAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCreateGpaSessionAMD\0"); + let val = _f(cname); if val.is_null() { create_gpa_session_amd } else { @@ -429,9 +429,9 @@ impl AmdGpaInterfaceFn { stringify!(destroy_gpa_session_amd) )) } - let raw_name = stringify!(vkDestroyGpaSessionAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkDestroyGpaSessionAMD\0"); + let val = _f(cname); if val.is_null() { destroy_gpa_session_amd } else { @@ -448,9 +448,10 @@ impl AmdGpaInterfaceFn { stringify!(set_gpa_device_clock_mode_amd) )) } - let raw_name = stringify!(vkSetGpaDeviceClockModeAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked( + b"vkSetGpaDeviceClockModeAMD\0", + ); + let val = _f(cname); if val.is_null() { set_gpa_device_clock_mode_amd } else { @@ -467,9 +468,9 @@ impl AmdGpaInterfaceFn { stringify!(cmd_begin_gpa_session_amd) )) } - let raw_name = stringify!(vkCmdBeginGpaSessionAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdBeginGpaSessionAMD\0"); + let val = _f(cname); if val.is_null() { cmd_begin_gpa_session_amd } else { @@ -486,9 +487,9 @@ impl AmdGpaInterfaceFn { stringify!(cmd_end_gpa_session_amd) )) } - let raw_name = stringify!(vkCmdEndGpaSessionAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSessionAMD\0"); + let val = _f(cname); if val.is_null() { cmd_end_gpa_session_amd } else { @@ -507,9 +508,9 @@ impl AmdGpaInterfaceFn { stringify!(cmd_begin_gpa_sample_amd) )) } - let raw_name = stringify!(vkCmdBeginGpaSampleAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdBeginGpaSampleAMD\0"); + let val = _f(cname); if val.is_null() { cmd_begin_gpa_sample_amd } else { @@ -527,9 +528,9 @@ impl AmdGpaInterfaceFn { stringify!(cmd_end_gpa_sample_amd) )) } - let raw_name = stringify!(vkCmdEndGpaSampleAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSampleAMD\0"); + let val = _f(cname); if val.is_null() { cmd_end_gpa_sample_amd } else { @@ -546,9 +547,9 @@ impl AmdGpaInterfaceFn { stringify!(get_gpa_session_status_amd) )) } - let raw_name = stringify!(vkGetGpaSessionStatusAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkGetGpaSessionStatusAMD\0"); + let val = _f(cname); if val.is_null() { get_gpa_session_status_amd } else { @@ -568,9 +569,9 @@ impl AmdGpaInterfaceFn { stringify!(get_gpa_session_results_amd) )) } - let raw_name = stringify!(vkGetGpaSessionResultsAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkGetGpaSessionResultsAMD\0"); + let val = _f(cname); if val.is_null() { get_gpa_session_results_amd } else { @@ -587,9 +588,9 @@ impl AmdGpaInterfaceFn { stringify!(reset_gpa_session_amd) )) } - let raw_name = stringify!(vkCmdEndGpaSampleAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSampleAMD\0"); + let val = _f(cname); if val.is_null() { reset_gpa_session_amd } else { @@ -606,9 +607,10 @@ impl AmdGpaInterfaceFn { stringify!(cmd_copy_gpa_session_results_amd) )) } - let raw_name = stringify!(vkCmdCopyGpaSessionResultsAMD); - let cname = ::std::ffi::CString::new(raw_name).unwrap(); - let val = _f(&cname); + let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked( + b"vkCmdCopyGpaSessionResultsAMD\0", + ); + let val = _f(cname); if val.is_null() { cmd_copy_gpa_session_results_amd } else { From afdab863d0c2b2480a3a2136245262e906824bc4 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 28 Dec 2021 00:14:56 +0100 Subject: [PATCH 4/5] examples: Remove remaining CString allocations on string literals These allocations and runtime assertions can all be replaced with a `CStr` directly wrapping a binary-string literal, as long as it is null-terminated. --- examples/src/bin/texture.rs | 4 ++-- examples/src/bin/triangle.rs | 4 ++-- examples/src/lib.rs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index e4ab27ecb..cdfd5998c 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -1,5 +1,5 @@ use std::default::Default; -use std::ffi::CString; +use std::ffi::CStr; use std::io::Cursor; use std::mem::{self, align_of}; use std::os::raw::c_void; @@ -573,7 +573,7 @@ fn main() { .create_pipeline_layout(&layout_create_info, None) .unwrap(); - let shader_entry_name = CString::new("main").unwrap(); + let shader_entry_name = CStr::from_bytes_with_nul_unchecked(b"main\0"); let shader_stage_create_infos = [ vk::PipelineShaderStageCreateInfo { module: vertex_shader_module, diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index cc322fc69..1b6e6ff42 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -2,7 +2,7 @@ use ash::util::*; use ash::vk; use examples::*; use std::default::Default; -use std::ffi::CString; +use std::ffi::CStr; use std::io::Cursor; use std::mem; use std::mem::align_of; @@ -226,7 +226,7 @@ fn main() { .create_pipeline_layout(&layout_create_info, None) .unwrap(); - let shader_entry_name = CString::new("main").unwrap(); + let shader_entry_name = CStr::from_bytes_with_nul_unchecked(b"main\0"); let shader_stage_create_infos = [ vk::PipelineShaderStageCreateInfo { module: vertex_shader_module, diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 1142e1e47..ab087e949 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -11,7 +11,7 @@ pub use ash::{Device, Instance}; use std::borrow::Cow; use std::cell::RefCell; use std::default::Default; -use std::ffi::{CStr, CString}; +use std::ffi::CStr; use std::ops::Drop; use std::os::raw::c_char; @@ -218,7 +218,7 @@ impl ExampleBase { .build(&event_loop) .unwrap(); let entry = Entry::linked(); - let app_name = CString::new("VulkanTriangle").unwrap(); + let app_name = CStr::from_bytes_with_nul_unchecked(b"VulkanTriangle\0"); let layer_names = [CStr::from_bytes_with_nul_unchecked( b"VK_LAYER_KHRONOS_validation\0", @@ -236,9 +236,9 @@ impl ExampleBase { extension_names_raw.push(DebugUtils::name().as_ptr()); let appinfo = vk::ApplicationInfo::builder() - .application_name(&app_name) + .application_name(app_name) .application_version(0) - .engine_name(&app_name) + .engine_name(app_name) .engine_version(0) .api_version(vk::make_api_version(0, 1, 0, 0)); From 8a46a1508a5eb9c1157435b25d723b26db2a8f23 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 28 Dec 2021 19:14:19 +0100 Subject: [PATCH 5/5] Generate `RGBA=R|G|B|A` helper constant for `ColorComponentFlags` When the misleading `all()` function was removed in #478 it also made all color components for `ColorComponentFlags` significantly more verbose to write, see #536. --- ash/src/vk/prelude.rs | 5 +++++ examples/src/bin/texture.rs | 5 +---- examples/src/bin/triangle.rs | 5 +---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ash/src/vk/prelude.rs b/ash/src/vk/prelude.rs index f873937c0..f62b60e5c 100644 --- a/ash/src/vk/prelude.rs +++ b/ash/src/vk/prelude.rs @@ -26,3 +26,8 @@ impl Packed24_8 { (self.0 >> 24) as u8 } } + +impl super::ColorComponentFlags { + /// Contraction of [`Self::R`] | [`Self::G`] | [`Self::B`] | [`Self::A`] + pub const RGBA: Self = Self(Self::R.0 | Self::G.0 | Self::B.0 | Self::A.0); +} diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index cdfd5998c..2107849b9 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -666,10 +666,7 @@ fn main() { src_alpha_blend_factor: vk::BlendFactor::ZERO, dst_alpha_blend_factor: vk::BlendFactor::ZERO, alpha_blend_op: vk::BlendOp::ADD, - color_write_mask: vk::ColorComponentFlags::R - | vk::ColorComponentFlags::G - | vk::ColorComponentFlags::B - | vk::ColorComponentFlags::A, + color_write_mask: vk::ColorComponentFlags::RGBA, }]; let color_blend_state = vk::PipelineColorBlendStateCreateInfo::builder() .logic_op(vk::LogicOp::CLEAR) diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index 1b6e6ff42..7b4b924ea 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -319,10 +319,7 @@ fn main() { src_alpha_blend_factor: vk::BlendFactor::ZERO, dst_alpha_blend_factor: vk::BlendFactor::ZERO, alpha_blend_op: vk::BlendOp::ADD, - color_write_mask: vk::ColorComponentFlags::R - | vk::ColorComponentFlags::G - | vk::ColorComponentFlags::B - | vk::ColorComponentFlags::A, + color_write_mask: vk::ColorComponentFlags::RGBA, }]; let color_blend_state = vk::PipelineColorBlendStateCreateInfo::builder() .logic_op(vk::LogicOp::CLEAR)