mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 08:51:31 +11:00
Format code using rustfmt
This commit is contained in:
parent
a9edbc0337
commit
9f5d97a43c
|
@ -1,11 +1,10 @@
|
|||
use hal::{buffer, command, device, format, image, memory, pass, pso, query, window};
|
||||
use hal::{IndexType, Features, Limits, PatchSize, Primitive};
|
||||
use hal::{Features, IndexType, Limits, PatchSize, Primitive};
|
||||
|
||||
use std::mem;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits {
|
||||
let viewport_size = limits.max_viewport_dimensions[0].max(limits.max_viewport_dimensions[1]);
|
||||
VkPhysicalDeviceLimits {
|
||||
|
@ -86,16 +85,33 @@ pub fn features_from_hal(features: Features) -> VkPhysicalDeviceFeatures {
|
|||
pipelineStatisticsQuery: features.contains(Features::PIPELINE_STATISTICS_QUERY) as _,
|
||||
vertexPipelineStoresAndAtomics: features.contains(Features::VERTEX_STORES_AND_ATOMICS) as _,
|
||||
fragmentStoresAndAtomics: features.contains(Features::FRAGMENT_STORES_AND_ATOMICS) as _,
|
||||
shaderTessellationAndGeometryPointSize: features.contains(Features::SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE) as _,
|
||||
shaderTessellationAndGeometryPointSize: features
|
||||
.contains(Features::SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE)
|
||||
as _,
|
||||
shaderImageGatherExtended: features.contains(Features::SHADER_IMAGE_GATHER_EXTENDED) as _,
|
||||
shaderStorageImageExtendedFormats: features.contains(Features::SHADER_STORAGE_IMAGE_EXTENDED_FORMATS) as _,
|
||||
shaderStorageImageMultisample: features.contains(Features::SHADER_STORAGE_IMAGE_MULTISAMPLE) as _,
|
||||
shaderStorageImageReadWithoutFormat: features.contains(Features::SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT) as _,
|
||||
shaderStorageImageWriteWithoutFormat: features.contains(Features::SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT) as _,
|
||||
shaderUniformBufferArrayDynamicIndexing: features.contains(Features::SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING) as _,
|
||||
shaderSampledImageArrayDynamicIndexing: features.contains(Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING) as _,
|
||||
shaderStorageBufferArrayDynamicIndexing: features.contains(Features::SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING) as _,
|
||||
shaderStorageImageArrayDynamicIndexing: features.contains(Features::SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING) as _,
|
||||
shaderStorageImageExtendedFormats: features
|
||||
.contains(Features::SHADER_STORAGE_IMAGE_EXTENDED_FORMATS)
|
||||
as _,
|
||||
shaderStorageImageMultisample: features.contains(Features::SHADER_STORAGE_IMAGE_MULTISAMPLE)
|
||||
as _,
|
||||
shaderStorageImageReadWithoutFormat: features
|
||||
.contains(Features::SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT)
|
||||
as _,
|
||||
shaderStorageImageWriteWithoutFormat: features
|
||||
.contains(Features::SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT)
|
||||
as _,
|
||||
shaderUniformBufferArrayDynamicIndexing: features
|
||||
.contains(Features::SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING)
|
||||
as _,
|
||||
shaderSampledImageArrayDynamicIndexing: features
|
||||
.contains(Features::SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING)
|
||||
as _,
|
||||
shaderStorageBufferArrayDynamicIndexing: features
|
||||
.contains(Features::SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING)
|
||||
as _,
|
||||
shaderStorageImageArrayDynamicIndexing: features
|
||||
.contains(Features::SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING)
|
||||
as _,
|
||||
shaderClipDistance: features.contains(Features::SHADER_CLIP_DISTANCE) as _,
|
||||
shaderCullDistance: features.contains(Features::SHADER_CULL_DISTANCE) as _,
|
||||
shaderFloat64: features.contains(Features::SHADER_FLOAT64) as _,
|
||||
|
@ -131,7 +147,9 @@ pub fn format_properties_from_hal(properties: format::Properties) -> VkFormatPro
|
|||
}
|
||||
}
|
||||
|
||||
pub fn image_format_properties_from_hal(properties: image::FormatProperties) -> VkImageFormatProperties {
|
||||
pub fn image_format_properties_from_hal(
|
||||
properties: image::FormatProperties,
|
||||
) -> VkImageFormatProperties {
|
||||
VkImageFormatProperties {
|
||||
maxExtent: extent3d_from_hal(properties.max_extent),
|
||||
maxMipLevels: properties.max_levels as _,
|
||||
|
@ -284,9 +302,16 @@ pub fn map_image_kind(
|
|||
debug_assert_ne!(array_layers, 0);
|
||||
match ty {
|
||||
VkImageType::VK_IMAGE_TYPE_1D => image::Kind::D1(extent.width as _, array_layers),
|
||||
VkImageType::VK_IMAGE_TYPE_2D => image::Kind::D2(extent.width as _, extent.height as _, array_layers, samples as _),
|
||||
VkImageType::VK_IMAGE_TYPE_3D => image::Kind::D3(extent.width as _, extent.height as _, extent.depth as _),
|
||||
_ => unreachable!()
|
||||
VkImageType::VK_IMAGE_TYPE_2D => image::Kind::D2(
|
||||
extent.width as _,
|
||||
extent.height as _,
|
||||
array_layers,
|
||||
samples as _,
|
||||
),
|
||||
VkImageType::VK_IMAGE_TYPE_3D => {
|
||||
image::Kind::D3(extent.width as _, extent.height as _, extent.depth as _)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +324,7 @@ pub fn map_view_kind(ty: VkImageViewType) -> image::ViewKind {
|
|||
VkImageViewType::VK_IMAGE_VIEW_TYPE_3D => image::ViewKind::D3,
|
||||
VkImageViewType::VK_IMAGE_VIEW_TYPE_CUBE => image::ViewKind::Cube,
|
||||
VkImageViewType::VK_IMAGE_VIEW_TYPE_CUBE_ARRAY => image::ViewKind::CubeArray,
|
||||
_ => unreachable!()
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,8 +334,12 @@ pub fn map_image_layout(layout: VkImageLayout) -> image::Layout {
|
|||
VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED => Undefined,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_GENERAL => General,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL => ColorAttachmentOptimal,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL => DepthStencilAttachmentOptimal,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL => DepthStencilReadOnlyOptimal,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL => {
|
||||
DepthStencilAttachmentOptimal
|
||||
}
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL => {
|
||||
DepthStencilReadOnlyOptimal
|
||||
}
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL => ShaderReadOnlyOptimal,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL => TransferSrcOptimal,
|
||||
VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL => TransferDstOptimal,
|
||||
|
@ -560,8 +589,9 @@ pub fn map_attachment_store_op(op: VkAttachmentStoreOp) -> pass::AttachmentStore
|
|||
pub fn map_subpass_contents(contents: VkSubpassContents) -> command::SubpassContents {
|
||||
match contents {
|
||||
VkSubpassContents::VK_SUBPASS_CONTENTS_INLINE => command::SubpassContents::Inline,
|
||||
VkSubpassContents::VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS =>
|
||||
command::SubpassContents::SecondaryBuffers,
|
||||
VkSubpassContents::VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS => {
|
||||
command::SubpassContents::SecondaryBuffers
|
||||
}
|
||||
|
||||
_ => panic!("Unexpected subpass contents: {:?}", contents),
|
||||
}
|
||||
|
@ -594,7 +624,10 @@ pub fn map_front_face(face: VkFrontFace) -> pso::FrontFace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn map_primitive_topology(topology: VkPrimitiveTopology, patch_size: PatchSize) -> Option<Primitive> {
|
||||
pub fn map_primitive_topology(
|
||||
topology: VkPrimitiveTopology,
|
||||
patch_size: PatchSize,
|
||||
) -> Option<Primitive> {
|
||||
use super::VkPrimitiveTopology::*;
|
||||
|
||||
Some(match topology {
|
||||
|
@ -622,14 +655,15 @@ pub fn map_present_mode(present_mode: VkPresentModeKHR) -> window::PresentMode {
|
|||
pub fn map_composite_alpha(composite_alpha: VkCompositeAlphaFlagBitsKHR) -> window::CompositeAlpha {
|
||||
if composite_alpha == VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR {
|
||||
window::CompositeAlpha::OPAQUE
|
||||
} else
|
||||
if composite_alpha == VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR {
|
||||
} else if composite_alpha
|
||||
== VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR
|
||||
{
|
||||
window::CompositeAlpha::PREMULTIPLIED
|
||||
} else
|
||||
if composite_alpha == VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR {
|
||||
} else if composite_alpha
|
||||
== VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR
|
||||
{
|
||||
window::CompositeAlpha::POSTMULTIPLIED
|
||||
} else
|
||||
if composite_alpha == VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR {
|
||||
} else if composite_alpha == VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR {
|
||||
window::CompositeAlpha::INHERIT
|
||||
} else {
|
||||
error!("Unrecognized composite alpha: {:?}", composite_alpha);
|
||||
|
@ -674,21 +708,23 @@ fn map_blend_factor(factor: VkBlendFactor) -> pso::Factor {
|
|||
}
|
||||
|
||||
pub fn map_blend_op(
|
||||
blend_op: VkBlendOp, src_factor: VkBlendFactor, dst_factor: VkBlendFactor,
|
||||
blend_op: VkBlendOp,
|
||||
src_factor: VkBlendFactor,
|
||||
dst_factor: VkBlendFactor,
|
||||
) -> pso::BlendOp {
|
||||
use super::VkBlendOp::*;
|
||||
match blend_op {
|
||||
VK_BLEND_OP_ADD => pso::BlendOp::Add {
|
||||
src: map_blend_factor(src_factor),
|
||||
dst: map_blend_factor(dst_factor)
|
||||
dst: map_blend_factor(dst_factor),
|
||||
},
|
||||
VK_BLEND_OP_SUBTRACT => pso::BlendOp::Sub {
|
||||
src: map_blend_factor(src_factor),
|
||||
dst: map_blend_factor(dst_factor)
|
||||
dst: map_blend_factor(dst_factor),
|
||||
},
|
||||
VK_BLEND_OP_REVERSE_SUBTRACT => pso::BlendOp::RevSub {
|
||||
src: map_blend_factor(src_factor),
|
||||
dst: map_blend_factor(dst_factor)
|
||||
dst: map_blend_factor(dst_factor),
|
||||
},
|
||||
VK_BLEND_OP_MIN => pso::BlendOp::Min,
|
||||
VK_BLEND_OP_MAX => pso::BlendOp::Max,
|
||||
|
@ -706,7 +742,7 @@ pub fn map_filter(filter: VkFilter) -> image::Filter {
|
|||
match filter {
|
||||
VkFilter::VK_FILTER_NEAREST => image::Filter::Nearest,
|
||||
VkFilter::VK_FILTER_LINEAR => image::Filter::Linear,
|
||||
_ => panic!("Unsupported filter {:?}", filter)
|
||||
_ => panic!("Unsupported filter {:?}", filter),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -714,7 +750,7 @@ pub fn map_mipmap_filter(mode: VkSamplerMipmapMode) -> image::Filter {
|
|||
match mode {
|
||||
VkSamplerMipmapMode::VK_SAMPLER_MIPMAP_MODE_NEAREST => image::Filter::Nearest,
|
||||
VkSamplerMipmapMode::VK_SAMPLER_MIPMAP_MODE_LINEAR => image::Filter::Linear,
|
||||
_ => panic!("Unsupported mipmap mode {:?}", mode)
|
||||
_ => panic!("Unsupported mipmap mode {:?}", mode),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -797,9 +833,9 @@ pub fn map_index_type(ty: VkIndexType) -> IndexType {
|
|||
pub fn map_query_type(ty: VkQueryType, statistic: VkQueryPipelineStatisticFlags) -> query::Type {
|
||||
match ty {
|
||||
VkQueryType::VK_QUERY_TYPE_OCCLUSION => query::Type::Occlusion,
|
||||
VkQueryType::VK_QUERY_TYPE_PIPELINE_STATISTICS => query::Type::PipelineStatistics(
|
||||
map_pipeline_statistics(statistic)
|
||||
),
|
||||
VkQueryType::VK_QUERY_TYPE_PIPELINE_STATISTICS => {
|
||||
query::Type::PipelineStatistics(map_pipeline_statistics(statistic))
|
||||
}
|
||||
VkQueryType::VK_QUERY_TYPE_TIMESTAMP => query::Type::Timestamp,
|
||||
_ => panic!("Unexpected query type: {:?}", ty),
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use VK_NULL_HANDLE;
|
||||
use std::{borrow, cmp, fmt, ops};
|
||||
#[cfg(feature = "nightly")]
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{borrow, cmp, fmt, ops};
|
||||
use VK_NULL_HANDLE;
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
use hal::backend::FastHashMap;
|
||||
|
||||
use copyless::{BoxAllocation, BoxHelper};
|
||||
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
lazy_static! {
|
||||
static ref REGISTRY: Arc<Mutex<FastHashMap<usize, &'static str>>> = Arc::new(Mutex::new(FastHashMap::default()));
|
||||
static ref REGISTRY: Arc<Mutex<FastHashMap<usize, &'static str>>> =
|
||||
Arc::new(Mutex::new(FastHashMap::default()));
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -141,9 +141,9 @@ pub type DispatchHandle<T> = Handle<T>;
|
|||
|
||||
#[cfg(feature = "dispatch")]
|
||||
mod dispatch {
|
||||
use VK_NULL_HANDLE;
|
||||
use copyless::{BoxAllocation, BoxHelper};
|
||||
use std::{borrow, cmp, fmt, ops};
|
||||
use VK_NULL_HANDLE;
|
||||
|
||||
const ICD_LOADER_MAGIC: u64 = 0x01CDC0DE;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,6 @@ use portability_gfx::*;
|
|||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
|
||||
|
||||
const ICD_VERSION: u32 = 5;
|
||||
|
||||
#[no_mangle]
|
||||
|
|
|
@ -638,14 +638,7 @@ pub extern "C" fn vkGetQueryPoolResults(
|
|||
flags: VkQueryResultFlags,
|
||||
) -> VkResult {
|
||||
gfxGetQueryPoolResults(
|
||||
device,
|
||||
queryPool,
|
||||
firstQuery,
|
||||
queryCount,
|
||||
dataSize,
|
||||
pData,
|
||||
stride,
|
||||
flags,
|
||||
device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags,
|
||||
)
|
||||
}
|
||||
#[no_mangle]
|
||||
|
@ -1078,7 +1071,13 @@ pub extern "C" fn vkCmdDraw(
|
|||
firstVertex: u32,
|
||||
firstInstance: u32,
|
||||
) {
|
||||
gfxCmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance)
|
||||
gfxCmdDraw(
|
||||
commandBuffer,
|
||||
vertexCount,
|
||||
instanceCount,
|
||||
firstVertex,
|
||||
firstInstance,
|
||||
)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn vkCmdDrawIndexed(
|
||||
|
@ -1231,13 +1230,7 @@ pub extern "C" fn vkCmdUpdateBuffer(
|
|||
dataSize: VkDeviceSize,
|
||||
pData: *const ::std::os::raw::c_void,
|
||||
) {
|
||||
gfxCmdUpdateBuffer(
|
||||
commandBuffer,
|
||||
dstBuffer,
|
||||
dstOffset,
|
||||
dataSize,
|
||||
pData,
|
||||
)
|
||||
gfxCmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn vkCmdFillBuffer(
|
||||
|
@ -1327,11 +1320,7 @@ pub extern "C" fn vkCmdSetEvent(
|
|||
event: VkEvent,
|
||||
stageMask: VkPipelineStageFlags,
|
||||
) {
|
||||
gfxCmdSetEvent(
|
||||
commandBuffer,
|
||||
event,
|
||||
stageMask,
|
||||
)
|
||||
gfxCmdSetEvent(commandBuffer, event, stageMask)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn vkCmdResetEvent(
|
||||
|
@ -1339,11 +1328,7 @@ pub extern "C" fn vkCmdResetEvent(
|
|||
event: VkEvent,
|
||||
stageMask: VkPipelineStageFlags,
|
||||
) {
|
||||
gfxCmdResetEvent(
|
||||
commandBuffer,
|
||||
event,
|
||||
stageMask,
|
||||
)
|
||||
gfxCmdResetEvent(commandBuffer, event, stageMask)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn vkCmdWaitEvents(
|
||||
|
@ -1500,14 +1485,7 @@ pub extern "C" fn vkAcquireNextImageKHR(
|
|||
fence: VkFence,
|
||||
pImageIndex: *mut u32,
|
||||
) -> VkResult {
|
||||
gfxAcquireNextImageKHR(
|
||||
device,
|
||||
swapchain,
|
||||
timeout,
|
||||
semaphore,
|
||||
fence,
|
||||
pImageIndex,
|
||||
)
|
||||
gfxAcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn vkQueuePresentKHR(
|
||||
|
|
Loading…
Reference in a new issue