Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some path effects causing shader compilation errors on macOS #58

Open
Lappun0 opened this issue Aug 15, 2023 · 2 comments
Open

Some path effects causing shader compilation errors on macOS #58

Lappun0 opened this issue Aug 15, 2023 · 2 comments

Comments

@Lappun0
Copy link

Lappun0 commented Aug 15, 2023

I have the code from the original PathEffects demo setup in Kotlin, when I run it with some basic LWJGL code on Windows everything renders fine, but when I run it on macOS it gives me this error each frame:

Shader compilation error

1 #version 110
2
3 uniform vec4 sk_RTAdjust;
4 uniform vec2 uatlas_adjust_S0;
5 attribute vec4 fillBounds;
6 attribute vec4 color;
7 attribute vec4 locations;
8 varying vec2 vatlasCoord_S0;
9 varying vec4 vcolor_S0;
10 void main() {
11 vec2 unitCoord = vec2(float(gl_VertexID & 1), float(gl_VertexID >> 1));
12 vec2 devCoord = mix(fillBounds.xy, fillBounds.zw, unitCoord);
13 vec2 atlasTopLeft = vec2(abs(locations.x) - 1.0, locations.y);
14 vec2 devTopLeft = locations.zw;
15 bool transposed = locations.x < 0.0;
16 vec2 atlasCoord = devCoord - devTopLeft;
17 if (transposed) {
18 atlasCoord = atlasCoord.yx;
19 }
20 atlasCoord += atlasTopLeft;
21 vatlasCoord_S0 = atlasCoord * uatlas_adjust_S0;
22 vcolor_S0 = color;
23 gl_Position = vec4(devCoord, 0.0, 1.0);
24 gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
25 }
26
Errors:
ERROR: 0:11: Use of undeclared identifier 'gl_VertexID'
ERROR: 0:11: Use of undeclared identifier 'gl_VertexID'
ERROR: 0:12: Use of undeclared identifier 'unitCoord'
ERROR: 0:16: Use of undeclared identifier 'devCoord'
ERROR: 0:18: Use of undeclared identifier 'atlasCoord'
ERROR: 0:18: Use of undeclared identifier 'atlasCoord'
ERROR: 0:20: Use of undeclared identifier 'atlasCoord'
ERROR: 0:21: Use of undeclared identifier 'atlasCoord'
ERROR: 0:23: Use of undeclared identifier 'devCoord'

here is my draw code:

var x = 20f
var y = 20f

Path().moveTo(-5f, -3f).lineTo(5f, 0f).lineTo(-5f, 3f).closePath().use { pattern ->
    Path().lineTo(10f, 0f).lineTo(10f, 1f).lineTo(0f, 1f).closePath().use { dash ->
        Paint().setColor(0x20457b9d).setMode(PaintMode.STROKE).setStrokeWidth(1f).use { stroke ->
            Paint().setColor(-0x1890af).setMode(PaintMode.STROKE).setStrokeWidth(1f).use { fill ->
                Path().moveTo(100f, 10f).lineTo(190f, 190f).lineTo(10f, 190f).closePath().use { figure ->
                    val offset = 1f - System.currentTimeMillis() % 1000 / 1000f
                    val effects = arrayOf(
                        PathEffect.makePath1D(pattern, 10f, 10 * offset, PathEffect.Style.TRANSLATE),
                        PathEffect.makePath1D(pattern, 20f, 20 * offset, PathEffect.Style.TRANSLATE),
                        PathEffect.makePath1D(pattern, 20f, 20 * offset, PathEffect.Style.ROTATE),
                        PathEffect.makePath1D(pattern, 20f, 20 * offset, PathEffect.Style.MORPH)
                            .makeCompose(PathEffect.makeCorner(50f)),
                        PathEffect.makePath1D(dash, 15f, 15 * offset, PathEffect.Style.MORPH),
                        PathEffect.makePath2D(Matrix33.makeScale(15f), pattern),
                        PathEffect.makeLine2D(1f, Matrix33.makeScale(3f, 3f)),
                        PathEffect.makeLine2D(1f, Matrix33.makeScale(3f, 3f).makeConcat(Matrix33.makeRotate(30f))),
                        PathEffect.makeCorner(10f),
                        PathEffect.makeCorner(30f),
                        PathEffect.makeDash(floatArrayOf(10f, 10f), 20 * offset),
                        PathEffect.makeDash(floatArrayOf(10f, 5f), 15 * offset),
                        PathEffect.makeDash(floatArrayOf(10f, 5f, 2f, 5f), 22 * offset),
                        PathEffect.makeDiscrete(5f, 2f, (System.currentTimeMillis() / 32).toInt()),
                        PathEffect.makeDash(floatArrayOf(10f, 5f, 2f, 5f), 22 * offset)
                            .makeCompose(PathEffect.makeCorner(50f)),
                        PathEffect.makeDash(floatArrayOf(10f, 5f, 2f, 5f), 22 * offset)
                            .makeSum(PathEffect.makeCorner(50f)),
                    )
                    for (effect in effects) {
                        if (x > 0f && x + 200f > width) {
                            x = 0f
                            y += 200f
                        }
                        canvas!!.save()
                        canvas!!.translate(x.toFloat(), y.toFloat())
                        canvas!!.drawPath(figure, stroke)
                        fill.setPathEffect(effect)
                        canvas!!.drawPath(figure, fill)
                        fill.setPathEffect(null)
                        effect.close()
                        canvas!!.restore()
                        x += 200
                    }
                }
            }
        }
    }
}

When no drawing (or only basic drawing) Is done before the path effects are drawn, only the first five fail to be drawn. However if I place this code after the rest of my scene is drawn, all effects fail.

This happens on the latest version (0.109.2)

@tonsky
Copy link
Contributor

tonsky commented Aug 15, 2023

Maybe ask at Skia? https://groups.google.com/g/skia-discuss/
I’m not sure in what state their OpenGL / macOS version is right now, given that Apple deprecated OpenGL a while ago
Also, try 0.116.1, it’s been out for a few days :)

@Lappun0
Copy link
Author

Lappun0 commented Aug 15, 2023

Whoops, While writing I figured id try with the newest version, but it seems that I accidentally wrote the one I was using before in, this happens on 0.116.1 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants