Skip to content

Commit

Permalink
Merge #2070
Browse files Browse the repository at this point in the history
2070: Metal indirect push constants r=msiglreith a=kvark

Fixes #2066, Fixes #2065 
~~Includes #2064 (to be rebased)~~

Includes many cool things for Metal:
- [x] indirect draw support
- [x] push constant support
- [x] TODO: don't require push constants if the shader doesn't use them
- [x] TODO: support pipeline inheritance
- [x] workaround for an issue occurring when the PSO is bound after the vertex buffers 
- [x] metal-rs flags update
- [x] point_size built-in usage by SPIRV-Cross
- [x] new `DrawCount` typedef in HAL
- [x] depth bounds

The CTS category of "dEQP-VK.draw" now shows the following stats:
  - 170 Succeeded 🎉 
  - 0 Crashed
  - 25 Failed
    - mostly due to missing TriangleFan topology
    - depth ranges don't work probably, Apple upstream bug is filed

PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends: Metal


Co-authored-by: Dzmitry Malyshau <[email protected]>
  • Loading branch information
bors[bot] and kvark committed May 28, 2018
2 parents eeb8603 + 9b8bf73 commit 1e959ac
Show file tree
Hide file tree
Showing 17 changed files with 382 additions and 82 deletions.
2 changes: 1 addition & 1 deletion examples/hal/quad/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fn main() {
let pipeline_layout = device.create_pipeline_layout(
Some(&set_layout),
&[
(pso::ShaderStageFlags::VERTEX, 0..8),
//(pso::ShaderStageFlags::VERTEX, 0..8), //TODO: use push constants
],
);

Expand Down
6 changes: 3 additions & 3 deletions src/backend/dx11/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern crate winit;
extern crate wio;

use hal::{buffer, command, device, error, format, image, memory, mapping, queue, query, pool, pso, pass, Features, Limits, QueueType};
use hal::{IndexCount, IndexType, InstanceCount, VertexCount, VertexOffset, WorkGroupCount};
use hal::{DrawCount, IndexCount, IndexType, InstanceCount, VertexCount, VertexOffset, WorkGroupCount};
use hal::queue::{QueueFamily as HalQueueFamily, QueueFamilyId, Queues};
use hal::backend::RawQueueGroup;
use hal::format::Aspects;
Expand Down Expand Up @@ -1131,11 +1131,11 @@ impl hal::command::RawCommandBuffer<Backend> for CommandBuffer {
unimplemented!()
}

fn draw_indirect(&mut self, buffer: &Buffer, offset: buffer::Offset, draw_count: u32, stride: u32) {
fn draw_indirect(&mut self, buffer: &Buffer, offset: buffer::Offset, draw_count: DrawCount, stride: u32) {
unimplemented!()
}

fn draw_indexed_indirect(&mut self, buffer: &Buffer, offset: buffer::Offset, draw_count: u32, stride: u32) {
fn draw_indexed_indirect(&mut self, buffer: &Buffer, offset: buffer::Offset, draw_count: DrawCount, stride: u32) {
unimplemented!()
}

Expand Down
6 changes: 3 additions & 3 deletions src/backend/dx12/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

use hal::{buffer, command as com, format, image, memory, pass, pso, query};
use hal::{IndexCount, IndexType, InstanceCount, VertexCount, VertexOffset, WorkGroupCount};
use hal::{DrawCount, IndexCount, IndexType, InstanceCount, VertexCount, VertexOffset, WorkGroupCount};
use hal::format::Aspects;
use hal::range::RangeArg;

Expand Down Expand Up @@ -2183,7 +2183,7 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
&mut self,
buffer: &n::Buffer,
offset: buffer::Offset,
draw_count: u32,
draw_count: DrawCount,
stride: u32,
) {
assert_eq!(stride, 16);
Expand All @@ -2204,7 +2204,7 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
&mut self,
buffer: &n::Buffer,
offset: buffer::Offset,
draw_count: u32,
draw_count: DrawCount,
stride: u32,
) {
assert_eq!(stride, 20);
Expand Down
10 changes: 8 additions & 2 deletions src/backend/empty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,15 +649,21 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
unimplemented!()
}

fn draw_indirect(&mut self, _: &(), _: buffer::Offset, _: u32, _: u32) {
fn draw_indirect(
&mut self,
_: &(),
_: buffer::Offset,
_: hal::DrawCount,
_: u32,
) {
unimplemented!()
}

fn draw_indexed_indirect(
&mut self,
_: &(),
_: buffer::Offset,
_: u32,
_: hal::DrawCount,
_: u32,
) {
unimplemented!()
Expand Down
4 changes: 2 additions & 2 deletions src/backend/gl/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
&mut self,
_buffer: &n::Buffer,
_offset: buffer::Offset,
_draw_count: u32,
_draw_count: hal::DrawCount,
_stride: u32,
) {
unimplemented!()
Expand All @@ -1045,7 +1045,7 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
&mut self,
_buffer: &n::Buffer,
_offset: buffer::Offset,
_draw_count: u32,
_draw_count: hal::DrawCount,
_stride: u32,
) {
unimplemented!()
Expand Down
4 changes: 2 additions & 2 deletions src/backend/metal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ name = "gfx_backend_metal"
gfx-hal = { path = "../../hal", version = "0.1" }
log = "0.4"
winit = { version = "0.13", optional = true }
metal-rs = "0.9.3"
metal-rs = "0.10.1"
foreign-types = "0.3"
objc = "0.2"
block = "0.1"
Expand All @@ -31,4 +31,4 @@ core-foundation = "0.6"
core-graphics = "0.14"
io-surface = "0.10"
smallvec = "0.6"
spirv_cross = "0.8.1"
spirv_cross = "0.9"
Loading

0 comments on commit 1e959ac

Please sign in to comment.