From 2068171f96c492c71040cd70edafd65b4b50b4b5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 1 Dec 2020 17:59:37 +0100 Subject: [PATCH] path_coarse.comp: tighten variable scopes, delete unused variables No functional changes. Signed-off-by: Elias Naur --- piet-gpu/shader/path_coarse.comp | 30 +++++++++++++----------------- piet-gpu/shader/path_coarse.spv | Bin 28876 -> 28916 bytes 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/piet-gpu/shader/path_coarse.comp b/piet-gpu/shader/path_coarse.comp index 658af0e..069d13b 100644 --- a/piet-gpu/shader/path_coarse.comp +++ b/piet-gpu/shader/path_coarse.comp @@ -101,12 +101,6 @@ void main() { if (element_ix < n_pathseg) { tag = PathSeg_tag(ref); } - // Setup for coverage algorithm. - float a, b, c; - // Bounding box of element in pixel coordinates. - float xmin, xmax, ymin, ymax; - PathStrokeLine line; - float dx; switch (tag) { case PathSeg_FillCubic: case PathSeg_StrokeCubic: @@ -162,22 +156,24 @@ void main() { } // Output line segment - xmin = min(p0.x, p1.x) - cubic.stroke.x; - xmax = max(p0.x, p1.x) + cubic.stroke.x; - ymin = min(p0.y, p1.y) - cubic.stroke.y; - ymax = max(p0.y, p1.y) + cubic.stroke.y; + + // Bounding box of element in pixel coordinates. + float xmin = min(p0.x, p1.x) - cubic.stroke.x; + float xmax = max(p0.x, p1.x) + cubic.stroke.x; + float ymin = min(p0.y, p1.y) - cubic.stroke.y; + float ymax = max(p0.y, p1.y) + cubic.stroke.y; float dx = p1.x - p0.x; float dy = p1.y - p0.y; // Set up for per-scanline coverage formula, below. float invslope = abs(dy) < 1e-9 ? 1e9 : dx / dy; - c = (cubic.stroke.x + abs(invslope) * (0.5 * float(TILE_HEIGHT_PX) + cubic.stroke.y)) * SX; - b = invslope; // Note: assumes square tiles, otherwise scale. - a = (p0.x - (p0.y - 0.5 * float(TILE_HEIGHT_PX)) * b) * SX; + float c = (cubic.stroke.x + abs(invslope) * (0.5 * float(TILE_HEIGHT_PX) + cubic.stroke.y)) * SX; + float b = invslope; // Note: assumes square tiles, otherwise scale. + float a = (p0.x - (p0.y - 0.5 * float(TILE_HEIGHT_PX)) * b) * SX; - int x0 = int(floor((xmin) * SX)); - int x1 = int(ceil((xmax) * SX)); - int y0 = int(floor((ymin) * SY)); - int y1 = int(ceil((ymax) * SY)); + int x0 = int(floor(xmin * SX)); + int x1 = int(ceil(xmax * SX)); + int y0 = int(floor(ymin * SY)); + int y1 = int(ceil(ymax * SY)); x0 = clamp(x0, bbox.x, bbox.z); y0 = clamp(y0, bbox.y, bbox.w); diff --git a/piet-gpu/shader/path_coarse.spv b/piet-gpu/shader/path_coarse.spv index f82a031295caaf30b5e4075547981235bfe9d90c..3ba2cff61fa355dc14b10e644fa7c579fdf4a0bf 100644 GIT binary patch delta 6341 zcmZ9Q37A%8702J%5ODx)N<~a4MN`xyF*6xrB26u6AW$le8RV1D5p19u%DUiErfv46 zl4e0sIw~RzyST5oi;}iSWrZ!~f})l7``x*R=QiK-yuAPa|D5-n^KSRv;o+?{FK?|G zSXaCME-BTd0jYo5vSQ%TgHB&wm(u(rQff$bX_a_XFWwC9IzwEaegU34uXEOnN-zH% ze0uv_n7m)w2A@4`-mH$wwDyjUIgC%UyE@x7 z=OYfNZXMK=9U5Mpl{0%S^=TB^x$T|p=M<4f_u=o2F_jJ?)unOpt}e6Gr4w^JD#w$= zMU2y8Ozzi^+Isn*%Cu7AO7*hAO{bSrpB2N3RI}l8I%eb(m>agam6=g`7ux)3l^HXO z6L-2l+pL|#NmGG1nw8;B`o`esl zKNMC|o6=M8Cwng6Yk5QF-m=~4SX|d)a({!5Mt6^cYj>Z^+>kqtvC0oeJac7r-Z=@Yn zLkhNRGTKdW^|2h|ZhCn$HvMk~x6v*t#;*XYT|sN)H0ZMuOgOH4O4=iCPaWH%(ZHS) zgq?v`gJ;nq@EWjMIq+I|1lAstSO?Ztp2T{%y16`q^5!(GcZM4vOKC04!ackN+)dwB zZ5h+FYpAzYTbi3%Zo_sft&#b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