Skip to content

Instantly share code, notes, and snippets.

@litherum
Last active May 31, 2019 19:32
Show Gist options
  • Save litherum/ae5f6b81ab37c853876335d6f78530ac to your computer and use it in GitHub Desktop.
Save litherum/ae5f6b81ab37c853876335d6f78530ac to your computer and use it in GitHub Desktop.
struct InnerVertexOut {
float4 extra : attribute(0);
}
Struct VertexOut {
float4 position : SV_Position;
InnerVertexOut innerVertexOut;
}
struct VertexInput {
float something : attribute(0);
}
vertex VertexOut vertexShader(VertexInput vertexInput, float somethingElse : attribute(1)) { ... }
===============================================
struct MetalStageInParameters {
 float metalSomething [[ attribute(0) ]];
float metalSomethingElse [[ attribute(1) ]];
};
struct MetalVertexOut {
float4 metalPosition [[ position ]];
float4 metalExtra [[ user(user0) ]];
};
vertex MetalVertexOut metalVertexShader(MetalStageInParameters metalStageInParameters) {
VertexInput vertexInput;
float somethingElse;
vertexInput.something = metalStageInParameters.metalSomething;
somethingElse = metalStageInParameters.metalSomethingElse;
...
/* "return foo" gets turned into */
metalVertexOut metalVertexOut;
metalVertexOut.metalPosition = foo.position;
metalVertexOut.metalExtra = foo.innerVertexOut.extra;
return metalVertexOut;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment