diff --git a/src/backend/dx12/src/command.rs b/src/backend/dx12/src/command.rs index 6e49e8c7f17..32937b724f7 100644 --- a/src/backend/dx12/src/command.rs +++ b/src/backend/dx12/src/command.rs @@ -1641,13 +1641,13 @@ impl com::RawCommandBuffer for CommandBuffer { { // Only cache the vertex buffer views as we don't know the stride (PSO). assert!(first_binding as usize <= MAX_VERTEX_BUFFERS); - for (&(buffer, offset), view) in buffers + for ((buffer, offset), view) in buffers .into_iter() .zip(self.vertex_buffer_views[first_binding as _..].iter_mut()) { let b = buffer.borrow(); let base = unsafe { (*b.resource).GetGPUVirtualAddress() }; - view.BufferLocation = base + offset as u64; + view.BufferLocation = base + offset; view.SizeInBytes = b.size_in_bytes - offset as u32; } } diff --git a/src/backend/metal/src/device.rs b/src/backend/metal/src/device.rs index 48f69ebe41b..96426050860 100644 --- a/src/backend/metal/src/device.rs +++ b/src/backend/metal/src/device.rs @@ -6,14 +6,13 @@ use {conversions as conv, command, native as n}; use native; use std::borrow::Borrow; -use std::collections::hash_map::{Entry, HashMap}; +use std::collections::hash_map::Entry; use std::ops::Range; use std::path::Path; use std::sync::{Arc, Condvar, Mutex, RwLock}; use std::{cmp, mem, slice, time}; use hal::{self, error, image, pass, format, mapping, memory, buffer, pso, query, window}; -use hal::backend::FastHashMap; use hal::device::{BindError, OutOfMemory, FramebufferError, ShaderError}; use hal::memory::Properties; use hal::pool::CommandPoolCreateFlags; @@ -496,7 +495,7 @@ impl Device { { Ok(library) => Ok(n::ShaderModule::Compiled { library, - entry_point_map: FastHashMap::default(), + entry_point_map: n::EntryPointMap::default(), }), Err(err) => Err(ShaderError::CompilationFailed(err.into())), } @@ -506,8 +505,8 @@ impl Device { &self, raw_data: &[u8], primitive_class: MTLPrimitiveTopologyClass, - overrides: &HashMap, - ) -> Result<(metal::Library, FastHashMap), ShaderError> { + overrides: &n::ResourceOverrideMap, + ) -> Result<(metal::Library, n::EntryPointMap), ShaderError> { // spec requires "codeSize must be a multiple of 4" assert_eq!(raw_data.len() & 3, 0); @@ -528,7 +527,10 @@ impl Device { compiler_options.resolve_specialized_array_lengths = true; compiler_options.vertex.invert_y = true; // fill the overrides - compiler_options.resource_binding_overrides = overrides.clone(); + compiler_options.resource_binding_overrides = overrides + .iter() + .map(|(key, value)| (key.clone(), value.clone())) + .collect(); ast.set_compiler_options(&compiler_options) .map_err(|err| { @@ -557,7 +559,7 @@ impl Device { ShaderError::CompilationFailed(msg) })?; - let mut entry_point_map = FastHashMap::default(); + let mut entry_point_map = n::EntryPointMap::default(); for entry_point in entry_points { info!("Entry point {:?}", entry_point); let cleansed = ast.get_cleansed_entry_point_name(&entry_point.name, entry_point.execution_model) @@ -727,7 +729,7 @@ impl hal::Device for Device { (ShaderStageFlags::FRAGMENT, spirv::ExecutionModel::Fragment, Counters { buffers:0, textures:0, samplers:0 }), (ShaderStageFlags::COMPUTE, spirv::ExecutionModel::GlCompute, Counters { buffers:0, textures:0, samplers:0 }), ]; - let mut res_overrides = HashMap::new(); + let mut res_overrides = n::ResourceOverrideMap::default(); for (set_index, set_layout) in set_layouts.into_iter().enumerate() { match set_layout.borrow() { @@ -1185,7 +1187,7 @@ impl hal::Device for Device { let (library, entry_point_map) = self.compile_shader_library( raw_data, MTLPrimitiveTopologyClass::Unspecified, - &HashMap::new(), + &n::ResourceOverrideMap::default(), )?; n::ShaderModule::Compiled { library, diff --git a/src/backend/metal/src/native.rs b/src/backend/metal/src/native.rs index 948edd42633..89ed8bb840a 100644 --- a/src/backend/metal/src/native.rs +++ b/src/backend/metal/src/native.rs @@ -2,7 +2,6 @@ use {Backend, BufferPtr, SamplerPtr, TexturePtr}; use internal::Channel; use window::SwapchainImage; -use std::collections::HashMap; use std::ops::Range; use std::os::raw::{c_void, c_long}; use std::sync::{Arc, Condvar, Mutex, RwLock}; @@ -20,13 +19,15 @@ use foreign_types::ForeignType; use range_alloc::RangeAllocator; +pub type EntryPointMap = FastHashMap; + /// Shader module can be compiled in advance if it's resource bindings do not /// depend on pipeline layout, in which case the value would become `Compiled`. #[derive(Debug)] pub enum ShaderModule { Compiled { library: metal::Library, - entry_point_map: FastHashMap, + entry_point_map: EntryPointMap, }, Raw(Vec), } @@ -65,11 +66,13 @@ pub struct Framebuffer { unsafe impl Send for Framebuffer {} unsafe impl Sync for Framebuffer {} +pub type ResourceOverrideMap = FastHashMap; + #[derive(Debug)] pub struct PipelineLayout { // First vertex buffer index to be used by attributes pub(crate) attribute_buffer_index: u32, - pub(crate) res_overrides: HashMap, + pub(crate) res_overrides: ResourceOverrideMap, } #[derive(Clone, Debug)]