2020-04-23 21:00:52 -04:00
|
|
|
#version 430
|
|
|
|
|
|
|
|
// pathfinder/shaders/fill.cs.glsl
|
|
|
|
//
|
|
|
|
// Copyright © 2020 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
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
#extension GL_GOOGLE_include_directive : enable
|
|
|
|
|
|
|
|
precision highp float;
|
2020-05-08 19:59:01 -04:00
|
|
|
|
|
|
|
#ifdef GL_ES
|
2020-04-23 21:00:52 -04:00
|
|
|
precision highp sampler2D;
|
2020-05-08 19:59:01 -04:00
|
|
|
#endif
|
2020-04-23 21:00:52 -04:00
|
|
|
|
|
|
|
#include "fill.inc.glsl"
|
|
|
|
|
2020-05-04 16:26:40 -04:00
|
|
|
layout(local_size_x = 16, local_size_y = 4) in;
|
2020-04-23 21:00:52 -04:00
|
|
|
|
|
|
|
uniform writeonly image2D uDest;
|
|
|
|
uniform sampler2D uAreaLUT;
|
|
|
|
uniform int uFirstTileIndex;
|
|
|
|
|
|
|
|
layout(std430, binding = 0) buffer bFills {
|
|
|
|
restrict readonly uvec2 iFills[];
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, binding = 1) buffer bNextFills {
|
|
|
|
restrict readonly int iNextFills[];
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, binding = 2) buffer bFillTileMap {
|
|
|
|
restrict readonly int iFillTileMap[];
|
|
|
|
};
|
|
|
|
|
|
|
|
void main() {
|
2020-05-04 16:26:40 -04:00
|
|
|
ivec2 tileSubCoord = ivec2(gl_LocalInvocationID.xy) * ivec2(1, 4);
|
2020-04-23 21:00:52 -04:00
|
|
|
uint tileIndexOffset = gl_WorkGroupID.z;
|
|
|
|
|
|
|
|
uint tileIndex = tileIndexOffset + uint(uFirstTileIndex);
|
|
|
|
|
|
|
|
int fillIndex = iFillTileMap[tileIndex];
|
|
|
|
if (fillIndex < 0)
|
|
|
|
return;
|
|
|
|
|
2020-05-04 16:26:40 -04:00
|
|
|
vec4 coverages = vec4(0.0);
|
2020-04-23 21:00:52 -04:00
|
|
|
do {
|
|
|
|
uvec2 fill = iFills[fillIndex];
|
|
|
|
vec2 from = vec2(fill.y & 0xf, (fill.y >> 4u) & 0xf) +
|
|
|
|
vec2(fill.x & 0xff, (fill.x >> 8u) & 0xff) / 256.0;
|
|
|
|
vec2 to = vec2((fill.y >> 8u) & 0xf, (fill.y >> 12u) & 0xf) +
|
|
|
|
vec2((fill.x >> 16u) & 0xff, (fill.x >> 24u) & 0xff) / 256.0;
|
|
|
|
|
2020-05-04 16:26:40 -04:00
|
|
|
coverages += computeCoverage(from - (vec2(tileSubCoord) + vec2(0.5)),
|
|
|
|
to - (vec2(tileSubCoord) + vec2(0.5)),
|
|
|
|
uAreaLUT);
|
2020-04-23 21:00:52 -04:00
|
|
|
|
|
|
|
fillIndex = iNextFills[fillIndex];
|
|
|
|
} while (fillIndex >= 0);
|
|
|
|
|
2020-05-04 16:26:40 -04:00
|
|
|
ivec2 tileOrigin = ivec2(tileIndex & 0xff, (tileIndex >> 8u) & 0xff) * ivec2(16, 4);
|
|
|
|
ivec2 destCoord = tileOrigin + ivec2(gl_LocalInvocationID.xy);
|
|
|
|
imageStore(uDest, destCoord, coverages);
|
2020-04-23 21:00:52 -04:00
|
|
|
}
|