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

Fix Metal backend #1165

Merged
merged 4 commits into from Jan 31, 2017

Conversation

@JohnColanduoni
Copy link
Member

commented Jan 30, 2017

I've updated the parts of the Metal backend that were out of date, allowing the examples to run. I also fixed the stencil buffer support and improved the mechanism for applying clear/clear_depth/clear_stencil commands.

@kvark
Copy link
Member

left a comment

This is some impressive work here! I wasn't aware of you doing that, hope the work doesn't conflict with anything other devs are doing.
I think it looks reasonable, but leaving to @fkaa for the final decision.

#[macro_use]
extern crate gfx;
extern crate gfx_window_glutin;
extern crate glutin;
extern crate gfx_app;

This comment has been minimized.

Copy link
@kvark

kvark Jan 30, 2017

Member

I'm sorry, but we'd prefer to keep triangle example to be straight without basing on gfx_app.

@@ -34,12 +34,17 @@ use native::{Rtv, Srv, Dsv};
use metal::*;

use std::ptr;
use std::collections::HashMap;
use std::collections::hash_map::Entry;

This comment has been minimized.

Copy link
@kvark

kvark Jan 30, 2017

Member

nit: could include both from hash_map::

if let Some(val) = clear {
attachment.set_load_action(MTLLoadAction::Clear);
attachment.set_clear_depth(val as f64);
if let Entry::Occupied(mut clear_entry) = self.dsv_clear.entry(depth) {

This comment has been minimized.

Copy link
@kvark

kvark Jan 30, 2017

Member

I don't think you need to use the Entry API here, just a regular get_mut should do

This comment has been minimized.

Copy link
@JohnColanduoni

JohnColanduoni Jan 30, 2017

Author Member

The reason I used it is that the entry may need to be deleted entirely, not just modified. If get_mut is used there would be two lookups in that case. For the depth target this is conditional so I can't simplify it to a remove(), but the render target analogue always removes the entry if present. I'll change that to remove() instead of mucking about with Entries.

@kvark

This comment has been minimized.

Copy link
Member

commented Jan 30, 2017

Cleaned up pull request
Removed changes to triangle example, cleaned up imports, and
simplified HashMap usage.
@@ -247,6 +247,10 @@ impl core::Factory<Resources> for Factory {
.object_at(0)
.set_pixel_format(MTLPixelFormat::BGRA8Unorm_sRGB);

// We need fake depth attachments in case explicit writes to the depth buffer are required
pso_descriptor.set_depth_attachment_pixel_format(MTLPixelFormat::Depth24Unorm_Stencil8);

This comment has been minimized.

Copy link
@fkaa

fkaa Jan 31, 2017

Member

I get an error for this:
/Library/Caches/com.apple.xbs/Sources/Metal/Metal-85.82.1/Framework/MTLRenderPipeline.mm:1571: failed assertion `depthAttachmentPixelFormat is not a valid MTLPixelFormat.'
Switching out for MTLPixelFormat::Depth32_Stencil8 works though

This comment has been minimized.

Copy link
@JohnColanduoni

JohnColanduoni Jan 31, 2017

Author Member

Good catch, apparently D24S8 is only supported on some OS X GPUs (and not at all on iOS). According to the docs all feature sets support Depth32_Stencil8 so that's a good choice.

@fkaa

This comment has been minimized.

Copy link
Member

commented Jan 31, 2017

Other than the triggered assertion on my end looks good to merge 👍

@kvark

This comment has been minimized.

Copy link
Member

commented Jan 31, 2017

Awesome, thanks @JohnColanduoni and @fkaa !
@homu r+

@homu

This comment has been minimized.

Copy link
Contributor

commented Jan 31, 2017

📌 Commit 255f54d has been approved by kvark

homu added a commit that referenced this pull request Jan 31, 2017

Auto merge of #1165 - JohnColanduoni:master, r=kvark
Fix Metal backend

I've updated the parts of the Metal backend that were out of date, allowing the examples to run. I also fixed the stencil buffer support and improved the mechanism for applying clear/clear_depth/clear_stencil commands.
@homu

This comment has been minimized.

Copy link
Contributor

commented Jan 31, 2017

☀️ Test successful - status

@homu homu merged commit 255f54d into gfx-rs:master Jan 31, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

JohnColanduoni added a commit to JohnColanduoni/gfx that referenced this pull request Jun 16, 2017

Squashed 'vendor/gfx/' changes from a404273..244fbf9
244fbf9 Fix metal-rs and cocoa versions to be consistent
52abefc Added Metal shader library support
911db3b Auto merge of gfx-rs#1173 - kvark:sdl, r=kvark
cdc06fe Proper SDL window flag selection
4916c0f Partly generalize gfx_window_sdl::init
a4cc291 Auto merge of gfx-rs#1166 - Bastacyclop:strict_access, r=kvark
96e28e8 Improve access overlap management
d51dbfe Stricter mapping access behavior
c87d35b Auto merge of gfx-rs#1162 - msiglreith:core_merge, r=kvark
5ba6651 Refactor away the Instance trait and replace iterator with slice
9a43b33 Auto merge of gfx-rs#1167 - nical:categories, r=kvark
359d258 Add the rendering::graphics-api category gfx's Cargo.toml
4d252a3 Auto merge of gfx-rs#1165 - JohnColanduoni:master, r=kvark
255f54d Switch to more compatible pixel format for shader reflection
365b28e Cleaned up pull request
9c41297 Merge commit 'f899521aa3054e7e761b169b243bbd2fd21b1513'
f73dddb Updated Metal backend enough to get examples running, added stencil attachments
f947f1c Migrate low level core API changes to core.

git-subtree-dir: vendor/gfx
git-subtree-split: 244fbf9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.