...

Text file src/github.com/alecthomas/chroma/lexers/testdata/metal.actual

Documentation: github.com/alecthomas/chroma/lexers/testdata

     1#include <metal_stdlib>
     2
     3using namespace metal;
     4
     5// Include header shared between C code and .metal files.
     6#include "AAPLShaderTypes.h"
     7
     8// Include header shared between all .metal files.
     9#include "AAPLShaderCommon.h"
    10
    11struct VertexOutput
    12{
    13    float4 position [[position]];
    14};
    15
    16// A depth pre-pass is necessary in forward plus rendering to produce
    17// minimum and maximum depth bounds for light culling.
    18vertex VertexOutput depth_pre_pass_vertex(Vertex in [[ stage_in ]],
    19                                          constant AAPLFrameData & frameData [[ buffer(AAPLBufferIndexFrameData) ]])
    20{
    21    // Make the position a float4 to perform 4x4 matrix math on it.
    22    VertexOutput out;
    23    float4 position = float4(in.position, 1.0);
    24
    25    // Calculate the position in clip space.
    26    out.position = frameData.projectionMatrix * frameData.modelViewMatrix * position;
    27
    28    return out;
    29}
    30
    31fragment ColorData depth_pre_pass_fragment(VertexOutput in [[ stage_in ]])
    32{
    33    // Populate on-tile geometry buffer data.
    34    ColorData f;
    35
    36    // Setting color in the depth pre-pass is unnecessary, but may make debugging easier.
    37    // f.lighting = half4(0, 0, 0, 1);
    38
    39    // Set the depth in clip space, which you use in `AAPLCulling` to perform per-tile light culling.
    40    f.depth = in.position.z;
    41
    42    return f;
    43}

View as plain text