mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-22 07:01:29 +11:00
Indirect draws, get image footprint, makefile improvements
This commit is contained in:
parent
4898017266
commit
b4b1cac73d
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -252,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "gfx-backend-dx12"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#d09ef94da58cac14f0ffd1f329073ee50c8a01f4"
|
||||
source = "git+https://github.com/gfx-rs/gfx#448cbebc020961c31fda456b9633273262bbb720"
|
||||
dependencies = [
|
||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -268,8 +268,9 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gfx-backend-metal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#d09ef94da58cac14f0ffd1f329073ee50c8a01f4"
|
||||
source = "git+https://github.com/gfx-rs/gfx#448cbebc020961c31fda456b9633273262bbb720"
|
||||
dependencies = [
|
||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -278,17 +279,17 @@ dependencies = [
|
|||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"io-surface 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"metal-rs 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"metal-rs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spirv_cross 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spirv_cross 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gfx-backend-vulkan"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#d09ef94da58cac14f0ffd1f329073ee50c8a01f4"
|
||||
source = "git+https://github.com/gfx-rs/gfx#448cbebc020961c31fda456b9633273262bbb720"
|
||||
dependencies = [
|
||||
"ash 0.24.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -306,7 +307,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gfx-hal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#d09ef94da58cac14f0ffd1f329073ee50c8a01f4"
|
||||
source = "git+https://github.com/gfx-rs/gfx#448cbebc020961c31fda456b9633273262bbb720"
|
||||
dependencies = [
|
||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -444,7 +445,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "metal-rs"
|
||||
version = "0.9.3"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -618,6 +619,14 @@ dependencies = [
|
|||
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spirv_cross"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "0.10.8"
|
||||
|
@ -934,7 +943,7 @@ dependencies = [
|
|||
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
||||
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
|
||||
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
|
||||
"checksum metal-rs 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "756654c44e8b85ba7d79497c887ff7a48d1f269c7bc09c9484f95092f54fbf6a"
|
||||
"checksum metal-rs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ac2894f1ea30a8bac947c43f9f28a500564bf454857dc65e48821eb9d24c680"
|
||||
"checksum objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "877f30f37acef6749b1841cceab289707f211aecfc756553cd63976190e6cc2e"
|
||||
"checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
|
||||
"checksum objc_exception 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "098cd29a2fa3c230d3463ae069cecccc3fdfd64c0d2496ab5b96f82dab6a00dc"
|
||||
|
@ -953,6 +962,7 @@ dependencies = [
|
|||
"checksum shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8254bf098ce4d8d7cc7cc6de438c5488adc5297e5b7ffef88816c0a91bd289c1"
|
||||
"checksum smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03dab98ab5ded3a8b43b2c80751194608d0b2aa0f1d46cf95d1c35e192844aa7"
|
||||
"checksum spirv_cross 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "387a12e5de5d5cd284d07fe7edbcac83163c0b9b4304bd3a0efb1274bcda83cf"
|
||||
"checksum spirv_cross 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1af833c4f35713d2d739de6e8a2a05614b25800fd48d07d98ca3a143a1df6ce1"
|
||||
"checksum syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "58fd09df59565db3399efbba34ba8a2fec1307511ebd245d0061ff9d42691673"
|
||||
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
|
||||
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
|
||||
|
|
5
Makefile
5
Makefile
|
@ -9,7 +9,7 @@ LIB_EXTENSION=
|
|||
TEST_LIST=$(CURDIR)/conformance/deqp.txt
|
||||
TEST_LIST_SOURCE=$(CTS_DIR)/external/vulkancts/mustpass/1.0.2/vk-default.txt
|
||||
DEQP_DIR=$(CTS_DIR)/build/external/vulkancts/modules/vulkan/
|
||||
DEQP=cd $(DEQP_DIR) && LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) ./deqp-vk
|
||||
DEQP=cd $(DEQP_DIR) && RUST_LOG=debug LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) ./deqp-vk
|
||||
|
||||
RUST_BACKTRACE:=1
|
||||
BACKEND:=gl
|
||||
|
@ -87,7 +87,8 @@ cts: $(TARGET) $(TEST_LIST)
|
|||
mv TestResults.qpa conformance/last.qpa
|
||||
firefox conformance/last.xml
|
||||
|
||||
cts-pick: $(TARGET)
|
||||
cts-pick:
|
||||
cargo build --manifest-path libportability/Cargo.toml --features $(BACKEND),portability-gfx/env_logger
|
||||
($(DEQP) -n $(name))
|
||||
|
||||
cts-debug: $(TARGET)
|
||||
|
|
|
@ -40,5 +40,4 @@ optional = true
|
|||
[target.'cfg(target_os = "macos")'.dependencies.gfx-backend-metal]
|
||||
git = "https://github.com/gfx-rs/gfx"
|
||||
#path = "../../gfx/src/backend/metal"
|
||||
features = ["metal_default_capture_scope"]
|
||||
optional = true
|
||||
|
|
|
@ -12,8 +12,14 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits {
|
|||
maxImageDimension2D: limits.max_texture_size as _,
|
||||
maxImageDimension3D: limits.max_texture_size as _,
|
||||
maxImageDimensionCube: limits.max_texture_size as _,
|
||||
maxTexelBufferElements: limits.max_texture_size as _, //TODO
|
||||
maxTessellationPatchSize: limits.max_patch_size as _,
|
||||
maxViewports: limits.max_viewports 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 _,
|
||||
maxComputeWorkGroupCount: limits.max_compute_group_count,
|
||||
maxComputeWorkGroupSize: limits.max_compute_group_size,
|
||||
optimalBufferCopyOffsetAlignment: limits.min_buffer_copy_offset_alignment,
|
||||
|
@ -24,6 +30,7 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits {
|
|||
framebufferColorSampleCounts: limits.framebuffer_color_samples_count as _,
|
||||
framebufferDepthSampleCounts: limits.framebuffer_depth_samples_count as _,
|
||||
framebufferStencilSampleCounts: limits.framebuffer_stencil_samples_count as _,
|
||||
nonCoherentAtomSize: limits.non_coherent_atom_size as _,
|
||||
.. unsafe { mem::zeroed() } //TODO
|
||||
}
|
||||
}
|
||||
|
@ -511,7 +518,11 @@ pub fn map_cull_face(cull: VkCullModeFlags) -> Option<pso::CullFace> {
|
|||
if cull == VK_CULL_MODE_NONE as _ { None }
|
||||
else if cull == VK_CULL_MODE_FRONT_BIT as _ { Some(pso::CullFace::Front) }
|
||||
else if cull == VK_CULL_MODE_BACK_BIT as _ { Some(pso::CullFace::Back) }
|
||||
else if cull == VK_CULL_MODE_FRONT_AND_BACK as _ { unimplemented!() } // TODO: can we support it?
|
||||
else if cull == VK_CULL_MODE_FRONT_AND_BACK as _ {
|
||||
// TODO: can we support it?
|
||||
error!("VK_CULL_MODE_FRONT_AND_BACK is not supported yet");
|
||||
Some(pso::CullFace::Front)
|
||||
}
|
||||
else { panic!("Unexpected cull mode: {:?}", cull) }
|
||||
}
|
||||
|
||||
|
@ -523,24 +534,23 @@ pub fn map_front_face(face: VkFrontFace) -> pso::FrontFace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn map_primitive_topology(topology: VkPrimitiveTopology, patch_size: PatchSize) -> hal::Primitive {
|
||||
pub fn map_primitive_topology(topology: VkPrimitiveTopology, patch_size: PatchSize) -> Option<hal::Primitive> {
|
||||
use super::VkPrimitiveTopology::*;
|
||||
|
||||
match topology {
|
||||
Some(match topology {
|
||||
VK_PRIMITIVE_TOPOLOGY_POINT_LIST => Primitive::PointList,
|
||||
VK_PRIMITIVE_TOPOLOGY_LINE_LIST => Primitive::LineList,
|
||||
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP => Primitive::LineStrip,
|
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST => Primitive::TriangleList,
|
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP => Primitive::TriangleStrip,
|
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN =>
|
||||
panic!("`VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN` not supported in portability"),
|
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN => return None,
|
||||
VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY => Primitive::LineListAdjacency,
|
||||
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY => Primitive::LineStripAdjacency,
|
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY => Primitive::TriangleListAdjacency,
|
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY => Primitive::TriangleStripAdjacency,
|
||||
VK_PRIMITIVE_TOPOLOGY_PATCH_LIST => Primitive::PatchList(patch_size),
|
||||
_ => panic!("Unexpected primitive topology: {:?}", topology),
|
||||
}
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn map_compare_op(op: VkCompareOp) -> pso::Comparison {
|
||||
|
@ -684,9 +694,10 @@ pub fn map_rect(rect: &VkRect2D) -> pso::Rect {
|
|||
}
|
||||
|
||||
pub fn map_clear_rect(rect: &VkClearRect) -> pso::ClearRect {
|
||||
let base = rect.baseArrayLayer as image::Layer;
|
||||
pso::ClearRect {
|
||||
rect: map_rect(&rect.rect),
|
||||
layers: rect.baseArrayLayer as _ .. (rect.baseArrayLayer + rect.layerCount) as _
|
||||
layers: base .. base + rect.layerCount as image::Layer,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,12 @@ pub extern "C" fn gfxCreateInstance(
|
|||
_pAllocator: *const VkAllocationCallbacks,
|
||||
pInstance: *mut VkInstance,
|
||||
) -> VkResult {
|
||||
#[cfg(feature = "env_logger")]
|
||||
{
|
||||
use env_logger;
|
||||
let _ = env_logger::try_init();
|
||||
}
|
||||
|
||||
let backend = back::Instance::create("portability", 1);
|
||||
let adapters = backend
|
||||
.enumerate_adapters()
|
||||
|
@ -1286,12 +1292,25 @@ pub extern "C" fn gfxDestroyImage(
|
|||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxGetImageSubresourceLayout(
|
||||
_gpu: VkDevice,
|
||||
_image: VkImage,
|
||||
_pSubresource: *const VkImageSubresource,
|
||||
_pLayout: *mut VkSubresourceLayout,
|
||||
gpu: VkDevice,
|
||||
image: VkImage,
|
||||
pSubresource: *const VkImageSubresource,
|
||||
pLayout: *mut VkSubresourceLayout,
|
||||
) {
|
||||
unimplemented!()
|
||||
let footprint = gpu.device.get_image_subresource_footprint(
|
||||
image.expect("Bound image expected!"),
|
||||
image.map_subresource(unsafe { *pSubresource} ),
|
||||
);
|
||||
let sub_layout = VkSubresourceLayout {
|
||||
offset: footprint.slice.start,
|
||||
size: footprint.slice.end - footprint.slice.start,
|
||||
rowPitch: footprint.row_pitch,
|
||||
depthPitch: footprint.depth_pitch,
|
||||
arrayPitch: footprint.array_pitch,
|
||||
};
|
||||
unsafe {
|
||||
*pLayout = sub_layout;
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxCreateImageView(
|
||||
|
@ -1562,13 +1581,21 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
|||
|
||||
assert_eq!(input_state.primitiveRestartEnable, VK_FALSE); // TODO
|
||||
|
||||
let primitive = match conv::map_primitive_topology(
|
||||
input_state.topology,
|
||||
tessellation_state
|
||||
.map(|state| state.patchControlPoints as _)
|
||||
.unwrap_or(0),
|
||||
) {
|
||||
Some(primitive) => primitive,
|
||||
None => {
|
||||
error!("Primitive topology {:?} is not supported", input_state.topology);
|
||||
hal::Primitive::PointList
|
||||
},
|
||||
};
|
||||
|
||||
pso::InputAssemblerDesc {
|
||||
primitive: conv::map_primitive_topology(
|
||||
input_state.topology,
|
||||
tessellation_state
|
||||
.map(|state| state.patchControlPoints as _)
|
||||
.unwrap_or(0),
|
||||
),
|
||||
primitive,
|
||||
primitive_restart: pso::PrimitiveRestart::Disabled, // TODO
|
||||
}
|
||||
};
|
||||
|
@ -2809,23 +2836,33 @@ pub extern "C" fn gfxCmdDrawIndexed(
|
|||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxCmdDrawIndirect(
|
||||
_commandBuffer: VkCommandBuffer,
|
||||
_buffer: VkBuffer,
|
||||
_offset: VkDeviceSize,
|
||||
_drawCount: u32,
|
||||
_stride: u32,
|
||||
mut commandBuffer: VkCommandBuffer,
|
||||
buffer: VkBuffer,
|
||||
offset: VkDeviceSize,
|
||||
drawCount: u32,
|
||||
stride: u32,
|
||||
) {
|
||||
unimplemented!()
|
||||
commandBuffer.draw_indirect(
|
||||
buffer.expect("Bound buffer expected!"),
|
||||
offset,
|
||||
drawCount,
|
||||
stride,
|
||||
)
|
||||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxCmdDrawIndexedIndirect(
|
||||
_commandBuffer: VkCommandBuffer,
|
||||
_buffer: VkBuffer,
|
||||
_offset: VkDeviceSize,
|
||||
_drawCount: u32,
|
||||
_stride: u32,
|
||||
mut commandBuffer: VkCommandBuffer,
|
||||
buffer: VkBuffer,
|
||||
offset: VkDeviceSize,
|
||||
drawCount: u32,
|
||||
stride: u32,
|
||||
) {
|
||||
unimplemented!()
|
||||
commandBuffer.draw_indexed_indirect(
|
||||
buffer.expect("Bound buffer expected!"),
|
||||
offset,
|
||||
drawCount,
|
||||
stride,
|
||||
)
|
||||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxCmdDispatch(
|
||||
|
@ -2842,7 +2879,10 @@ pub extern "C" fn gfxCmdDispatchIndirect(
|
|||
buffer: VkBuffer,
|
||||
offset: VkDeviceSize,
|
||||
) {
|
||||
commandBuffer.dispatch_indirect(buffer.expect("Bound buffer expected!"), offset)
|
||||
commandBuffer.dispatch_indirect(
|
||||
buffer.expect("Bound buffer expected!"),
|
||||
offset,
|
||||
)
|
||||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxCmdCopyBuffer(
|
||||
|
|
|
@ -31,11 +31,6 @@ use std::collections::HashMap;
|
|||
|
||||
pub use impls::*;
|
||||
|
||||
#[cfg(feature = "env_logger")]
|
||||
lazy_static! {
|
||||
static ref _LOGGER: () = env_logger::init();
|
||||
}
|
||||
|
||||
// Vulkan objects
|
||||
pub type VkInstance = Handle<RawInstance>;
|
||||
pub type VkPhysicalDevice = Handle<hal::Adapter<B>>;
|
||||
|
@ -105,6 +100,14 @@ impl<B: hal::Backend> Image<B> {
|
|||
}
|
||||
}
|
||||
|
||||
fn map_subresource(&self, subresource: VkImageSubresource) -> hal::image::Subresource {
|
||||
hal::image::Subresource {
|
||||
aspects: conv::map_aspect(subresource.aspectMask),
|
||||
level: subresource.mipLevel as _,
|
||||
layer: subresource.arrayLayer as _,
|
||||
}
|
||||
}
|
||||
|
||||
fn map_subresource_layers(&self, subresource: VkImageSubresourceLayers) -> hal::image::SubresourceLayers {
|
||||
let layer_end = if subresource.layerCount == VK_REMAINING_ARRAY_LAYERS as _ {
|
||||
self.array_layers()
|
||||
|
|
Loading…
Reference in a new issue