vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
547 stars 90 forks source link

opaque rendering on platforms lacking GL_ARB_fragment_shader_interlock #313

Closed zarniwhoop73 closed 2 years ago

zarniwhoop73 commented 2 years ago

I closed #312 because for my reduced testcases it was working. But with a larger set of runs I'm seeing a 'shipout3' error in (at least) png and pdf files, html (webgl) continues to run. Example:

shipout3(prefix,f,preview ? nativeformat() : format,

/opt/texlive/2022/texmf-dist/asymptote/three.asy: 2896.13: runtime

The file for this run was

settings.outformat="png";
import graph3;
settings.render=4;
size3(50,0);
currentprojection =
perspective(10,5,-8);
path center_path = (0,0) --- (0,3)
.. (1.5,3) .. (0,0.3) --- (0,0);
real bottomradius = 0.6;
real topradius = 0.1;

path radius_graph = (0, bottomradius) {up} ::
    (0.3,1.2*bottomradius) --- (0.9, 1.2*bottomradius) ::
    (1.2, topradius) --- (2, topradius) :: {up} (3, bottomradius);

radius_graph = xscale(1/3) * radius_graph;
radius_graph = (shift(-1,0)*radius_graph) & radius_graph &
    (shift(1,0)*radius_graph);

real radius(real t) {
  return point(radius_graph, times(radius_graph, t)[0]).y;
}

triple F(pair w) {
  real t = w.x % 2.0;
  bool reverse = (t >= 1.0);
  t %= 1.0;

  real relt = reltime(center_path, t);
  real theta = w.y;
  triple center = YZplane(point(center_path, relt));
  pair tangent = dir(center_path, relt);
  if (reverse) tangent *= -1;
  triple normal = X;
  triple binormal = cross(YZplane(tangent), normal);
  triple v = normal*cos(theta) + binormal*sin(theta);
  return center + radius(t)*v;
}

surface kleinbottle = surface(F, (0.5,0), (1.5, 2pi), nu=32,
    nv=16, Spline);

draw(kleinbottle, mediumred);

This is from a test file to play with variations of kleinbottle, colours, formats [https://www.linuxfromscratch.org/~ken/asy-nontex-testfiles/(https://www.linuxfromscratch.org/~ken/asy-nontex-testfiles/asy-test-20200809.tar.xz] (make klein VAR=7 type=png COLOR=mediumred in the above case)

johncbowman commented 2 years ago

I can't reproduce the problem. At what git version does this fail for you?

johncbowman commented 2 years ago

This suggests you are testing with Asymptote version 2.79 shipped with TeXLive: /opt/texlive/2022/texmf-dist/asymptote/three.asy

Can you please test against the latest stable version, 2.80, or the latest git version?

Be sure that you are not mixing different Asymptote binary and base file (plain.asy, three.asy, etc.) versions.

zarniwhoop73 commented 2 years ago

I always configure for the current /opt/texlive and install there, over any previous version.

This is 2.81-13 de70a953b384 installed a few hours ago, ~ $ls -l /opt/texlive/2022/bin/x86_64-linux/asy -rwxr-xr-x 1 root root 48841656 May 12 00:21 /opt/texlive/2022/bin/x86_64-linux/asy

The asy files match the dates and times of what is in git for that version.

~ $ls -l /opt/texlive/2022/texmf-dist/asymptote/{plain,three}.asy -rw-r--r-- 1 root root 7634 May 8 09:30 /opt/texlive/2022/texmf-dist/asymptote/plain.asy -rw-r--r-- 1 root root 85989 May 8 03:49 /opt/texlive/2022/texmf-dist/asymptote/three.asy

$ls -lR /scratch/ken/git/asymptote/base/{plain,three}.asy -rw-r--r-- 1 ken users 7634 May 8 09:30 /scratch/ken/git/asymptote/base/plain.asy -rw-r--r-- 1 ken users 85989 May 8 03:49 /scratch/ken/git/asymptote/base/three.asy

I can test against latest git, maybe in a few hours or maybe a bit after that.

johncbowman commented 2 years ago

The changes to the 3D code in version 2.80 and the git repo relate to transparency. So for this opaque example probably 2.70 and 2.79 won't work either for you. It could be due to a buggy graphics library on this platform.

zarniwhoop73 commented 2 years ago

As you suggested, 2.79 does not work for png with this file on this machine. But 2.78 does work.

johncbowman commented 2 years ago

Can you use git bisect to narrow down the first bad commit (between 1922c3ba7daa62370a91b52f0b16cfda1c461efb and 94fe097db546f1de9e5b43e6b31fe1d2d4e4edaf) ? Thanks!

zarniwhoop73 commented 2 years ago

I'd already started (marginally different end points, I used 2.78 and 2.79):

$git bisect log git bisect start

good: [83b0213063787b8cfdd68fe274b78b5867e5e9b6] TRANSPARENCY: Implement GPUinterlock setting.

git bisect good 83b0213063787b8cfdd68fe274b78b5867e5e9b6

bad: [70dcf303c069ce3669f5f589aa3642650665278b] Improve diagnostic.

git bisect bad 70dcf303c069ce3669f5f589aa3642650665278b

good: [efb89680a9bca82f38fa0ab5c8faf1e5dc584b3e] Fix commit 45f445c9c6a8f9d2f5d4c743464113e827b86ec8.

git bisect good efb89680a9bca82f38fa0ab5c8faf1e5dc584b3e

good: [4b8738823adfbe292a90f0a6a037b4e9716e95d1] TRANSPARENCY: Set initial (minimum) maxSize to 8.

git bisect good 4b8738823adfbe292a90f0a6a037b4e9716e95d1

bad: [8194c27001d46765cb7914df9751e5aa367a6d51] Reformat.

git bisect bad 8194c27001d46765cb7914df9751e5aa367a6d51

bad: [616460b1dd97ec326f4cf47a6c01ce4b301efb20] Fix offscreen export.

git bisect bad 616460b1dd97ec326f4cf47a6c01ce4b301efb20

bad: [096e6ecadea8279ce0c9d8d1aa2279615f341688] TRANSPARENCY: Define m1 and r only when needed.

git bisect bad 096e6ecadea8279ce0c9d8d1aa2279615f341688

bad: [49b90ca22992f97a9b314d2ac4e2da9b6e17dd40] Fix GPUinterlock=false.

git bisect bad 49b90ca22992f97a9b314d2ac4e2da9b6e17dd40

first bad commit: [49b90ca22992f97a9b314d2ac4e2da9b6e17dd40] Fix GPUinterlock=false.

johncbowman commented 2 years ago

Ok, I can reproduce the problem with asy -noGPUinterlock; apparently your graphics driver doesn't support GL_ARB_fragment_shader_interlock.