mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 15:01:01 +01:00
[gpu] Fix WGSL naming: avoid reserved underscore prefix
WGSL reserves identifiers starting with underscore. Use hb_gpu_fetch (no prefix) for the atlas fetch helper, and hb_gpu__* (double underscore mid-identifier) for truly internal functions. Reverts the decode_glyph/curve_counts refactor from the WGSL shader since it was causing compilation failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b884ee12bf
commit
f35ff87a1a
2 files changed
+88
-134
No files matched your search
+44
-67
@@ -35,14 +35,14 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
"const HB_GPU_INV_UNITS: f32 = 1.0 / 4.0;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"fn hbgpu_fetch (hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>,\n"
|
||||
"fn hb_gpu_fetch (hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>,\n"
|
||||
" offset: i32) -> vec4<i32>\n"
|
||||
"{\n"
|
||||
" return (*hb_gpu_atlas)[offset];\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"fn hbgpu_calc_root_code (y1: f32, y2: f32, y3: f32) -> u32\n"
|
||||
"fn hb_gpu__calc_root_code (y1: f32, y2: f32, y3: f32) -> u32\n"
|
||||
"{\n"
|
||||
" let i1 = bitcast<u32> (y1) >> 31u;\n"
|
||||
" let i2 = bitcast<u32> (y2) >> 30u;\n"
|
||||
@@ -54,7 +54,7 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" return (0x2E74u >> shift) & 0x0101u;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn hbgpu_solve_horiz_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f\n"
|
||||
"fn hb_gpu__solve_horiz_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f\n"
|
||||
"{\n"
|
||||
" let ra = 1.0 / a.y;\n"
|
||||
" let rb = 0.5 / b.y;\n"
|
||||
@@ -72,7 +72,7 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" (a.x * t2 - b.x * 2.0) * t2 + p1.x);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn hbgpu_solve_vert_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f\n"
|
||||
"fn hb_gpu__solve_vert_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f\n"
|
||||
"{\n"
|
||||
" let ra = 1.0 / a.x;\n"
|
||||
" let rb = 0.5 / b.x;\n"
|
||||
@@ -90,7 +90,7 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" (a.y * t2 - b.y * 2.0) * t2 + p1.y);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn hbgpu_calc_coverage (xcov: f32, ycov: f32, xwgt: f32, ywgt: f32) -> f32\n"
|
||||
"fn hb_gpu__calc_coverage (xcov: f32, ycov: f32, xwgt: f32, ywgt: f32) -> f32\n"
|
||||
"{\n"
|
||||
" let coverage = max (abs (xcov * xwgt + ycov * ywgt) /\n"
|
||||
" max (xwgt + ywgt, 1.0 / 65536.0),\n"
|
||||
@@ -99,66 +99,43 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" return clamp (coverage, 0.0, 1.0);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"/* Decoded glyph band info for a pixel position. */\n"
|
||||
"struct HbGpuGlyphInfo\n"
|
||||
"{\n"
|
||||
" glyphLoc: i32,\n"
|
||||
" bandBase: i32,\n"
|
||||
" bandIndex: vec2<i32>,\n"
|
||||
" numHBands: i32,\n"
|
||||
" numVBands: i32,\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn hbgpu_decode_glyph (renderCoord: vec2f, glyphLoc_: u32,\n"
|
||||
" hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>) -> HbGpuGlyphInfo\n"
|
||||
"{\n"
|
||||
" var gi: HbGpuGlyphInfo;\n"
|
||||
" gi.glyphLoc = i32 (glyphLoc_);\n"
|
||||
"\n"
|
||||
" let header0 = hbgpu_fetch (hb_gpu_atlas, gi.glyphLoc);\n"
|
||||
" let header1 = hbgpu_fetch (hb_gpu_atlas, gi.glyphLoc + 1);\n"
|
||||
" let ext = vec4f (header0) * HB_GPU_INV_UNITS;\n"
|
||||
" gi.numHBands = header1.r;\n"
|
||||
" gi.numVBands = header1.g;\n"
|
||||
"\n"
|
||||
" let extSize = ext.zw - ext.xy;\n"
|
||||
" let bandScale = vec2f (f32 (gi.numVBands), f32 (gi.numHBands)) / max (extSize, vec2f (1.0 / 65536.0));\n"
|
||||
" let bandOffset = -ext.xy * bandScale;\n"
|
||||
"\n"
|
||||
" gi.bandIndex = clamp (vec2<i32> (renderCoord * bandScale + bandOffset),\n"
|
||||
" vec2<i32> (0, 0),\n"
|
||||
" vec2<i32> (gi.numVBands - 1, gi.numHBands - 1));\n"
|
||||
"\n"
|
||||
" gi.bandBase = gi.glyphLoc + 2;\n"
|
||||
" return gi;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"/* Return per-pixel curve counts: (horizontal, vertical). */\n"
|
||||
"fn hbgpu_curve_counts (renderCoord: vec2f, glyphLoc_: u32,\n"
|
||||
" hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>) -> vec2<i32>\n"
|
||||
"{\n"
|
||||
" let gi = hbgpu_decode_glyph (renderCoord, glyphLoc_, hb_gpu_atlas);\n"
|
||||
" let hCount = hbgpu_fetch (hb_gpu_atlas, gi.bandBase + gi.bandIndex.y).r;\n"
|
||||
" let vCount = hbgpu_fetch (hb_gpu_atlas, gi.bandBase + gi.numHBands + gi.bandIndex.x).r;\n"
|
||||
" return vec2<i32> (hCount, vCount);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"/* Render a glyph and return its coverage in [0, 1]. */\n"
|
||||
"/* Render a glyph and return its coverage in [0, 1].\n"
|
||||
" *\n"
|
||||
" * renderCoord: em-space sample position (interpolated from vertex shader)\n"
|
||||
" * glyphLoc: offset into hb_gpu_atlas for this glyph's encoded blob\n"
|
||||
" * hb_gpu_atlas: storage buffer with the glyph atlas data\n"
|
||||
" */\n"
|
||||
"fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,\n"
|
||||
" hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>) -> f32\n"
|
||||
"{\n"
|
||||
" let emsPerPixel = fwidth (renderCoord);\n"
|
||||
" let pixelsPerEm = 1.0 / emsPerPixel;\n"
|
||||
"\n"
|
||||
" let gi = hbgpu_decode_glyph (renderCoord, glyphLoc_, hb_gpu_atlas);\n"
|
||||
" let glyphLoc = gi.glyphLoc;\n"
|
||||
" let bandBase = gi.bandBase;\n"
|
||||
" let numHBands = gi.numHBands;\n"
|
||||
" let glyphLoc = i32 (glyphLoc_);\n"
|
||||
"\n"
|
||||
" /* Read blob header */\n"
|
||||
" let header0 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc);\n"
|
||||
" let header1 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + 1);\n"
|
||||
" let ext = vec4f (header0) * HB_GPU_INV_UNITS; /* min_x, min_y, max_x, max_y */\n"
|
||||
" let numHBands = header1.r;\n"
|
||||
" let numVBands = header1.g;\n"
|
||||
"\n"
|
||||
" /* Compute band transform from extents */\n"
|
||||
" let extSize = ext.zw - ext.xy; /* (width, height) */\n"
|
||||
" let bandScale = vec2f (f32 (numVBands), f32 (numHBands)) / max (extSize, vec2f (1.0 / 65536.0));\n"
|
||||
" let bandOffset = -ext.xy * bandScale;\n"
|
||||
"\n"
|
||||
" let bandIndex = clamp (vec2<i32> (renderCoord * bandScale + bandOffset),\n"
|
||||
" vec2<i32> (0, 0),\n"
|
||||
" vec2<i32> (numVBands - 1, numHBands - 1));\n"
|
||||
"\n"
|
||||
" /* Skip past header (2 texels) */\n"
|
||||
" let bandBase = glyphLoc + 2;\n"
|
||||
"\n"
|
||||
" var xcov: f32 = 0.0;\n"
|
||||
" var xwgt: f32 = 0.0;\n"
|
||||
"\n"
|
||||
" let hbandData = hbgpu_fetch (hb_gpu_atlas, bandBase + bandIndex.y);\n"
|
||||
" let hbandData = hb_gpu_fetch (hb_gpu_atlas, bandBase + bandIndex.y);\n"
|
||||
" let hCurveCount = hbandData.r;\n"
|
||||
" /* Symmetric: choose rightward (desc) or leftward (asc) sort */\n"
|
||||
" let hSplit = f32 (hbandData.a) * HB_GPU_INV_UNITS;\n"
|
||||
@@ -169,10 +146,10 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
"\n"
|
||||
" for (var ci: i32 = 0; ci < hCurveCount; ci++)\n"
|
||||
" {\n"
|
||||
" let curveOffset = hbgpu_fetch (hb_gpu_atlas, glyphLoc + hDataOffset + ci).r + 32768;\n"
|
||||
" let curveOffset = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + hDataOffset + ci).r + 32768;\n"
|
||||
"\n"
|
||||
" let raw12 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);\n"
|
||||
" let raw3 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);\n"
|
||||
" let raw12 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);\n"
|
||||
" let raw3 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);\n"
|
||||
"\n"
|
||||
" let q12 = vec4f (raw12) * HB_GPU_INV_UNITS;\n"
|
||||
" let q3 = vec2f (vec2<i32> (raw3.r, raw3.g)) * HB_GPU_INV_UNITS;\n"
|
||||
@@ -186,12 +163,12 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" if (max (max (p12.x, p12.z), p3.x) * pixelsPerEm.x < -0.5) { break; }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" let code = hbgpu_calc_root_code (p12.y, p12.w, p3.y);\n"
|
||||
" let code = hb_gpu__calc_root_code (p12.y, p12.w, p3.y);\n"
|
||||
" if (code != 0u)\n"
|
||||
" {\n"
|
||||
" let a = q12.xy - q12.zw * 2.0 + q3;\n"
|
||||
" let b = q12.xy - q12.zw;\n"
|
||||
" let r = hbgpu_solve_horiz_poly (a, b, p12.xy) * pixelsPerEm.x;\n"
|
||||
" let r = hb_gpu__solve_horiz_poly (a, b, p12.xy) * pixelsPerEm.x;\n"
|
||||
" /* For leftward ray: saturate(0.5 - r) counts coverage from the left */\n"
|
||||
" var cov: vec2f;\n"
|
||||
" if (hLeftRay) { cov = clamp (vec2f (0.5) - r, vec2f (0.0), vec2f (1.0)); }\n"
|
||||
@@ -214,7 +191,7 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" var ycov: f32 = 0.0;\n"
|
||||
" var ywgt: f32 = 0.0;\n"
|
||||
"\n"
|
||||
" let vbandData = hbgpu_fetch (hb_gpu_atlas, bandBase + numHBands + gi.bandIndex.x);\n"
|
||||
" let vbandData = hb_gpu_fetch (hb_gpu_atlas, bandBase + numHBands + bandIndex.x);\n"
|
||||
" let vCurveCount = vbandData.r;\n"
|
||||
" let vSplit = f32 (vbandData.a) * HB_GPU_INV_UNITS;\n"
|
||||
" let vLeftRay = (renderCoord.y < vSplit);\n"
|
||||
@@ -224,10 +201,10 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
"\n"
|
||||
" for (var ci: i32 = 0; ci < vCurveCount; ci++)\n"
|
||||
" {\n"
|
||||
" let curveOffset = hbgpu_fetch (hb_gpu_atlas, glyphLoc + vDataOffset + ci).r + 32768;\n"
|
||||
" let curveOffset = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + vDataOffset + ci).r + 32768;\n"
|
||||
"\n"
|
||||
" let raw12 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);\n"
|
||||
" let raw3 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);\n"
|
||||
" let raw12 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);\n"
|
||||
" let raw3 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);\n"
|
||||
"\n"
|
||||
" let q12 = vec4f (raw12) * HB_GPU_INV_UNITS;\n"
|
||||
" let q3 = vec2f (vec2<i32> (raw3.r, raw3.g)) * HB_GPU_INV_UNITS;\n"
|
||||
@@ -241,12 +218,12 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" if (max (max (p12.y, p12.w), p3.y) * pixelsPerEm.y < -0.5) { break; }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" let code = hbgpu_calc_root_code (p12.x, p12.z, p3.x);\n"
|
||||
" let code = hb_gpu__calc_root_code (p12.x, p12.z, p3.x);\n"
|
||||
" if (code != 0u)\n"
|
||||
" {\n"
|
||||
" let a = q12.xy - q12.zw * 2.0 + q3;\n"
|
||||
" let b = q12.xy - q12.zw;\n"
|
||||
" let r = hbgpu_solve_vert_poly (a, b, p12.xy) * pixelsPerEm.y;\n"
|
||||
" let r = hb_gpu__solve_vert_poly (a, b, p12.xy) * pixelsPerEm.y;\n"
|
||||
" var cov: vec2f;\n"
|
||||
" if (vLeftRay) { cov = clamp (vec2f (0.5) - r, vec2f (0.0), vec2f (1.0)); }\n"
|
||||
" else { cov = clamp (r + vec2f (0.5), vec2f (0.0), vec2f (1.0)); }\n"
|
||||
@@ -265,6 +242,6 @@ static const char *hb_gpu_fragment_wgsl =
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" return hbgpu_calc_coverage (xcov, ycov, xwgt, ywgt);\n"
|
||||
" return hb_gpu__calc_coverage (xcov, ycov, xwgt, ywgt);\n"
|
||||
"}\n"
|
||||
;
|
||||
+44
-67
@@ -34,14 +34,14 @@ const HB_GPU_UNITS_PER_EM: f32 = 4.0;
|
||||
const HB_GPU_INV_UNITS: f32 = 1.0 / 4.0;
|
||||
|
||||
|
||||
fn hbgpu_fetch (hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>,
|
||||
fn hb_gpu_fetch (hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>,
|
||||
offset: i32) -> vec4<i32>
|
||||
{
|
||||
return (*hb_gpu_atlas)[offset];
|
||||
}
|
||||
|
||||
|
||||
fn hbgpu_calc_root_code (y1: f32, y2: f32, y3: f32) -> u32
|
||||
fn hb_gpu__calc_root_code (y1: f32, y2: f32, y3: f32) -> u32
|
||||
{
|
||||
let i1 = bitcast<u32> (y1) >> 31u;
|
||||
let i2 = bitcast<u32> (y2) >> 30u;
|
||||
@@ -53,7 +53,7 @@ fn hbgpu_calc_root_code (y1: f32, y2: f32, y3: f32) -> u32
|
||||
return (0x2E74u >> shift) & 0x0101u;
|
||||
}
|
||||
|
||||
fn hbgpu_solve_horiz_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f
|
||||
fn hb_gpu__solve_horiz_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f
|
||||
{
|
||||
let ra = 1.0 / a.y;
|
||||
let rb = 0.5 / b.y;
|
||||
@@ -71,7 +71,7 @@ fn hbgpu_solve_horiz_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f
|
||||
(a.x * t2 - b.x * 2.0) * t2 + p1.x);
|
||||
}
|
||||
|
||||
fn hbgpu_solve_vert_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f
|
||||
fn hb_gpu__solve_vert_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f
|
||||
{
|
||||
let ra = 1.0 / a.x;
|
||||
let rb = 0.5 / b.x;
|
||||
@@ -89,7 +89,7 @@ fn hbgpu_solve_vert_poly (a: vec2f, b: vec2f, p1: vec2f) -> vec2f
|
||||
(a.y * t2 - b.y * 2.0) * t2 + p1.y);
|
||||
}
|
||||
|
||||
fn hbgpu_calc_coverage (xcov: f32, ycov: f32, xwgt: f32, ywgt: f32) -> f32
|
||||
fn hb_gpu__calc_coverage (xcov: f32, ycov: f32, xwgt: f32, ywgt: f32) -> f32
|
||||
{
|
||||
let coverage = max (abs (xcov * xwgt + ycov * ywgt) /
|
||||
max (xwgt + ywgt, 1.0 / 65536.0),
|
||||
@@ -98,66 +98,43 @@ fn hbgpu_calc_coverage (xcov: f32, ycov: f32, xwgt: f32, ywgt: f32) -> f32
|
||||
return clamp (coverage, 0.0, 1.0);
|
||||
}
|
||||
|
||||
/* Decoded glyph band info for a pixel position. */
|
||||
struct HbGpuGlyphInfo
|
||||
{
|
||||
glyphLoc: i32,
|
||||
bandBase: i32,
|
||||
bandIndex: vec2<i32>,
|
||||
numHBands: i32,
|
||||
numVBands: i32,
|
||||
}
|
||||
|
||||
fn hbgpu_decode_glyph (renderCoord: vec2f, glyphLoc_: u32,
|
||||
hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>) -> HbGpuGlyphInfo
|
||||
{
|
||||
var gi: HbGpuGlyphInfo;
|
||||
gi.glyphLoc = i32 (glyphLoc_);
|
||||
|
||||
let header0 = hbgpu_fetch (hb_gpu_atlas, gi.glyphLoc);
|
||||
let header1 = hbgpu_fetch (hb_gpu_atlas, gi.glyphLoc + 1);
|
||||
let ext = vec4f (header0) * HB_GPU_INV_UNITS;
|
||||
gi.numHBands = header1.r;
|
||||
gi.numVBands = header1.g;
|
||||
|
||||
let extSize = ext.zw - ext.xy;
|
||||
let bandScale = vec2f (f32 (gi.numVBands), f32 (gi.numHBands)) / max (extSize, vec2f (1.0 / 65536.0));
|
||||
let bandOffset = -ext.xy * bandScale;
|
||||
|
||||
gi.bandIndex = clamp (vec2<i32> (renderCoord * bandScale + bandOffset),
|
||||
vec2<i32> (0, 0),
|
||||
vec2<i32> (gi.numVBands - 1, gi.numHBands - 1));
|
||||
|
||||
gi.bandBase = gi.glyphLoc + 2;
|
||||
return gi;
|
||||
}
|
||||
|
||||
/* Return per-pixel curve counts: (horizontal, vertical). */
|
||||
fn hbgpu_curve_counts (renderCoord: vec2f, glyphLoc_: u32,
|
||||
hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>) -> vec2<i32>
|
||||
{
|
||||
let gi = hbgpu_decode_glyph (renderCoord, glyphLoc_, hb_gpu_atlas);
|
||||
let hCount = hbgpu_fetch (hb_gpu_atlas, gi.bandBase + gi.bandIndex.y).r;
|
||||
let vCount = hbgpu_fetch (hb_gpu_atlas, gi.bandBase + gi.numHBands + gi.bandIndex.x).r;
|
||||
return vec2<i32> (hCount, vCount);
|
||||
}
|
||||
|
||||
/* Render a glyph and return its coverage in [0, 1]. */
|
||||
/* Render a glyph and return its coverage in [0, 1].
|
||||
*
|
||||
* renderCoord: em-space sample position (interpolated from vertex shader)
|
||||
* glyphLoc: offset into hb_gpu_atlas for this glyph's encoded blob
|
||||
* hb_gpu_atlas: storage buffer with the glyph atlas data
|
||||
*/
|
||||
fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>) -> f32
|
||||
{
|
||||
let emsPerPixel = fwidth (renderCoord);
|
||||
let pixelsPerEm = 1.0 / emsPerPixel;
|
||||
|
||||
let gi = hbgpu_decode_glyph (renderCoord, glyphLoc_, hb_gpu_atlas);
|
||||
let glyphLoc = gi.glyphLoc;
|
||||
let bandBase = gi.bandBase;
|
||||
let numHBands = gi.numHBands;
|
||||
let glyphLoc = i32 (glyphLoc_);
|
||||
|
||||
/* Read blob header */
|
||||
let header0 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc);
|
||||
let header1 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + 1);
|
||||
let ext = vec4f (header0) * HB_GPU_INV_UNITS; /* min_x, min_y, max_x, max_y */
|
||||
let numHBands = header1.r;
|
||||
let numVBands = header1.g;
|
||||
|
||||
/* Compute band transform from extents */
|
||||
let extSize = ext.zw - ext.xy; /* (width, height) */
|
||||
let bandScale = vec2f (f32 (numVBands), f32 (numHBands)) / max (extSize, vec2f (1.0 / 65536.0));
|
||||
let bandOffset = -ext.xy * bandScale;
|
||||
|
||||
let bandIndex = clamp (vec2<i32> (renderCoord * bandScale + bandOffset),
|
||||
vec2<i32> (0, 0),
|
||||
vec2<i32> (numVBands - 1, numHBands - 1));
|
||||
|
||||
/* Skip past header (2 texels) */
|
||||
let bandBase = glyphLoc + 2;
|
||||
|
||||
var xcov: f32 = 0.0;
|
||||
var xwgt: f32 = 0.0;
|
||||
|
||||
let hbandData = hbgpu_fetch (hb_gpu_atlas, bandBase + bandIndex.y);
|
||||
let hbandData = hb_gpu_fetch (hb_gpu_atlas, bandBase + bandIndex.y);
|
||||
let hCurveCount = hbandData.r;
|
||||
/* Symmetric: choose rightward (desc) or leftward (asc) sort */
|
||||
let hSplit = f32 (hbandData.a) * HB_GPU_INV_UNITS;
|
||||
@@ -168,10 +145,10 @@ fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
|
||||
for (var ci: i32 = 0; ci < hCurveCount; ci++)
|
||||
{
|
||||
let curveOffset = hbgpu_fetch (hb_gpu_atlas, glyphLoc + hDataOffset + ci).r + 32768;
|
||||
let curveOffset = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + hDataOffset + ci).r + 32768;
|
||||
|
||||
let raw12 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);
|
||||
let raw3 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);
|
||||
let raw12 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);
|
||||
let raw3 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);
|
||||
|
||||
let q12 = vec4f (raw12) * HB_GPU_INV_UNITS;
|
||||
let q3 = vec2f (vec2<i32> (raw3.r, raw3.g)) * HB_GPU_INV_UNITS;
|
||||
@@ -185,12 +162,12 @@ fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
if (max (max (p12.x, p12.z), p3.x) * pixelsPerEm.x < -0.5) { break; }
|
||||
}
|
||||
|
||||
let code = hbgpu_calc_root_code (p12.y, p12.w, p3.y);
|
||||
let code = hb_gpu__calc_root_code (p12.y, p12.w, p3.y);
|
||||
if (code != 0u)
|
||||
{
|
||||
let a = q12.xy - q12.zw * 2.0 + q3;
|
||||
let b = q12.xy - q12.zw;
|
||||
let r = hbgpu_solve_horiz_poly (a, b, p12.xy) * pixelsPerEm.x;
|
||||
let r = hb_gpu__solve_horiz_poly (a, b, p12.xy) * pixelsPerEm.x;
|
||||
/* For leftward ray: saturate(0.5 - r) counts coverage from the left */
|
||||
var cov: vec2f;
|
||||
if (hLeftRay) { cov = clamp (vec2f (0.5) - r, vec2f (0.0), vec2f (1.0)); }
|
||||
@@ -213,7 +190,7 @@ fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
var ycov: f32 = 0.0;
|
||||
var ywgt: f32 = 0.0;
|
||||
|
||||
let vbandData = hbgpu_fetch (hb_gpu_atlas, bandBase + numHBands + gi.bandIndex.x);
|
||||
let vbandData = hb_gpu_fetch (hb_gpu_atlas, bandBase + numHBands + bandIndex.x);
|
||||
let vCurveCount = vbandData.r;
|
||||
let vSplit = f32 (vbandData.a) * HB_GPU_INV_UNITS;
|
||||
let vLeftRay = (renderCoord.y < vSplit);
|
||||
@@ -223,10 +200,10 @@ fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
|
||||
for (var ci: i32 = 0; ci < vCurveCount; ci++)
|
||||
{
|
||||
let curveOffset = hbgpu_fetch (hb_gpu_atlas, glyphLoc + vDataOffset + ci).r + 32768;
|
||||
let curveOffset = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + vDataOffset + ci).r + 32768;
|
||||
|
||||
let raw12 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);
|
||||
let raw3 = hbgpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);
|
||||
let raw12 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset);
|
||||
let raw3 = hb_gpu_fetch (hb_gpu_atlas, glyphLoc + curveOffset + 1);
|
||||
|
||||
let q12 = vec4f (raw12) * HB_GPU_INV_UNITS;
|
||||
let q3 = vec2f (vec2<i32> (raw3.r, raw3.g)) * HB_GPU_INV_UNITS;
|
||||
@@ -240,12 +217,12 @@ fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
if (max (max (p12.y, p12.w), p3.y) * pixelsPerEm.y < -0.5) { break; }
|
||||
}
|
||||
|
||||
let code = hbgpu_calc_root_code (p12.x, p12.z, p3.x);
|
||||
let code = hb_gpu__calc_root_code (p12.x, p12.z, p3.x);
|
||||
if (code != 0u)
|
||||
{
|
||||
let a = q12.xy - q12.zw * 2.0 + q3;
|
||||
let b = q12.xy - q12.zw;
|
||||
let r = hbgpu_solve_vert_poly (a, b, p12.xy) * pixelsPerEm.y;
|
||||
let r = hb_gpu__solve_vert_poly (a, b, p12.xy) * pixelsPerEm.y;
|
||||
var cov: vec2f;
|
||||
if (vLeftRay) { cov = clamp (vec2f (0.5) - r, vec2f (0.0), vec2f (1.0)); }
|
||||
else { cov = clamp (r + vec2f (0.5), vec2f (0.0), vec2f (1.0)); }
|
||||
@@ -264,5 +241,5 @@ fn hb_gpu_render (renderCoord: vec2f, glyphLoc_: u32,
|
||||
}
|
||||
}
|
||||
|
||||
return hbgpu_calc_coverage (xcov, ycov, xwgt, ywgt);
|
||||
return hb_gpu__calc_coverage (xcov, ycov, xwgt, ywgt);
|
||||
}
|
||||
Reference in new issue
Block a user