• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#pragma clang diagnostic ignored "-Wmissing-prototypes"
2
3#include <metal_stdlib>
4#include <simd/simd.h>
5
6using namespace metal;
7
8struct main0_out
9{
10    float4 FragColor [[color(0)]];
11};
12
13// Returns 2D texture coords corresponding to 1D texel buffer coords
14static inline __attribute__((always_inline))
15uint2 spvTexelBufferCoord(uint tc)
16{
17    return uint2(tc % 4096, tc / 4096);
18}
19
20fragment main0_out main0(texture2d<float> buf [[texture(0)]], texture2d<float, access::write> bufOut [[texture(1)]], float4 gl_FragCoord [[position]])
21{
22    main0_out out = {};
23    out.FragColor = buf.read(spvTexelBufferCoord(0));
24    bufOut.write(out.FragColor, spvTexelBufferCoord(int(gl_FragCoord.x)));
25    return out;
26}
27
28