16:15Company: I just bisected a new GTK testsuite failure down to this commit: https://gitlab.freedesktop.org/mesa/mesa/-/commit/7f2130c86e17f936be66fa6ad8eda85746b5fc6b
16:15Company: do I now assume this is likely GTK's shadercode doing something undefined and try to debug that?
16:15Company: or do I assume that commit has a problem and try to learn enough nir to debug that?
16:21Company: the GTK bug is that this shader: https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gsk/gpu/shaders/gskgputurbulence.glsl should produce the image at https://gitlab.gnome.org/GNOME/gtk/-/blob/main/testsuite/gsk/compare/turbulence-transformed.png but produces https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/10193#note_2832543
16:22Company: which is exactly at the repeat boundaries where x - floor(x) and such happen and might result in 0.0 or 1.0 or sth like that
16:25Ristovski: Company: what hardware?
16:27Company: Ristovski: llvmpipe
16:27Company: well, lavapipe
16:27Company: though I get some artifacts if I run the test with Intel, too
16:32Ristovski: hm no clue, but lavapipe has LP_DEBUG=fs for dumping the frag shader, might be worth A/B-ing with/without that commit etc
16:41Company: https://paste.centos.org/view/4f195676
16:42Company: so what the shader does is:
16:42Company: x = x + 4096;
16:42Company: x = fract(x);
16:43Company: and the addition is to get rid of floating point rounding errors by doing the addition
16:43Company: ie 0.000000000000001 + 4096 would be 4096
16:44Company: and the optimization detects that the addition should modify the fractional part so it optimizes it away
16:44Company: and then the shader gets 0.000000000000001 instead of 0
16:45Company: now I still have no idea who's fault that is
16:49karolherbst: Company: you could try to pinpoint which of the rules is doing that
16:50karolherbst: Company: ohhh.. you might have to declare the part as precise...
16:51karolherbst: https://wikis.khronos.org/opengl/Type_Qualifier_(GLSL)#Precise_qualifiers
16:51Company: I wonder if it should just use a better method
16:52karolherbst: maybe
16:52Company: adding 4096 to get rid of floating point accuracy seems dodgy
16:53karolherbst: but yeah.. the optimiation _improves_ precision and therefore it's legal if contraction is allowed
16:53Company: this code looks copy/pasted from https://drafts.csswg.org/filter-effects/#feTurbulenceElement
16:54karolherbst: if you rely on computations being done 1:1 how it's in the code, you'll have to declare it as precise for now or figure out a better way of doing that :)
16:55Company: I wonder if more shaders run into this
16:55karolherbst: "nextafter(4096.0, +inf) - 4096.0" would give you the floating point precision around 4096.0, and you could compare the initial value with it to see if ti would be rounded away or not
16:55Company: the one place I know: https://github.com/WebKit/WebKit/blob/9ff899b9b2f4121ebf7e7f5b376e5ad8dab21574/Source/WebCore/platform/graphics/coreimage/FETurbulenceCoreImageApplier.mm#L145 is doing the exact same thing
16:56karolherbst: well that uses floor
16:57karolherbst: so it shouldn't run into the issue
16:57Company: line 151
16:57karolherbst: or maybe it could...
16:57Company: does a position - floor(position) essentially
16:58Company: our shader doesn't use fract() either - because it's ported straight from that example code and C has no fract()
16:58Company: but nir is smart enough to optimize that
16:58karolherbst: ahh
16:59karolherbst: well you have to expect that the shader can improve precision of any operation at any time unless contraction is disabled
16:59Company: right - so it's something that I need to fix
16:59Company: and probably the SVG spec, too
16:59karolherbst: yeah.. just throw in a "precise" on the variable or something
16:59Company: and maybe Firefox, Servo, Chrome, and Webkit, too ;)
17:00karolherbst: precise marks the entire expression assigning to the variable on the rhs as "precise"
17:00karolherbst: yeah... worst case we'll have to disable that optimiation for certain applications
17:00karolherbst: *optimization
17:01Company: meh, precise is GL 4
17:02karolherbst: or ARB_gpu_shader5
17:02Company: right - and I suppose the other ones can live with the bug
17:02karolherbst: many 2.x, and 3.x advertise that one
17:02karolherbst: *devices
17:03Company: does GLES 3 have prcise?
17:04karolherbst: no idea :)
17:06Company: https://paste.centos.org/view/f49cb646 does fix GTK's shader
17:07karolherbst: rough :)
17:08Company: only with Vulkan though, not with GLES
17:09Company: and with GL
17:09karolherbst: I guess gles ignores the modiifer
17:09Company: that was my guess there, too
17:10karolherbst: I do think you can do an algo with nextafter, but that's kinda slow
17:10Company: I think I will just do x = round (4096 * x) / 4096;
17:10karolherbst: uhh not sure if gl/gles have nextafter...
17:10karolherbst: I guess not