skia2/tests/sksl/compute/Buffers.metal
Ethan Nicholas 4144b8abb4 Added preliminary SkSL Metal compute shader support
This adds mostly-functional compute shader output to SkSL. This does not
add overall compute shader support to Skia; it still needs to be
integrated into the Skia pipeline before it is possible to actually use
compute shaders in practice.

Change-Id: Ic5c69863704f141d16bb191224a817e44f4a8565
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/539060
Reviewed-by: Arman Uguray <armansito@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2022-06-15 18:52:42 +00:00

16 lines
438 B
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
uint3 sk_ThreadPosition;
device int* src;
};
struct Outputs {
device int* dest;
};
kernel void computeMain(device int* src, device int* dest, uint3 sk_ThreadPosition [[thread_position_in_grid]]) {
Inputs _in = { sk_ThreadPosition, src };
Outputs _out = { dest };
_out.dest[_in.sk_ThreadPosition.x] = _in.src[_in.sk_ThreadPosition.x] * 2;
}