Merge pull request #227 from tomaka/asm-improve

Some improvements to the generated assembly
This commit is contained in:
tomaka 2016-08-21 08:37:02 +02:00 committed by GitHub
commit ea5ded8eb5
4 changed files with 21 additions and 8 deletions

View File

@ -10,11 +10,13 @@
use std::cmp;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::iter::Chain;
use std::marker::PhantomData;
use std::sync::Arc;
use std::sync::Mutex;
use std::vec::IntoIter as VecIntoIter;
use fnv::FnvHasher;
use command_buffer::pool::AllocatedCommandBuffer;
use command_buffer::pool::CommandPool;
@ -45,7 +47,7 @@ pub struct StandardCommandPool {
queue_family: u32,
// For each "thread id" (see `THREAD_ID` above), we store thread-specific info.
per_thread: Mutex<HashMap<usize, StandardCommandPoolPerThread>>,
per_thread: Mutex<HashMap<usize, StandardCommandPoolPerThread, BuildHasherDefault<FnvHasher>>>,
// Dummy marker in order to not implement `Send` and `Sync`.
//
@ -72,7 +74,7 @@ impl StandardCommandPool {
StandardCommandPool {
device: device.clone(),
queue_family: queue_family.id(),
per_thread: Mutex::new(HashMap::new()),
per_thread: Mutex::new(Default::default()),
dummy_avoid_send_sync: PhantomData,
}
}

View File

@ -648,6 +648,7 @@ impl<P> UnsafeCommandBufferBuilder<P> where P: CommandPool {
/// Adds a pipeline barrier to the command buffer.
///
/// This function itself is not unsafe, but creating a pipeline barrier builder is.
#[inline]
pub fn pipeline_barrier(&mut self, barrier: PipelineBarrierBuilder) {
// If barrier is empty, don't do anything.
if barrier.src_stage_mask == 0 || barrier.dst_stage_mask == 0 {
@ -1098,6 +1099,7 @@ pub struct PipelineBarrierBuilder {
impl PipelineBarrierBuilder {
/// Adds a command that adds a pipeline barrier to a command buffer.
#[inline]
pub fn new() -> PipelineBarrierBuilder {
PipelineBarrierBuilder {
src_stage_mask: 0,

View File

@ -16,6 +16,7 @@ use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::fmt;
use std::error;
use std::hash::BuildHasherDefault;
use std::mem;
use std::ptr;
use std::sync::Arc;
@ -23,6 +24,7 @@ use std::sync::Mutex;
use std::sync::MutexGuard;
use std::sync::Weak;
use smallvec::SmallVec;
use fnv::FnvHasher;
use command_buffer::pool::StandardCommandPool;
use instance::Features;
@ -49,7 +51,7 @@ pub struct Device {
device: vk::Device,
vk: vk::DevicePointers,
standard_pool: Mutex<Option<Weak<StdMemoryPool>>>, // TODO: use Weak::new() instead
standard_command_pools: Mutex<HashMap<u32, Weak<StandardCommandPool>>>, // TODO: use a better hasher
standard_command_pools: Mutex<HashMap<u32, Weak<StandardCommandPool>, BuildHasherDefault<FnvHasher>>>,
features: Features,
extensions: DeviceExtensions,
}
@ -198,7 +200,7 @@ impl Device {
device: device,
vk: vk,
standard_pool: Mutex::new(None),
standard_command_pools: Mutex::new(HashMap::new()),
standard_command_pools: Mutex::new(Default::default()),
features: requested_features.clone(),
extensions: extensions.clone(),
});

View File

@ -56,6 +56,16 @@ impl Instance {
pub fn new<'a, L>(app_infos: Option<&ApplicationInfo>, extensions: &InstanceExtensions,
layers: L) -> Result<Arc<Instance>, InstanceCreationError>
where L: IntoIterator<Item = &'a &'a str>
{
let layers = layers.into_iter().map(|&layer| {
CString::new(layer).unwrap()
}).collect::<SmallVec<[_; 16]>>();
Instance::new_inner(app_infos, extensions, layers)
}
fn new_inner(app_infos: Option<&ApplicationInfo>, extensions: &InstanceExtensions,
layers: SmallVec<[CString; 16]>) -> Result<Arc<Instance>, InstanceCreationError>
{
// TODO: For now there are still buggy drivers that will segfault if you don't pass any
// appinfos. Therefore for now we ensure that it can't be `None`.
@ -92,10 +102,7 @@ impl Instance {
None
};
let layers = layers.into_iter().map(|&layer| {
// FIXME: check whether each layer is supported
CString::new(layer).unwrap()
}).collect::<SmallVec<[_; 16]>>();
// FIXME: check whether each layer is supported
let layers_ptr = layers.iter().map(|layer| {
layer.as_ptr()
}).collect::<SmallVec<[_; 16]>>();