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

Metal support #2

Open
keijiro opened this issue Oct 31, 2017 · 3 comments
Open

Metal support #2

keijiro opened this issue Oct 31, 2017 · 3 comments
Assignees

Comments

@keijiro
Copy link
Owner

keijiro commented Oct 31, 2017

Metal doesn't have geometry shader. It has to be emulated by using compute + procedural indirect draw.

@millerhooks
Copy link

millerhooks commented Oct 31, 2017

Thanks so much for the quick response! I'm really new at this fancy shader stuff, but I found this discussion over here with this snippet.

I reading the Disk shader it looks to me that I'd do the combination in the geometry phase in Disk.cginc. I'm going to keep playing with it, but I figured I'd mention my thinking here and see if you have any resources to point me at. The topic seems to be sparsely discussed on the internet or I just have no idea what I'm trying to google.

https://forums.developer.apple.com/thread/4818

render_vertex(const device VertexInput* v_in [[ buffer(0) ]],  
              constant float4x4& mvp_matrix [[ buffer(1) ]],  
              constant LightDesc& light_desc [[ buffer(2) ]],  
              device VertexOutput* xform_output [[ buffer(3) ]],  
              uint v_id [[ vertex_id ]] )  
{  
    VertexOutput v_out;  
    v_out.position = v_in[v_id].position * mvp_matrix;  
    v_out.color = do_lighting(v_in[v_id].position,  
                    v_in[v_id].normal,  
                    light_desc);  
  
  
    v_out.texcoord = v_in[v_id].texcoord;  
  
  
    // output position to a buffer  
    xform_output[v_id] = v_out.position;  
}  

@keijiro
Copy link
Owner Author

keijiro commented Oct 31, 2017

That thread in the Apple forum is not relevant to Unity. Please ignore it. That's almost meaningless for this case.

I've implemented a non-geometry shader variant of the disk shader in compute-2 branch.
https://github.com/keijiro/Pcx/commits/compute-2

I rejected this variant because it's not performant compared to the original (geometry shader).

I've verified that it works on Metal, so, I should rethink about it. It's not performant but useful for compatibility.

@millerhooks
Copy link

Oh perfect. That’ll get me where I’m going with this demo. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants