Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to the new swapchain model #210

Merged
merged 6 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
505 changes: 209 additions & 296 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ FULL_LIBRARY_PATH=$(CURDIR)/target/debug
LIBRARY=target/debug/libportability.$(LIB_EXTENSION)
LIBRARY_FAST=target/release/libportability.$(LIB_EXTENSION)

.PHONY: all rebuild debug release version-debug version-release binding run-native cts clean cherry dota-debug dota-release dota-orig dota-bench-gfx dota-bench-orig dota-bench-gl package memcpy-report
.PHONY: all dummy rebuild debug release version-debug version-release binding run-native cts clean cherry dota-debug dota-release dota-orig dota-bench-gfx dota-bench-orig dota-bench-gl package memcpy-report

all: $(NATIVE_TARGET)

dummy:

rebuild:
cargo build --manifest-path libportability/Cargo.toml --features $(BACKEND)

Expand Down Expand Up @@ -117,12 +119,12 @@ binding: $(BINDING)
$(BINDING): $(VULKAN_DIR)/vulkan/*.h
bindgen --no-layout-tests --rustfmt-bindings $(VULKAN_DIR)/vulkan/vulkan.h -o $(BINDING)

$(LIBRARY): libportability*/src/*.rs libportability*/Cargo.toml Cargo.lock
$(LIBRARY): dummy
cargo build --manifest-path libportability/Cargo.toml --features $(BACKEND)
cargo build --manifest-path libportability-icd/Cargo.toml --features $(BACKEND)
cargo build --manifest-path libportability-icd/Cargo.toml --features $(BACKEND),portability-gfx/env_logger
mkdir -p target/native

$(LIBRARY_FAST): libportability*/src/*.rs libportability*/Cargo.toml Cargo.lock
$(LIBRARY_FAST): dummy
cargo build --release --manifest-path libportability/Cargo.toml --features $(BACKEND)
cargo build --release --manifest-path libportability-icd/Cargo.toml --features $(BACKEND)

Expand Down
12 changes: 3 additions & 9 deletions libportability-gfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ metal-capture = ["gfx-backend-metal/auto-capture"]

[dependencies]
copyless = "0.1.1"
env_logger = { version = "0.5", optional = true }
lazy_static = "1"
log = { version = "0.4", features = ["release_max_level_error"] }

[dependencies.env_logger]
version = "0.5"
optional = true

[dependencies.renderdoc]
version = "0.3"
optional = true
renderdoc = { version = "0.3", optional = true }

[dependencies.hal]
package = "gfx-hal"
Expand Down Expand Up @@ -68,5 +62,5 @@ optional = true

[dependencies.gfx-auxil]
git = "https://github.com/gfx-rs/gfx"
# path = "../../gfx/src/auxil/auxil"
#path = "../../gfx/src/auxil/auxil"
optional = true
105 changes: 84 additions & 21 deletions libportability-gfx/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,110 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits {
maxImageDimension2D: limits.max_image_2d_size,
maxImageDimension3D: limits.max_image_3d_size,
maxImageDimensionCube: limits.max_image_cube_size,
maxFramebufferWidth: limits.max_framebuffer_extent.width,
maxFramebufferHeight: limits.max_framebuffer_extent.height,
maxImageArrayLayers: limits.max_image_array_layers as _,
maxTexelBufferElements: limits.max_texel_elements as _,
maxTessellationPatchSize: limits.max_patch_size as _,
maxUniformBufferRange: limits.max_uniform_buffer_range as _,
maxStorageBufferRange: limits.max_storage_buffer_range as _,
maxPushConstantsSize: limits.max_push_constants_size as _,
maxViewports: limits.max_viewports as _,
maxViewportDimensions: limits.max_viewport_dimensions,
maxMemoryAllocationCount: limits.max_memory_allocation_count as _,
maxSamplerAllocationCount: limits.max_sampler_allocation_count as _,
bufferImageGranularity: limits.buffer_image_granularity,
sparseAddressSpaceSize: 0,
maxBoundDescriptorSets: limits.max_bound_descriptor_sets as _,
maxPerStageDescriptorSamplers: limits.max_per_stage_descriptor_samplers as _,
maxPerStageDescriptorUniformBuffers: limits.max_per_stage_descriptor_uniform_buffers as _,
maxPerStageDescriptorStorageBuffers: limits.max_per_stage_descriptor_storage_buffers as _,
maxPerStageDescriptorSampledImages: limits.max_per_stage_descriptor_sampled_images as _,
maxPerStageDescriptorStorageImages: limits.max_per_stage_descriptor_storage_images as _,
maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments as _,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments as _,
maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments
as _,

This comment was generated by: rustfmt

maxPerStageResources: limits.max_per_stage_resources as _,
maxDescriptorSetSamplers: limits.max_descriptor_set_samplers as _,
maxDescriptorSetUniformBuffers: limits.max_descriptor_set_uniform_buffers as _,
maxFragmentInputComponents: limits.max_fragment_input_components as _,
maxFramebufferLayers: limits.max_framebuffer_layers as _,
maxMemoryAllocationCount: limits.max_memory_allocation_count as _,
maxUniformBufferRange: limits.max_uniform_buffer_range as _,
// Warning: spec violation
// "The x/y rectangle of the viewport must lie entirely within the current attachment size."
viewportBoundsRange: [0.0, viewport_size as f32],
maxDescriptorSetUniformBuffersDynamic: limits.max_descriptor_set_uniform_buffers_dynamic.max(1) as _,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxDescriptorSetUniformBuffersDynamic: limits.max_descriptor_set_uniform_buffers_dynamic.max(1) as _,
maxDescriptorSetUniformBuffersDynamic: limits
.max_descriptor_set_uniform_buffers_dynamic
.max(1) as _,

This comment was generated by: rustfmt

maxDescriptorSetStorageBuffers: limits.max_descriptor_set_storage_buffers as _,
maxDescriptorSetStorageBuffersDynamic: limits.max_descriptor_set_storage_buffers_dynamic.max(1) as _,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxDescriptorSetStorageBuffersDynamic: limits.max_descriptor_set_storage_buffers_dynamic.max(1) as _,
maxDescriptorSetStorageBuffersDynamic: limits
.max_descriptor_set_storage_buffers_dynamic
.max(1) as _,

This comment was generated by: rustfmt

maxDescriptorSetSampledImages: limits.max_descriptor_set_sampled_images as _,
maxDescriptorSetStorageImages: limits.max_descriptor_set_storage_images as _,
maxDescriptorSetInputAttachments: limits.max_descriptor_set_input_attachments as _,
maxVertexInputAttributes: limits.max_vertex_input_attributes as _,
maxVertexInputBindings: limits.max_vertex_input_bindings as _,
maxVertexInputAttributeOffset: limits.max_vertex_input_attribute_offset as _,
maxVertexInputBindingStride: limits.max_vertex_input_binding_stride as _,
maxVertexOutputComponents: limits.max_vertex_output_components as _,
maxTessellationGenerationLevel: 0,
maxTessellationPatchSize: limits.max_patch_size as _,
maxTessellationControlPerVertexInputComponents: 0,
maxTessellationControlPerVertexOutputComponents: 0,
maxTessellationControlPerPatchOutputComponents: 0,
maxTessellationControlTotalOutputComponents: 0,
maxTessellationEvaluationInputComponents: 0,
maxTessellationEvaluationOutputComponents: 0,
maxGeometryShaderInvocations: limits.max_geometry_shader_invocations as _,
maxGeometryInputComponents: limits.max_geometry_input_components as _,
maxGeometryOutputComponents: limits.max_geometry_output_components as _,
maxGeometryOutputVertices: limits.max_geometry_output_vertices as _,
maxGeometryTotalOutputComponents: limits.max_geometry_total_output_components as _,
maxFragmentInputComponents: limits.max_fragment_input_components as _,
maxFragmentOutputAttachments: limits.max_fragment_output_attachments as _,
maxFragmentDualSrcAttachments: limits.max_fragment_dual_source_attachments as _,
maxFragmentCombinedOutputResources: limits.max_fragment_combined_output_resources as _,
maxComputeSharedMemorySize: limits.max_compute_shared_memory_size as _,
maxComputeWorkGroupCount: limits.max_compute_work_group_count,
maxComputeWorkGroupInvocations: limits.max_compute_work_group_invocations as _,
maxComputeWorkGroupSize: limits.max_compute_work_group_size,
bufferImageGranularity: limits.buffer_image_granularity,
subPixelPrecisionBits: 0,
subTexelPrecisionBits: 0,
mipmapPrecisionBits: 0,
maxDrawIndexedIndexValue: limits.max_draw_indexed_index_value,
maxDrawIndirectCount: limits.max_draw_indirect_count,
maxSamplerLodBias: limits.max_sampler_lod_bias,
maxSamplerAnisotropy: limits.max_sampler_anisotropy,
maxViewports: limits.max_viewports as _,
maxViewportDimensions: limits.max_viewport_dimensions,
// Warning: spec violation
// "The x/y rectangle of the viewport must lie entirely within the current attachment size."
viewportBoundsRange: [0.0, viewport_size as f32],
viewportSubPixelBits: 0,
minMemoryMapAlignment: limits.min_memory_map_alignment.max(1),
minTexelBufferOffsetAlignment: limits.min_texel_buffer_offset_alignment,
minUniformBufferOffsetAlignment: limits.min_uniform_buffer_offset_alignment,
minStorageBufferOffsetAlignment: limits.min_storage_buffer_offset_alignment,
minTexelOffset: 0,
maxTexelOffset: 0,
minTexelGatherOffset: 0,
maxTexelGatherOffset: 0,
minInterpolationOffset: 0.0,
maxInterpolationOffset: 0.0,
subPixelInterpolationOffsetBits: 0,
maxFramebufferWidth: limits.max_framebuffer_extent.width,
maxFramebufferHeight: limits.max_framebuffer_extent.height,
maxFramebufferLayers: limits.max_framebuffer_layers as _,
framebufferColorSampleCounts: limits.framebuffer_color_sample_counts as _,
framebufferDepthSampleCounts: limits.framebuffer_depth_sample_counts as _,
framebufferStencilSampleCounts: limits.framebuffer_stencil_sample_counts as _,
framebufferNoAttachmentsSampleCounts: 0, //TODO
maxColorAttachments: limits.max_color_attachments as _,
nonCoherentAtomSize: limits.non_coherent_atom_size as _,
maxSamplerAnisotropy: limits.max_sampler_anisotropy,
sampledImageColorSampleCounts: 0,
sampledImageIntegerSampleCounts: 0,
sampledImageDepthSampleCounts: 0,
sampledImageStencilSampleCounts: 0,
storageImageSampleCounts: 0,
maxSampleMaskWords: 0,
timestampComputeAndGraphics: 0,
timestampPeriod: 0.0,
maxClipDistances: 0,
maxCullDistances: 0,
maxCombinedClipAndCullDistances: 0,
discreteQueuePriorities: 0,
pointSizeRange: [0.0; 2],
lineWidthRange: [0.0; 2],
pointSizeGranularity: 0.0,
lineWidthGranularity: 0.0,
strictLines: 0,
standardSampleLocations: if limits.standard_sample_locations { VK_TRUE } else { VK_FALSE },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
standardSampleLocations: if limits.standard_sample_locations { VK_TRUE } else { VK_FALSE },
standardSampleLocations: if limits.standard_sample_locations {
VK_TRUE
} else {
VK_FALSE
},

This comment was generated by: rustfmt

optimalBufferCopyOffsetAlignment: limits.optimal_buffer_copy_offset_alignment,
optimalBufferCopyRowPitchAlignment: limits.optimal_buffer_copy_pitch_alignment,
maxPerStageDescriptorSampledImages: limits.max_per_stage_descriptor_sampled_images as _,
maxPerStageDescriptorSamplers: limits.max_per_stage_descriptor_samplers as _,
maxDescriptorSetSampledImages: limits.max_descriptor_set_sampled_images as _,
maxDescriptorSetSamplers: limits.max_descriptor_set_samplers as _,
..unsafe { mem::zeroed() } //TODO
nonCoherentAtomSize: limits.non_coherent_atom_size as _,
}
}

Expand Down Expand Up @@ -355,7 +418,7 @@ pub fn map_image_usage(usage: VkImageUsageFlags) -> image::Usage {
image::Usage::from_bits_truncate(usage)
}

pub fn map_image_usage_from_hal(usage: image::Usage) -> VkImageUsageFlags {
pub fn _map_image_usage_from_hal(usage: image::Usage) -> VkImageUsageFlags {
usage.bits()
}

Expand Down
Loading