Fix rustc warnings

This commit is contained in:
Martin Krošlák 2020-01-22 06:51:33 +01:00
parent 988fb7547c
commit 6ad83bed4c
2 changed files with 24 additions and 17 deletions

View file

@ -37,7 +37,7 @@ impl<T> HandleAllocation<T> {
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
{ {
use std::intrinsics::type_name; use std::intrinsics::type_name;
let name = unsafe { type_name::<T>() }; let name = type_name::<T>();
REGISTRY.lock().unwrap().insert(ptr as _, name); REGISTRY.lock().unwrap().insert(ptr as _, name);
} }
Handle(ptr) Handle(ptr)

View file

@ -62,6 +62,8 @@ pub extern "C" fn gfxCreateInstance(
let _ = env_logger::try_init(); let _ = env_logger::try_init();
} }
#[allow(unused_mut)]
// Metal branch performs mutation, so we silence the warning on other backends.
let mut backend = let mut backend =
back::Instance::create("portability", 1).expect("failed to create backend instance"); back::Instance::create("portability", 1).expect("failed to create backend instance");
@ -2074,13 +2076,11 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
}; };
let shaders = { let shaders = {
let mut set = pso::GraphicsShaderSet { let mut vertex = mem::MaybeUninit::uninit();
vertex: unsafe { mem::zeroed() }, // fake entry point let mut hull = None;
hull: None, let mut domain = None;
domain: None, let mut geometry = None;
geometry: None, let mut fragment = None;
fragment: None,
};
let stages = unsafe { slice::from_raw_parts(info.pStages, info.stageCount as _) }; let stages = unsafe { slice::from_raw_parts(info.pStages, info.stageCount as _) };
@ -2109,26 +2109,31 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
match stage.stage { match stage.stage {
VK_SHADER_STAGE_VERTEX_BIT => { VK_SHADER_STAGE_VERTEX_BIT => {
let fake_vs_entry = mem::replace(&mut set.vertex, entry_point); vertex = mem::MaybeUninit::new(entry_point);
mem::forget(fake_vs_entry);
} }
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT => { VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT => {
set.hull = Some(entry_point); hull = Some(entry_point);
} }
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT => { VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT => {
set.domain = Some(entry_point); domain = Some(entry_point);
} }
VK_SHADER_STAGE_GEOMETRY_BIT => { VK_SHADER_STAGE_GEOMETRY_BIT => {
set.geometry = Some(entry_point); geometry = Some(entry_point);
} }
VK_SHADER_STAGE_FRAGMENT_BIT if !rasterizer_discard => { VK_SHADER_STAGE_FRAGMENT_BIT if !rasterizer_discard => {
set.fragment = Some(entry_point); fragment = Some(entry_point);
} }
stage => panic!("Unexpected shader stage: {:?}", stage), stage => panic!("Unexpected shader stage: {:?}", stage),
} }
} }
set pso::GraphicsShaderSet {
vertex: unsafe { vertex.assume_init() },
hull,
domain,
geometry,
fragment,
}
}; };
let (vertex_buffers, attributes) = { let (vertex_buffers, attributes) = {
@ -4413,8 +4418,8 @@ pub extern "C" fn gfxGetPhysicalDeviceSurfacePresentModesKHR(
#[inline] #[inline]
pub extern "C" fn gfxGetPhysicalDeviceWin32PresentationSupportKHR( pub extern "C" fn gfxGetPhysicalDeviceWin32PresentationSupportKHR(
adapter: VkPhysicalDevice, _adapter: VkPhysicalDevice,
queueFamilyIndex: u32, _queueFamilyIndex: u32,
) -> VkBool32 { ) -> VkBool32 {
VK_TRUE VK_TRUE
} }
@ -4443,6 +4448,8 @@ pub extern "C" fn gfxCreateSwapchainKHR(
image_layers: 1, image_layers: 1,
image_usage: conv::map_image_usage(info.imageUsage), image_usage: conv::map_image_usage(info.imageUsage),
}; };
#[allow(unused_mut)] // Metal branch performs mutation.
let (mut swapchain, backbuffers) = match unsafe { let (mut swapchain, backbuffers) = match unsafe {
gpu.device.create_swapchain( gpu.device.create_swapchain(
&mut info.surface.clone(), &mut info.surface.clone(),