Add Metal shaders, cross-compiled from the GLSL via SPIR-V.

The Metal shaders are checked into the repository for convenience, but they
should not be directly edited. Instead, edit the corresponding GLSL shader in
the top-level `shaders/` directory, and rerun `make` in there.
This commit is contained in:
Patrick Walton 2019-06-05 17:20:12 -07:00
parent 678e12aed6
commit 9f9233c153
90 changed files with 1709 additions and 102 deletions

View File

@ -225,18 +225,12 @@ impl Device for GLDevice {
texture
}
fn create_shader_from_source(&self,
resources: &dyn ResourceLoader,
name: &str,
source: &[u8],
kind: ShaderKind,
includes: &[&str])
-> GLShader {
fn create_shader_from_source(&self, name: &str, source: &[u8], kind: ShaderKind) -> GLShader {
// FIXME(pcwalton): Do this once and cache it.
let glsl_version_spec = self.version.to_glsl_version_spec();
let mut output = vec![];
self.preprocess(&mut output, resources, source, includes, glsl_version_spec);
self.preprocess(&mut output, source, glsl_version_spec);
let source = output;
let gl_shader_kind = match kind {
@ -650,12 +644,7 @@ impl Device for GLDevice {
}
impl GLDevice {
fn preprocess(&self,
output: &mut Vec<u8>,
resources: &dyn ResourceLoader,
source: &[u8],
includes: &[&str],
version: &str) {
fn preprocess(&self, output: &mut Vec<u8>, source: &[u8], version: &str) {
let mut index = 0;
while index < source.len() {
if source[index..].starts_with(b"{{") {
@ -666,12 +655,6 @@ impl GLDevice {
let ident = String::from_utf8_lossy(&source[(index + 2)..end_index]);
if ident == "version" {
output.extend_from_slice(version.as_bytes());
} else if ident.starts_with("include_") {
let include_name = &ident["include_".len()..];
if includes.iter().any(|include| *include == include_name) {
let include_source = self.load_shader_include(resources, include_name);
self.preprocess(output, resources, &include_source, includes, version);
}
} else {
panic!("unknown template variable: `{}`", ident);
}

View File

@ -21,15 +21,6 @@ use std::time::Duration;
pub mod resources;
static INCLUDES: [&str; 6] = [
"tile_alpha_vertex",
"tile_monochrome",
"tile_multicolor",
"tile_solid_vertex",
"post_convolve",
"post_gamma_correct",
];
pub trait Device {
type Buffer;
type Framebuffer;
@ -43,14 +34,8 @@ pub trait Device {
fn create_texture(&self, format: TextureFormat, size: Vector2I) -> Self::Texture;
fn create_texture_from_data(&self, size: Vector2I, data: &[u8]) -> Self::Texture;
fn create_shader_from_source(
&self,
resources: &dyn ResourceLoader,
name: &str,
source: &[u8],
kind: ShaderKind,
includes: &[&str],
) -> Self::Shader;
fn create_shader_from_source(&self, name: &str, source: &[u8], kind: ShaderKind)
-> Self::Shader;
fn create_vertex_array(&self) -> Self::VertexArray;
fn create_program_from_shaders(
&self,
@ -117,8 +102,8 @@ pub trait Device {
ShaderKind::Vertex => 'v',
ShaderKind::Fragment => 'f',
};
let source = resources.slurp(&format!("shaders/{}.{}s.glsl", name, suffix)).unwrap();
self.create_shader_from_source(resources, name, &source, kind, &INCLUDES)
let source = resources.slurp(&format!("shaders/gl3/{}.{}s.glsl", name, suffix)).unwrap();
self.create_shader_from_source(name, &source, kind)
}
fn create_program_from_shader_names(
@ -137,10 +122,6 @@ pub trait Device {
fn create_program(&self, resources: &dyn ResourceLoader, name: &str) -> Self::Program {
self.create_program_from_shader_names(resources, name, name, name)
}
fn load_shader_include(&self, resources: &dyn ResourceLoader, include_name: &str) -> Vec<u8> {
resources.slurp(&format!("shaders/{}.inc.glsl", include_name)).unwrap()
}
}
#[derive(Clone, Copy, Debug)]

View File

@ -0,0 +1,7 @@
This directory contains postprocessed versions of the shaders in the top-level
`shaders/` directory, for convenience. Don't modify the shaders here; instead
modify the corresponding shaders in `shaders/` and rerun `make` in that
directory.
You will need `glslangValidator` and `spirv-cross` installed to execute the
Makefile. On macOS, you can get these with `brew install glslang spirv-cross`.

View File

@ -0,0 +1,22 @@
#version {{version}}
precision highp float;
uniform vec4 uColor;
out vec4 oFragColor;
void main(){
oFragColor = vec4(uColor . rgb, 1.0)* uColor . a;
}

View File

@ -0,0 +1,23 @@
#version {{version}}
precision highp float;
uniform vec2 uFramebufferSize;
in vec2 aPosition;
void main(){
vec2 position = aPosition / uFramebufferSize * 2.0 - 1.0;
gl_Position = vec4(position . x, - position . y, 0.0, 1.0);
}

View File

@ -0,0 +1,26 @@
#version {{version}}
precision highp float;
uniform sampler2D uTexture;
uniform vec4 uColor;
in vec2 vTexCoord;
out vec4 oFragColor;
void main(){
float alpha = texture(uTexture, vTexCoord). r * uColor . a;
oFragColor = alpha * vec4(uColor . rgb, 1.0);
}

View File

@ -0,0 +1,28 @@
#version {{version}}
precision highp float;
uniform vec2 uFramebufferSize;
uniform vec2 uTextureSize;
in vec2 aPosition;
in vec2 aTexCoord;
out vec2 vTexCoord;
void main(){
vTexCoord = aTexCoord / uTextureSize;
vec2 position = aPosition / uFramebufferSize * 2.0 - 1.0;
gl_Position = vec4(position . x, - position . y, 0.0, 1.0);
}

View File

@ -0,0 +1,26 @@
#version {{version}}
precision highp float;
uniform vec4 uGroundColor;
uniform vec4 uGridlineColor;
in vec2 vTexCoord;
out vec4 oFragColor;
void main(){
vec2 texCoordPx = fract(vTexCoord)/ fwidth(vTexCoord);
oFragColor = any(lessThanEqual(texCoordPx, vec2(1.0)))? uGridlineColor : uGroundColor;
}

View File

@ -0,0 +1,26 @@
#version {{version}}
precision highp float;
uniform mat4 uTransform;
uniform int uGridlineCount;
in vec2 aPosition;
out vec2 vTexCoord;
void main(){
vTexCoord = aPosition * float(uGridlineCount);
gl_Position = uTransform * vec4(aPosition . x, 0.0, aPosition . y, 1.0);
}

View File

@ -0,0 +1,42 @@
#version {{version}}
precision highp float;
uniform sampler2D uAreaLUT;
in vec2 vFrom;
in vec2 vTo;
out vec4 oFragColor;
void main(){
vec2 from = vFrom, to = vTo;
vec2 left = from . x < to . x ? from : to, right = from . x < to . x ? to : from;
vec2 window = clamp(vec2(from . x, to . x), - 0.5, 0.5);
float offset = mix(window . x, window . y, 0.5)- left . x;
float t = offset /(right . x - left . x);
float y = mix(left . y, right . y, t);
float d =(right . y - left . y)/(right . x - left . x);
float dX = window . x - window . y;
oFragColor = vec4(texture(uAreaLUT, vec2(y + 8.0, abs(d * dX))/ 16.0). r * dX);
}

View File

@ -0,0 +1,55 @@
#version {{version}}
precision highp float;
uniform vec2 uFramebufferSize;
uniform vec2 uTileSize;
in vec2 aTessCoord;
in uint aFromPx;
in uint aToPx;
in vec2 aFromSubpx;
in vec2 aToSubpx;
in uint aTileIndex;
out vec2 vFrom;
out vec2 vTo;
vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth){
uint tilesPerRow = uint(stencilTextureWidth / uTileSize . x);
uvec2 tileOffset = uvec2(aTileIndex % tilesPerRow, aTileIndex / tilesPerRow);
return vec2(tileOffset)* uTileSize;
}
void main(){
vec2 tileOrigin = computeTileOffset(aTileIndex, uFramebufferSize . x);
vec2 from = vec2(aFromPx & 15u, aFromPx >> 4u)+ aFromSubpx;
vec2 to = vec2(aToPx & 15u, aToPx >> 4u)+ aToSubpx;
vec2 position;
if(aTessCoord . x < 0.5)
position . x = floor(min(from . x, to . x));
else
position . x = ceil(max(from . x, to . x));
if(aTessCoord . y < 0.5)
position . y = floor(min(from . y, to . y));
else
position . y = uTileSize . y;
vFrom = from - position;
vTo = to - position;
gl_Position = vec4((tileOrigin + position)/ uFramebufferSize * 2.0 - 1.0, 0.0, 1.0);
}

View File

@ -0,0 +1,125 @@
#version {{version}}
#extension GL_GOOGLE_include_directive : enable
precision highp float;
uniform sampler2D uSource;
uniform vec2 uSourceSize;
uniform vec4 uFGColor;
uniform vec4 uBGColor;
uniform int uGammaCorrectionEnabled;
in vec2 vTexCoord;
out vec4 oFragColor;
uniform sampler2D uGammaLUT;
float gammaCorrectChannel(float bgColor, float fgColor){
return texture(uGammaLUT, vec2(fgColor, 1.0 - bgColor)). r;
}
vec3 gammaCorrect(vec3 bgColor, vec3 fgColor){
return vec3(gammaCorrectChannel(bgColor . r, fgColor . r),
gammaCorrectChannel(bgColor . g, fgColor . g),
gammaCorrectChannel(bgColor . b, fgColor . b));
}
uniform vec4 uKernel;
float sample1Tap(float offset);
void sample9Tap(out vec4 outAlphaLeft,
out float outAlphaCenter,
out vec4 outAlphaRight,
float onePixel){
outAlphaLeft = vec4(uKernel . x > 0.0 ? sample1Tap(- 4.0 * onePixel): 0.0,
sample1Tap(- 3.0 * onePixel),
sample1Tap(- 2.0 * onePixel),
sample1Tap(- 1.0 * onePixel));
outAlphaCenter = sample1Tap(0.0);
outAlphaRight = vec4(sample1Tap(1.0 * onePixel),
sample1Tap(2.0 * onePixel),
sample1Tap(3.0 * onePixel),
uKernel . x > 0.0 ? sample1Tap(4.0 * onePixel): 0.0);
}
float convolve7Tap(vec4 alpha0, vec3 alpha1){
return dot(alpha0, uKernel)+ dot(alpha1, uKernel . zyx);
}
float sample1Tap(float offset){
return texture(uSource, vec2(vTexCoord . x + offset, vTexCoord . y)). r;
}
void main(){
vec3 alpha;
if(uKernel . w == 0.0){
alpha = texture(uSource, vTexCoord). rrr;
} else {
vec4 alphaLeft, alphaRight;
float alphaCenter;
sample9Tap(alphaLeft, alphaCenter, alphaRight, 1.0 / uSourceSize . x);
float r = convolve7Tap(alphaLeft, vec3(alphaCenter, alphaRight . xy));
float g = convolve7Tap(vec4(alphaLeft . yzw, alphaCenter), alphaRight . xyz);
float b = convolve7Tap(vec4(alphaLeft . zw, alphaCenter, alphaRight . x), alphaRight . yzw);
alpha = vec3(r, g, b);
}
if(uGammaCorrectionEnabled != 0)
alpha = gammaCorrect(uBGColor . rgb, alpha);
oFragColor = vec4(mix(uBGColor . rgb, uFGColor . rgb, alpha), 1.0);
}

View File

@ -0,0 +1,23 @@
#version {{version}}
precision highp float;
in vec2 aPosition;
out vec2 vTexCoord;
void main(){
vTexCoord = aPosition;
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
}

View File

@ -0,0 +1,27 @@
#version {{version}}
precision highp float;
uniform mat4 uOldTransform;
uniform sampler2D uTexture;
in vec2 vTexCoord;
out vec4 oFragColor;
void main(){
vec4 normTexCoord = uOldTransform * vec4(vTexCoord, 0.0, 1.0);
vec2 texCoord =((normTexCoord . xy / normTexCoord . w)+ 1.0)* 0.5;
oFragColor = texture(uTexture, texCoord);
}

View File

@ -0,0 +1,25 @@
#version {{version}}
precision highp float;
uniform mat4 uNewTransform;
in vec2 aPosition;
out vec2 vTexCoord;
void main(){
vTexCoord = aPosition;
gl_Position = uNewTransform * vec4(aPosition, 0.0, 1.0);
}

View File

@ -0,0 +1,21 @@
#version {{version}}
precision highp float;
out vec4 oFragColor;
void main(){
oFragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

View File

@ -0,0 +1,20 @@
#version {{version}}
precision highp float;
in vec3 aPosition;
void main(){
gl_Position = vec4(aPosition, 1.0);
}

View File

@ -0,0 +1,27 @@
#version {{version}}
precision highp float;
uniform sampler2D uStencilTexture;
in vec2 vTexCoord;
in float vBackdrop;
in vec4 vColor;
out vec4 oFragColor;
void main(){
float coverage = abs(texture(uStencilTexture, vTexCoord). r + vBackdrop);
oFragColor = vec4(vColor . rgb, vColor . a * coverage);
}

View File

@ -0,0 +1,85 @@
#version {{version}}
#extension GL_GOOGLE_include_directive : enable
precision highp float;
uniform vec2 uFramebufferSize;
uniform vec2 uTileSize;
uniform vec2 uStencilTextureSize;
uniform vec2 uViewBoxOrigin;
in vec2 aTessCoord;
in uvec3 aTileOrigin;
in int aBackdrop;
in uint aTileIndex;
out vec2 vTexCoord;
out float vBackdrop;
out vec4 vColor;
vec4 getColor();
vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth){
uint tilesPerRow = uint(stencilTextureWidth / uTileSize . x);
uvec2 tileOffset = uvec2(tileIndex % tilesPerRow, tileIndex / tilesPerRow);
return vec2(tileOffset)* uTileSize;
}
void computeVaryings(){
vec2 origin = vec2(aTileOrigin . xy)+ vec2(aTileOrigin . z & 15u, aTileOrigin . z >> 4u)* 256.0;
vec2 pixelPosition =(origin + aTessCoord)* uTileSize + uViewBoxOrigin;
vec2 position =(pixelPosition / uFramebufferSize * 2.0 - 1.0)* vec2(1.0, - 1.0);
vec2 maskTexCoordOrigin = computeTileOffset(aTileIndex, uStencilTextureSize . x);
vec2 maskTexCoord = maskTexCoordOrigin + aTessCoord * uTileSize;
vTexCoord = maskTexCoord / uStencilTextureSize;
vBackdrop = float(aBackdrop);
vColor = getColor();
gl_Position = vec4(position, 0.0, 1.0);
}
uniform vec4 uColor;
vec4 getColor(){
return uColor;
}
void main(){
computeVaryings();
}

View File

@ -0,0 +1,88 @@
#version {{version}}
#extension GL_GOOGLE_include_directive : enable
precision highp float;
uniform vec2 uFramebufferSize;
uniform vec2 uTileSize;
uniform vec2 uStencilTextureSize;
uniform vec2 uViewBoxOrigin;
in vec2 aTessCoord;
in uvec3 aTileOrigin;
in int aBackdrop;
in uint aTileIndex;
out vec2 vTexCoord;
out float vBackdrop;
out vec4 vColor;
vec4 getColor();
vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth){
uint tilesPerRow = uint(stencilTextureWidth / uTileSize . x);
uvec2 tileOffset = uvec2(tileIndex % tilesPerRow, tileIndex / tilesPerRow);
return vec2(tileOffset)* uTileSize;
}
void computeVaryings(){
vec2 origin = vec2(aTileOrigin . xy)+ vec2(aTileOrigin . z & 15u, aTileOrigin . z >> 4u)* 256.0;
vec2 pixelPosition =(origin + aTessCoord)* uTileSize + uViewBoxOrigin;
vec2 position =(pixelPosition / uFramebufferSize * 2.0 - 1.0)* vec2(1.0, - 1.0);
vec2 maskTexCoordOrigin = computeTileOffset(aTileIndex, uStencilTextureSize . x);
vec2 maskTexCoord = maskTexCoordOrigin + aTessCoord * uTileSize;
vTexCoord = maskTexCoord / uStencilTextureSize;
vBackdrop = float(aBackdrop);
vColor = getColor();
gl_Position = vec4(position, 0.0, 1.0);
}
uniform sampler2D uPaintTexture;
uniform vec2 uPaintTextureSize;
in vec2 aColorTexCoord;
vec4 getColor(){
return texture(uPaintTexture, aColorTexCoord);
}
void main(){
computeVaryings();
}

View File

@ -0,0 +1,22 @@
#version {{version}}
precision highp float;
in vec4 vColor;
out vec4 oFragColor;
void main(){
oFragColor = vColor;
}

View File

@ -0,0 +1,69 @@
#version {{version}}
#extension GL_GOOGLE_include_directive : enable
precision highp float;
uniform vec2 uFramebufferSize;
uniform vec2 uTileSize;
uniform vec2 uViewBoxOrigin;
in vec2 aTessCoord;
in vec2 aTileOrigin;
out vec4 vColor;
vec4 getColor();
void computeVaryings(){
vec2 pixelPosition =(aTileOrigin + aTessCoord)* uTileSize + uViewBoxOrigin;
vec2 position =(pixelPosition / uFramebufferSize * 2.0 - 1.0)* vec2(1.0, - 1.0);
vColor = getColor();
gl_Position = vec4(position, 0.0, 1.0);
}
uniform vec4 uColor;
vec4 getColor(){
return uColor;
}
void main(){
computeVaryings();
}

View File

@ -0,0 +1,72 @@
#version {{version}}
#extension GL_GOOGLE_include_directive : enable
precision highp float;
uniform vec2 uFramebufferSize;
uniform vec2 uTileSize;
uniform vec2 uViewBoxOrigin;
in vec2 aTessCoord;
in vec2 aTileOrigin;
out vec4 vColor;
vec4 getColor();
void computeVaryings(){
vec2 pixelPosition =(aTileOrigin + aTessCoord)* uTileSize + uViewBoxOrigin;
vec2 position =(pixelPosition / uFramebufferSize * 2.0 - 1.0)* vec2(1.0, - 1.0);
vColor = getColor();
gl_Position = vec4(position, 0.0, 1.0);
}
uniform sampler2D uPaintTexture;
uniform vec2 uPaintTextureSize;
in vec2 aColorTexCoord;
vec4 getColor(){
return texture(uPaintTexture, aColorTexCoord);
}
void main(){
computeVaryings();
}

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
fragment main0_out main0(float4 uColor [[buffer(0)]])
{
main0_out out = {};
out.oFragColor = float4(uColor.xyz, 1.0) * uColor.w;
return out;
}

View File

@ -0,0 +1,23 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aPosition [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], float2 uFramebufferSize [[buffer(0)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
float2 position = ((in.aPosition / uFramebufferSize) * 2.0) - float2(1.0);
out.gl_Position = float4(position.x, -position.y, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,23 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float2 vTexCoord [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4 uColor [[buffer(0)]], texture2d<float> uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]])
{
main0_out out = {};
float alpha = uTexture.sample(uTextureSmplr, in.vTexCoord).x * uColor.w;
out.oFragColor = float4(uColor.xyz, 1.0) * alpha;
return out;
}

View File

@ -0,0 +1,26 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vTexCoord [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aPosition [[attribute(0)]];
float2 aTexCoord [[attribute(1)]];
};
vertex main0_out main0(main0_in in [[stage_in]], float2 uTextureSize [[buffer(0)]], float2 uFramebufferSize [[buffer(1)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
out.vTexCoord = in.aTexCoord / uTextureSize;
float2 position = ((in.aPosition / uFramebufferSize) * 2.0) - float2(1.0);
out.gl_Position = float4(position.x, -position.y, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,24 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float2 vTexCoord [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4 uGridlineColor [[buffer(0)]], float4 uGroundColor [[buffer(1)]])
{
main0_out out = {};
float2 texCoordPx = fract(in.vTexCoord) / fwidth(in.vTexCoord);
bool4 _33 = bool4(any(texCoordPx <= float2(1.0)));
out.oFragColor = float4(_33.x ? uGridlineColor.x : uGroundColor.x, _33.y ? uGridlineColor.y : uGroundColor.y, _33.z ? uGridlineColor.z : uGroundColor.z, _33.w ? uGridlineColor.w : uGroundColor.w);
return out;
}

View File

@ -0,0 +1,24 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vTexCoord [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aPosition [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], int uGridlineCount [[buffer(0)]], float4x4 uTransform [[buffer(1)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
out.vTexCoord = in.aPosition * float(uGridlineCount);
out.gl_Position = uTransform * float4(in.aPosition.x, 0.0, in.aPosition.y, 1.0);
return out;
}

View File

@ -0,0 +1,35 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float2 vFrom [[user(locn0)]];
float2 vTo [[user(locn1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> uAreaLUT [[texture(0)]], sampler uAreaLUTSmplr [[sampler(0)]])
{
main0_out out = {};
float2 from = in.vFrom;
float2 to = in.vTo;
bool2 _29 = bool2(from.x < to.x);
float2 left = float2(_29.x ? from.x : to.x, _29.y ? from.y : to.y);
bool2 _39 = bool2(from.x < to.x);
float2 right = float2(_39.x ? to.x : from.x, _39.y ? to.y : from.y);
float2 window = fast::clamp(float2(from.x, to.x), float2(-0.5), float2(0.5));
float offset = mix(window.x, window.y, 0.5) - left.x;
float t = offset / (right.x - left.x);
float y = mix(left.y, right.y, t);
float d = (right.y - left.y) / (right.x - left.x);
float dX = window.x - window.y;
out.oFragColor = float4(uAreaLUT.sample(uAreaLUTSmplr, (float2(y + 8.0, abs(d * dX)) / float2(16.0))).x * dX);
return out;
}

View File

@ -0,0 +1,62 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vFrom [[user(locn0)]];
float2 vTo [[user(locn1)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aTessCoord [[attribute(0)]];
uint aFromPx [[attribute(1)]];
uint aToPx [[attribute(2)]];
float2 aFromSubpx [[attribute(3)]];
float2 aToSubpx [[attribute(4)]];
uint aTileIndex [[attribute(5)]];
};
float2 computeTileOffset(thread const uint& tileIndex, thread const float& stencilTextureWidth, thread float2 uTileSize, thread uint& aTileIndex)
{
uint tilesPerRow = uint(stencilTextureWidth / uTileSize.x);
uint2 tileOffset = uint2(aTileIndex % tilesPerRow, aTileIndex / tilesPerRow);
return float2(tileOffset) * uTileSize;
}
vertex main0_out main0(main0_in in [[stage_in]], float2 uTileSize [[buffer(0)]], float2 uFramebufferSize [[buffer(1)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
uint param = in.aTileIndex;
float param_1 = uFramebufferSize.x;
float2 tileOrigin = computeTileOffset(param, param_1, uTileSize, in.aTileIndex);
float2 from = float2(float(in.aFromPx & 15u), float(in.aFromPx >> 4u)) + in.aFromSubpx;
float2 to = float2(float(in.aToPx & 15u), float(in.aToPx >> 4u)) + in.aToSubpx;
float2 position;
if (in.aTessCoord.x < 0.5)
{
position.x = floor(fast::min(from.x, to.x));
}
else
{
position.x = ceil(fast::max(from.x, to.x));
}
if (in.aTessCoord.y < 0.5)
{
position.y = floor(fast::min(from.y, to.y));
}
else
{
position.y = uTileSize.y;
}
out.vFrom = from - position;
out.vTo = to - position;
out.gl_Position = float4((((tileOrigin + position) / uFramebufferSize) * 2.0) - float2(1.0), 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,119 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float2 vTexCoord [[user(locn0)]];
};
float sample1Tap(thread const float& offset, thread texture2d<float> uSource, thread const sampler uSourceSmplr, thread float2& vTexCoord)
{
return uSource.sample(uSourceSmplr, float2(vTexCoord.x + offset, vTexCoord.y)).x;
}
void sample9Tap(thread float4& outAlphaLeft, thread float& outAlphaCenter, thread float4& outAlphaRight, thread const float& onePixel, thread float4 uKernel, thread texture2d<float> uSource, thread const sampler uSourceSmplr, thread float2& vTexCoord)
{
float _89;
if (uKernel.x > 0.0)
{
float param = (-4.0) * onePixel;
_89 = sample1Tap(param, uSource, uSourceSmplr, vTexCoord);
}
else
{
_89 = 0.0;
}
float param_1 = (-3.0) * onePixel;
float param_2 = (-2.0) * onePixel;
float param_3 = (-1.0) * onePixel;
outAlphaLeft = float4(_89, sample1Tap(param_1, uSource, uSourceSmplr, vTexCoord), sample1Tap(param_2, uSource, uSourceSmplr, vTexCoord), sample1Tap(param_3, uSource, uSourceSmplr, vTexCoord));
float param_4 = 0.0;
outAlphaCenter = sample1Tap(param_4, uSource, uSourceSmplr, vTexCoord);
float param_5 = 1.0 * onePixel;
float _120 = sample1Tap(param_5, uSource, uSourceSmplr, vTexCoord);
float param_6 = 2.0 * onePixel;
float _125 = sample1Tap(param_6, uSource, uSourceSmplr, vTexCoord);
float param_7 = 3.0 * onePixel;
float _130 = sample1Tap(param_7, uSource, uSourceSmplr, vTexCoord);
float _134;
if (uKernel.x > 0.0)
{
float param_8 = 4.0 * onePixel;
_134 = sample1Tap(param_8, uSource, uSourceSmplr, vTexCoord);
}
else
{
_134 = 0.0;
}
outAlphaRight = float4(_120, _125, _130, _134);
}
float convolve7Tap(thread const float4& alpha0, thread const float3& alpha1, thread float4 uKernel)
{
return dot(alpha0, uKernel) + dot(alpha1, uKernel.zyx);
}
float gammaCorrectChannel(thread const float& bgColor, thread const float& fgColor, thread texture2d<float> uGammaLUT, thread const sampler uGammaLUTSmplr)
{
return uGammaLUT.sample(uGammaLUTSmplr, float2(fgColor, 1.0 - bgColor)).x;
}
float3 gammaCorrect(thread const float3& bgColor, thread const float3& fgColor, thread texture2d<float> uGammaLUT, thread const sampler uGammaLUTSmplr)
{
float param = bgColor.x;
float param_1 = fgColor.x;
float param_2 = bgColor.y;
float param_3 = fgColor.y;
float param_4 = bgColor.z;
float param_5 = fgColor.z;
return float3(gammaCorrectChannel(param, param_1, uGammaLUT, uGammaLUTSmplr), gammaCorrectChannel(param_2, param_3, uGammaLUT, uGammaLUTSmplr), gammaCorrectChannel(param_4, param_5, uGammaLUT, uGammaLUTSmplr));
}
fragment main0_out main0(main0_in in [[stage_in]], int uGammaCorrectionEnabled [[buffer(2)]], float4 uKernel [[buffer(0)]], float2 uSourceSize [[buffer(1)]], float4 uBGColor [[buffer(3)]], float4 uFGColor [[buffer(4)]], texture2d<float> uGammaLUT [[texture(0)]], texture2d<float> uSource [[texture(0)]], sampler uGammaLUTSmplr [[sampler(0)]], sampler uSourceSmplr [[sampler(0)]])
{
main0_out out = {};
float3 alpha;
if (uKernel.w == 0.0)
{
alpha = uSource.sample(uSourceSmplr, in.vTexCoord).xxx;
}
else
{
float param_3 = 1.0 / uSourceSize.x;
float4 param;
float param_1;
float4 param_2;
sample9Tap(param, param_1, param_2, param_3, uKernel, uSource, uSourceSmplr, in.vTexCoord);
float4 alphaLeft = param;
float alphaCenter = param_1;
float4 alphaRight = param_2;
float4 param_4 = alphaLeft;
float3 param_5 = float3(alphaCenter, alphaRight.xy);
float r = convolve7Tap(param_4, param_5, uKernel);
float4 param_6 = float4(alphaLeft.yzw, alphaCenter);
float3 param_7 = alphaRight.xyz;
float g = convolve7Tap(param_6, param_7, uKernel);
float4 param_8 = float4(alphaLeft.zw, alphaCenter, alphaRight.x);
float3 param_9 = alphaRight.yzw;
float b = convolve7Tap(param_8, param_9, uKernel);
alpha = float3(r, g, b);
}
if (uGammaCorrectionEnabled != 0)
{
float3 param_10 = uBGColor.xyz;
float3 param_11 = alpha;
alpha = gammaCorrect(param_10, param_11, uGammaLUT, uGammaLUTSmplr);
}
out.oFragColor = float4(mix(uBGColor.xyz, uFGColor.xyz, alpha), 1.0);
return out;
}

View File

@ -0,0 +1,24 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vTexCoord [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aPosition [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
out.vTexCoord = in.aPosition;
out.gl_Position = float4((in.aPosition * 2.0) - float2(1.0), 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,24 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float2 vTexCoord [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4x4 uOldTransform [[buffer(0)]], texture2d<float> uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]])
{
main0_out out = {};
float4 normTexCoord = uOldTransform * float4(in.vTexCoord, 0.0, 1.0);
float2 texCoord = ((normTexCoord.xy / float2(normTexCoord.w)) + float2(1.0)) * 0.5;
out.oFragColor = uTexture.sample(uTextureSmplr, texCoord);
return out;
}

View File

@ -0,0 +1,24 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vTexCoord [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aPosition [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], float4x4 uNewTransform [[buffer(0)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
out.vTexCoord = in.aPosition;
out.gl_Position = uNewTransform * float4(in.aPosition, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
out.oFragColor = float4(1.0, 0.0, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,22 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float3 aPosition [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
out.gl_Position = float4(in.aPosition, 1.0);
return out;
}

View File

@ -0,0 +1,25 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float2 vTexCoord [[user(locn0)]];
float vBackdrop [[user(locn1)]];
float4 vColor [[user(locn2)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> uStencilTexture [[texture(0)]], sampler uStencilTextureSmplr [[sampler(0)]])
{
main0_out out = {};
float coverage = abs(uStencilTexture.sample(uStencilTextureSmplr, in.vTexCoord).x + in.vBackdrop);
out.oFragColor = float4(in.vColor.xyz, in.vColor.w * coverage);
return out;
}

View File

@ -0,0 +1,57 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vTexCoord [[user(locn0)]];
float vBackdrop [[user(locn1)]];
float4 vColor [[user(locn2)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aTessCoord [[attribute(0)]];
uint3 aTileOrigin [[attribute(1)]];
int aBackdrop [[attribute(2)]];
uint aTileIndex [[attribute(3)]];
};
float2 computeTileOffset(thread const uint& tileIndex, thread const float& stencilTextureWidth, thread float2 uTileSize)
{
uint tilesPerRow = uint(stencilTextureWidth / uTileSize.x);
uint2 tileOffset = uint2(tileIndex % tilesPerRow, tileIndex / tilesPerRow);
return float2(tileOffset) * uTileSize;
}
float4 getColor(thread float4 uColor)
{
return uColor;
}
void computeVaryings(thread float2 uTileSize, thread uint3& aTileOrigin, thread float2& aTessCoord, thread float2 uViewBoxOrigin, thread float2 uFramebufferSize, thread uint& aTileIndex, thread float2 uStencilTextureSize, thread float2& vTexCoord, thread float& vBackdrop, thread int& aBackdrop, thread float4& vColor, thread float4& gl_Position, thread float4 uColor)
{
float2 origin = float2(aTileOrigin.xy) + (float2(float(aTileOrigin.z & 15u), float(aTileOrigin.z >> 4u)) * 256.0);
float2 pixelPosition = ((origin + aTessCoord) * uTileSize) + uViewBoxOrigin;
float2 position = (((pixelPosition / uFramebufferSize) * 2.0) - float2(1.0)) * float2(1.0, -1.0);
uint param = aTileIndex;
float param_1 = uStencilTextureSize.x;
float2 maskTexCoordOrigin = computeTileOffset(param, param_1, uTileSize);
float2 maskTexCoord = maskTexCoordOrigin + (aTessCoord * uTileSize);
vTexCoord = maskTexCoord / uStencilTextureSize;
vBackdrop = float(aBackdrop);
vColor = getColor(uColor);
gl_Position = float4(position, 0.0, 1.0);
}
vertex main0_out main0(main0_in in [[stage_in]], float2 uTileSize [[buffer(0)]], float2 uViewBoxOrigin [[buffer(1)]], float2 uFramebufferSize [[buffer(2)]], float2 uStencilTextureSize [[buffer(3)]], float4 uColor [[buffer(4)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
computeVaryings(uTileSize, in.aTileOrigin, in.aTessCoord, uViewBoxOrigin, uFramebufferSize, in.aTileIndex, uStencilTextureSize, out.vTexCoord, out.vBackdrop, in.aBackdrop, out.vColor, out.gl_Position, uColor);
return out;
}

View File

@ -0,0 +1,58 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float2 vTexCoord [[user(locn0)]];
float vBackdrop [[user(locn1)]];
float4 vColor [[user(locn2)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aTessCoord [[attribute(0)]];
uint3 aTileOrigin [[attribute(1)]];
int aBackdrop [[attribute(2)]];
uint aTileIndex [[attribute(3)]];
float2 aColorTexCoord [[attribute(4)]];
};
float2 computeTileOffset(thread const uint& tileIndex, thread const float& stencilTextureWidth, thread float2 uTileSize)
{
uint tilesPerRow = uint(stencilTextureWidth / uTileSize.x);
uint2 tileOffset = uint2(tileIndex % tilesPerRow, tileIndex / tilesPerRow);
return float2(tileOffset) * uTileSize;
}
float4 getColor(thread texture2d<float> uPaintTexture, thread const sampler uPaintTextureSmplr, thread float2& aColorTexCoord)
{
return uPaintTexture.sample(uPaintTextureSmplr, aColorTexCoord, level(0.0));
}
void computeVaryings(thread float2 uTileSize, thread uint3& aTileOrigin, thread float2& aTessCoord, thread float2 uViewBoxOrigin, thread float2 uFramebufferSize, thread uint& aTileIndex, thread float2 uStencilTextureSize, thread float2& vTexCoord, thread float& vBackdrop, thread int& aBackdrop, thread float4& vColor, thread float4& gl_Position, thread texture2d<float> uPaintTexture, thread const sampler uPaintTextureSmplr, thread float2& aColorTexCoord)
{
float2 origin = float2(aTileOrigin.xy) + (float2(float(aTileOrigin.z & 15u), float(aTileOrigin.z >> 4u)) * 256.0);
float2 pixelPosition = ((origin + aTessCoord) * uTileSize) + uViewBoxOrigin;
float2 position = (((pixelPosition / uFramebufferSize) * 2.0) - float2(1.0)) * float2(1.0, -1.0);
uint param = aTileIndex;
float param_1 = uStencilTextureSize.x;
float2 maskTexCoordOrigin = computeTileOffset(param, param_1, uTileSize);
float2 maskTexCoord = maskTexCoordOrigin + (aTessCoord * uTileSize);
vTexCoord = maskTexCoord / uStencilTextureSize;
vBackdrop = float(aBackdrop);
vColor = getColor(uPaintTexture, uPaintTextureSmplr, aColorTexCoord);
gl_Position = float4(position, 0.0, 1.0);
}
vertex main0_out main0(main0_in in [[stage_in]], float2 uTileSize [[buffer(0)]], float2 uViewBoxOrigin [[buffer(1)]], float2 uFramebufferSize [[buffer(2)]], float2 uStencilTextureSize [[buffer(3)]], texture2d<float> uPaintTexture [[texture(0)]], sampler uPaintTextureSmplr [[sampler(0)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
computeVaryings(uTileSize, in.aTileOrigin, in.aTessCoord, uViewBoxOrigin, uFramebufferSize, in.aTileIndex, uStencilTextureSize, out.vTexCoord, out.vBackdrop, in.aBackdrop, out.vColor, out.gl_Position, uPaintTexture, uPaintTextureSmplr, in.aColorTexCoord);
return out;
}

View File

@ -0,0 +1,22 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 oFragColor [[color(0)]];
};
struct main0_in
{
float4 vColor [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.oFragColor = in.vColor;
return out;
}

View File

@ -0,0 +1,39 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 vColor [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aTessCoord [[attribute(0)]];
float2 aTileOrigin [[attribute(1)]];
};
float4 getColor(thread float4 uColor)
{
return uColor;
}
void computeVaryings(thread float2& aTileOrigin, thread float2& aTessCoord, thread float2 uTileSize, thread float2 uViewBoxOrigin, thread float2 uFramebufferSize, thread float4& vColor, thread float4& gl_Position, thread float4 uColor)
{
float2 pixelPosition = ((aTileOrigin + aTessCoord) * uTileSize) + uViewBoxOrigin;
float2 position = (((pixelPosition / uFramebufferSize) * 2.0) - float2(1.0)) * float2(1.0, -1.0);
vColor = getColor(uColor);
gl_Position = float4(position, 0.0, 1.0);
}
vertex main0_out main0(main0_in in [[stage_in]], float2 uTileSize [[buffer(0)]], float2 uViewBoxOrigin [[buffer(1)]], float2 uFramebufferSize [[buffer(2)]], float4 uColor [[buffer(3)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
computeVaryings(in.aTileOrigin, in.aTessCoord, uTileSize, uViewBoxOrigin, uFramebufferSize, out.vColor, out.gl_Position, uColor);
return out;
}

View File

@ -0,0 +1,40 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 vColor [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float2 aTessCoord [[attribute(0)]];
float2 aTileOrigin [[attribute(1)]];
float2 aColorTexCoord [[attribute(2)]];
};
float4 getColor(thread texture2d<float> uPaintTexture, thread const sampler uPaintTextureSmplr, thread float2& aColorTexCoord)
{
return uPaintTexture.sample(uPaintTextureSmplr, aColorTexCoord, level(0.0));
}
void computeVaryings(thread float2& aTileOrigin, thread float2& aTessCoord, thread float2 uTileSize, thread float2 uViewBoxOrigin, thread float2 uFramebufferSize, thread float4& vColor, thread float4& gl_Position, thread texture2d<float> uPaintTexture, thread const sampler uPaintTextureSmplr, thread float2& aColorTexCoord)
{
float2 pixelPosition = ((aTileOrigin + aTessCoord) * uTileSize) + uViewBoxOrigin;
float2 position = (((pixelPosition / uFramebufferSize) * 2.0) - float2(1.0)) * float2(1.0, -1.0);
vColor = getColor(uPaintTexture, uPaintTextureSmplr, aColorTexCoord);
gl_Position = float4(position, 0.0, 1.0);
}
vertex main0_out main0(main0_in in [[stage_in]], float2 uTileSize [[buffer(0)]], float2 uViewBoxOrigin [[buffer(1)]], float2 uFramebufferSize [[buffer(2)]], texture2d<float> uPaintTexture [[texture(0)]], sampler uPaintTextureSmplr [[sampler(0)]], uint gl_VertexID [[vertex_id]], uint gl_InstanceID [[instance_id]])
{
main0_out out = {};
computeVaryings(in.aTileOrigin, in.aTessCoord, uTileSize, uViewBoxOrigin, uFramebufferSize, out.vColor, out.gl_Position, uPaintTexture, uPaintTextureSmplr, in.aColorTexCoord);
return out;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

69
shaders/Makefile Normal file
View File

@ -0,0 +1,69 @@
TARGET_DIR?=../resources/shaders
EMPTY=
SHADERS=\
debug_solid.fs.glsl \
debug_solid.vs.glsl \
debug_texture.fs.glsl \
debug_texture.vs.glsl \
demo_ground.fs.glsl \
demo_ground.vs.glsl \
fill.fs.glsl \
fill.vs.glsl \
post.fs.glsl \
post.vs.glsl \
reproject.fs.glsl \
reproject.vs.glsl \
stencil.fs.glsl \
stencil.vs.glsl \
tile_alpha.fs.glsl \
tile_alpha_monochrome.vs.glsl \
tile_alpha_multicolor.vs.glsl \
tile_solid.fs.glsl \
tile_solid_monochrome.vs.glsl \
tile_solid_multicolor.vs.glsl \
$(EMPTY)
INCLUDES=\
post_convolve.inc.glsl \
tile_alpha_vertex.inc.glsl \
tile_multicolor.inc.glsl \
post_gamma_correct.inc.glsl \
tile_monochrome.inc.glsl \
tile_solid_vertex.inc.glsl \
$(EMPTY)
OUT=\
$(SHADERS:%=$(TARGET_DIR)/gl3/%) \
$(SHADERS:%.glsl=$(TARGET_DIR)/metal/%.metal) \
$(EMPTY)
GLSL_VERSION=330
GLSLANGFLAGS=--auto-map-locations -I.
SPIRVCROSSFLAGS=--msl
SED_ARGS=-e "s/\#version 330/\#version \{\{version\}\}/" -e "s/\#line.*$$//"
all: $(OUT)
.PHONY: clean
clean:
rm -f $(OUT)
$(TARGET_DIR)/spirv/%.fs.spv: %.fs.glsl $(INCLUDES)
mkdir -p $(TARGET_DIR)/spirv && glslangValidator $(GLSLANGFLAGS) -G$(GLSL_VERSION) -S frag -o $@ $<
$(TARGET_DIR)/gl3/%.fs.glsl: %.fs.glsl $(INCLUDES)
mkdir -p $(TARGET_DIR)/gl3 && glslangValidator $(GLSLANGFLAGS) -S frag -E $< | sed $(SED_ARGS) > $@
$(TARGET_DIR)/spirv/%.vs.spv: %.vs.glsl $(INCLUDES)
mkdir -p $(TARGET_DIR)/spirv && glslangValidator $(GLSLANGFLAGS) -G$(GLSL_VERSION) -S vert -o $@ $<
$(TARGET_DIR)/gl3/%.vs.glsl: %.vs.glsl $(INCLUDES)
mkdir -p $(TARGET_DIR)/gl3 && glslangValidator $(GLSLANGFLAGS) -S vert -E $< | sed $(SED_ARGS) > $@
$(TARGET_DIR)/metal/%.metal: $(TARGET_DIR)/spirv/%.spv
mkdir -p $(TARGET_DIR)/metal && spirv-cross $(SPIRVCROSSFLAGS) --output $@ $<

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/shaders/debug_solid.fs.glsl
// pathfinder/shaders/debug_solid.fs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/shaders/debug_solid.vs.glsl
// pathfinder/shaders/debug_solid.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/debug_texture.fs.glsl
// pathfinder/shaders/debug_texture.fs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/shaders/debug_texture.vs.glsl
// pathfinder/shaders/debug_texture.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/resources/shaders/demo_ground.fs.glsl
// pathfinder/resources/shaders/demo_ground.fs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/resources/shaders/demo_ground.vs.glsl
// pathfinder/resources/shaders/demo_ground.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,8 +1,8 @@
#version {{version}}
#version 330
// pathfinder/demo2/stencil.fs.glsl
// pathfinder/shaders/stencil.fs.glsl
//
// Copyright © 2018 The Pathfinder Project Developers.
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/fill.vs.glsl
// pathfinder/resources/fill.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/post.fs.glsl
// pathfinder/shaders/post.fs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//
@ -13,6 +13,8 @@
// TODO(pcwalton): This could be significantly optimized by operating on a
// sparse per-tile basis.
#extension GL_GOOGLE_include_directive : enable
precision highp float;
uniform sampler2D uSource;
@ -25,8 +27,8 @@ in vec2 vTexCoord;
out vec4 oFragColor;
{{include_post_gamma_correct}}
{{include_post_convolve}}
#include "post_gamma_correct.inc.glsl"
#include "post_convolve.inc.glsl"
// Convolve horizontally in this pass.
float sample1Tap(float offset) {

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/post.vs.glsl
// pathfinder/shaders/post.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,4 +1,4 @@
// pathfinder/resources/shaders/post_convolve.inc.glsl
// pathfinder/shaders/post_convolve.inc.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,4 +1,4 @@
// pathfinder/resources/shaders/post_gamma_correct.inc.glsl
// pathfinder/shaders/post_gamma_correct.inc.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/reproject.fs.glsl
// pathfinder/shaders/reproject.fs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/reproject.vs.glsl
// pathfinder/shaders/reproject.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/stencil.fs.glsl
// pathfinder/shaders/stencil.fs.glsl
//
// Copyright © 2018 The Pathfinder Project Developers.
//

View File

@ -1,8 +1,8 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/stencil.vs.glsl
// pathfinder/shaders/stencil.vs.glsl
//
// Copyright © 2018 The Pathfinder Project Developers.
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/demo/resources/shaders/mask_tile.fs.glsl
// pathfinder/shaders/tile_alpha.fs.glsl
//
// Copyright © 2018 The Pathfinder Project Developers.
//

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/tile_alpha_monochrome.vs.glsl
// pathfinder/shaders/tile_alpha_monochrome.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//
@ -10,10 +10,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#extension GL_GOOGLE_include_directive : enable
precision highp float;
{{include_tile_alpha_vertex}}
{{include_tile_monochrome}}
#include "tile_alpha_vertex.inc.glsl"
#include "tile_monochrome.inc.glsl"
void main() {
computeVaryings();

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/tile_alpha_multicolor.vs.glsl
// pathfinder/shaders/tile_alpha_multicolor.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//
@ -10,10 +10,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#extension GL_GOOGLE_include_directive : enable
precision highp float;
{{include_tile_alpha_vertex}}
{{include_tile_multicolor}}
#include "tile_alpha_vertex.inc.glsl"
#include "tile_multicolor.inc.glsl"
void main() {
computeVaryings();

View File

@ -1,4 +1,4 @@
// pathfinder/resources/shaders/tile_alpha_vertex.inc.glsl
// pathfinder/shaders/tile_alpha_vertex.inc.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,4 +1,4 @@
// pathfinder/resources/shaders/tile_monochrome.inc.glsl
// pathfinder/shaders/tile_monochrome.inc.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,4 +1,4 @@
// pathfinder/resources/shaders/tile_multicolor.inc.glsl
// pathfinder/shaders/tile_multicolor.inc.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//

View File

@ -1,8 +1,8 @@
#version {{version}}
#version 330
// pathfinder/demo2/opaque.fs.glsl
// pathfinder/shaders/tile_solid.fs.glsl
//
// Copyright © 2018 The Pathfinder Project Developers.
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/tile_solid_monochrome.vs.glsl
// pathfinder/shaders/tile_solid_monochrome.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//
@ -10,10 +10,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#extension GL_GOOGLE_include_directive : enable
precision highp float;
{{include_tile_solid_vertex}}
{{include_tile_monochrome}}
#include "tile_solid_vertex.inc.glsl"
#include "tile_monochrome.inc.glsl"
void main() {
computeVaryings();

View File

@ -1,6 +1,6 @@
#version {{version}}
#version 330
// pathfinder/resources/shaders/tile_solid_multicolor.vs.glsl
// pathfinder/shaders/tile_solid_multicolor.vs.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//
@ -10,10 +10,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#extension GL_GOOGLE_include_directive : enable
precision highp float;
{{include_tile_solid_vertex}}
{{include_tile_multicolor}}
#include "tile_solid_vertex.inc.glsl"
#include "tile_multicolor.inc.glsl"
void main() {
computeVaryings();

View File

@ -1,4 +1,4 @@
// pathfinder/resources/shaders/tile_solid_vertex.inc.glsl
// pathfinder/shaders/tile_solid_vertex.inc.glsl
//
// Copyright © 2019 The Pathfinder Project Developers.
//