Commit Graph

1148 Commits

Author SHA1 Message Date
Elias Naur 7fba3bb8fe gpu/backend: remove clear color and depth state
Specifying the clear color and depth at the time of clearing is
less error prone and a better for modern GPU APIs. As a bonus, we
can get rid of the BufferAttachment type.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-15 12:25:56 +01:00
Chris Waldon daecdcaabf ci: add skeleton for sourcehut annotations
This commit adds the necessary task to the CI job to generate sourcehut
annotations as documented here:

https://man.sr.ht/git.sr.ht/annotations.md

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-03-15 09:30:37 +01:00
Elias Naur 5180bb0e1a gpu/gl: don't panic if no input layout is bound
Rendering will probably not be correct, but a panic is overreacting.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-13 17:33:06 +01:00
Elias Naur af68e17dd3 op/paint: set subimage Rect when converting image
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-12 18:42:20 +01:00
Egon Elbre 7c1a21ce56 add f32color.RGBA
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-03-12 13:21:34 +01:00
Elias Naur 7024a0e691 gpu: fix depth buffer on direct3d and headless opengl
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-11 17:45:16 +01:00
Elias Naur 61529c2cb6 gpu: fix clip intersection with the D3D backend
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-11 16:23:35 +01:00
Daniel Martí acfe91ec3e CI: add wine on Linux for the Windows e2e test
Installing it on Debian was enough, with the only wrinkle that
propagating -race won't work when we're cross-compiling, since
cross-compilation disables CGo by default.

For now, just skip the test in that edge case. If we want to use the
race detector on Windows in the future, we need to get a Windows CI
builder somehow.

Tested on my fork; see https://builds.sr.ht/~mvdan/job/164899.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-08 10:52:08 +01:00
Daniel Martí 49000ae4a3 cmd/gogio: add the first Windows e2e test via Wine
Since Wine is heavily tied to X11, we build its end-to-end test driver
on top of X11's. We use the same mechanism to start an X server, take
screenshots, and issue clicks.

Its only quirk is that it was difficult to get the screenshots to line
up with Gio's window. The comments cover what we ended up with. The
display dimensions are now part of driverBase, so that methods other
than Start can also use them - this is necessary for the wine driver to
crop screenshots.

We also use a sleep for now; a comment explains why, and a TODO is left
for future Dan to deal with. What we have now works, and I've spent
enough hours on this patch as it is.

Adding Wine to CI, and ensuring that the test passes there, is left for
a follow-up patch.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-05 09:49:02 +01:00
Daniel Martí 9bbeb92b61 cmd/gogio: reuse the test binary to call gogio in the e2e tests
We were using 'go run . <args>' before, which works fine, but does mean
re-linking a new binary and throwing it away at each invocation. Given
that the end-to-end tests don't do all that much work besides building
the tiny red.go app, this amount of extra work was noticeable.

We can obtain statistics for the JS sub-test, which used 'go run', via
the perflock and benchcmd tools:

	$ go test -c
	$ perflock -governorp% benchcmd EndToEnd/JS ./gogio.test -test.run=EndToEnd/JS

After capturing those numbers before and after the change, we can then
compare them with benchstat. The CPU cost of the subtest is halved:

	name         old time/op         new time/op         delta
	EndToEnd/JS          1.42s ± 2%          1.07s ± 3%  -25.04%  (p=0.008 n=5+5)

	name         old user-time/op    new user-time/op    delta
	EndToEnd/JS          1.46s ± 3%          0.75s ± 5%  -48.34%  (p=0.008 n=5+5)

	name         old sys-time/op     new sys-time/op     delta
	EndToEnd/JS          366ms ±13%          224ms ± 7%  -38.79%  (p=0.008 n=5+5)

An alternative here would have been to refactor main.go to allow being
called directly. However, that would have required a non-trivial
refactor, since flag parsing is done via globals. Given that the
TestMain method is asy and keeps the main function simple, we've
decided to avoid a refactor.

While at it, remove the sleep in the Android driver to wait for the app
to come up on screen. Since we retry screenshots now, we no longer need
a static sleep. On average, we still need one retry for the initial
screenshot, but that's just 100ms versus the old 500ms. The maximum wait
time is also 2s here, which should scale better for slower devices.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 17:34:59 +01:00
Daniel Martí b064899967 cmd/gogio: groundwork for Windows e2e tests on Wine
First, move from debian unstable to testing, since sway was promoted to
testing as of earlier this week.

Second, use the --sync option when using xdotool to move an X11 mouse.
This makes the command block until the mouse has finished moving to the
specified location, removing a potential race with the following
'xdotool click' command.

Third, deduplicate some logic into driverBase: tempDir to create a
temporary directory within a test, and needPrograms to skip a test if
the required programs aren't available.

Lastly, split the code that starts the X11 server into a method, so that
the future Wine e2e driver can reuse it. Since Wine is tightly coupled
with X11, we can reuse a good part of the code, including the X11 server
and the xdotool mechanisms.

We also add a TODO to perhaps improve the handling of the app's output
under each of the e2e test cases.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 10:29:17 +01:00
Elias Naur 48eb5c666c example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 16:17:27 +01:00
Elias Naur bd7c7a108a app/internal/window: (Windows) don't send zero-sized draw requests
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 16:15:55 +01:00
Elias Naur 3738aa43a8 example,cmd: bump gio version 2020-02-29 15:57:27 +01:00
Elias Naur 62a2f3b8c8 README.md: link to Larry's GitHub mirror
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 15:42:01 +01:00
Elias Naur 22e15da67c app/internal/window: (Windows) return all errors from NewContext
Instead of just returning the first error (from Direct3D), return
the errors from all attempts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 15:39:04 +01:00
Elias Naur 8405bf0e47 gpu/shaders: be more robust against floating point inaccuracies
We're forced by compatibility to encode an integer state into a
floating point. Make the implicit conversion from floating point to
integer more robust against GPUs with low precision floats.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 14:27:50 +00:00
Elias Naur 148a2828e7 layout: don't force Expanded Stack children larger than their minimum
Instead, honor the constraints after laying out both Stacked and
Expanded children.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 14:06:25 +01:00
Elias Naur c1048a3a54 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 13:03:20 +01:00
Elias Naur 0ceccf3c93 app/internal/d3d11: try more floating point formats
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 13:01:48 +01:00
Elias Naur 0160bba020 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:53:20 +01:00
Elias Naur b3a3c34088 app/internal/d3d11: detect hardware floating point support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:52:04 +01:00
Elias Naur 050f43d60a io/router: add pointer drag-and-move test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:11:23 +01:00
Elias Naur 330705a423 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 15:24:07 +01:00
Elias Naur b194a0ce58 internal/cmd/convertshaders: target 9.1 compatibility shader model
Direct3D 11 supports Direct3D 9.1 level hardware, but only if the shaders are
compiled for target 4_0_level_9_1.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 15:22:58 +01:00
Elias Naur 1d3a9fb2d6 internal/cmd/convertshaders: replace fxc.exe with D3DCompile
D3DCompile successfully compiles shaders fxc.exe doesn't. As a bonus
the DirectX SDK is no longer required (it includes fxc.exe).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 15:14:54 +01:00
Elias Naur a448825d48 app/internal/d3d11: only clear depth buffer if it exists
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 14:50:39 +00:00
Elias Naur 73fc5e1482 app/internal/d3d11: return structured ErrorCode errors from d3d functions
While here, change the ErrorCode.Code field type to uint32 to better reflect
its native counterpart.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 13:49:56 +01:00
Elias Naur 5ae68d2127 example, cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 09:59:34 +01:00
Elias Naur 2fd7e2dd9b app/internal/d3d11: fix GOOS=windows GOARCH=386 build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 09:58:23 +01:00
Elias Naur bfb50cef5d all: remove unused fields, functions and add missing error handling
Credit to staticcheck.io.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 22:26:54 +01:00
Elias Naur 4b7387369b .builds: upgrade to Go 1.14 final
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:56:18 +01:00
Elias Naur 27c77f1baf example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:56:17 +01:00
Elias Naur e03b3cd808 app/internal/d3d11: add Direct3D backend
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:41:35 +01:00
Elias Naur d65bfdc275 internal/cmd/convertshaders: use gofmt to format output
In particular, the simplifying "-s" flag to gofmt ensures that the automatic
test for unformatted Go source files won't complain.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:41:31 +01:00
Elias Naur 591c89ab0a gpu: drop use of integer shader inputs
They're a pain to support. Encode the single integer value we have
as a float instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 3043c4243a gpu/backend: add support for GLSL 1.50
Apple's OpenGL 3.2 Core implementation doesn't accept 1.30.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur dd6a247326 gpu/backend: add support for desktop OpenGL 3
In particular, add the GLSL 1.30 shader variant. Sigh.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur a0c4688d0c app/headless,gpu/gl: make ReadPixels y-flipping backend specific
The Direct3D backend doesn't need y-flipping, so don't do it unconditionally in
package app/headless.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 8dce81d8fd gpu/shaders: introduce toClipSpace to map to GPU native clip space
OpenGL use the [-1; 1] range for clip depths, Direct3D [0; 1].
Use toClipSpace to encapsulate the difference.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur c34c350a52 gpu: pack 2D transforms in vec4 values
Instead of separate 2d scale and transform, pack them into a single
4d value.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 1f117d8de0 internal/cmd/convertshaders: #define HLSL when compiling for HLSL
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur c20c1ab96f gpu/shaders: compensate for GPU Framebuffer => texture transformation
Add fboTextureTransform shader function for cancelling the
implied transformation from fragments output by the fragment
shader and the (u, v) coordinates used to sample from it in a
later pass.

For OpenGL the transformation is the identity.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 0d573514c5 internal/cmd/convertshaders: support #include in shaders
Add flag to specify shader directory while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 6213daa3e9 app: recover from transient Present errors
Some GPU APIs such as Direct3D can return an error after drawing
a frame indicating a transient device error. Recreate device and
retry if it happens.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 29d36e11ee gpu/shaders: use correct type for integer vector
OpenGL supports casting from int to float during vertex array
reading. Direct3D doesn't. Since we're transpiling from GLSL, we can't
directly use the Direct3D builtin "asint". So that leaves using
"ivec2" instead of vec2.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 7ff2f60412 app/headless: add lower-level backend tests
Add a series of low level gpu.Backend tests to assure the correct behaviour of
Backends. The immediate use is debugging of the Direct3D port, in the future
for developing new backends.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:22:59 +01:00
Elias Naur 55c74d3159 app/headless: setup default Viewport in NewWindow
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:58 +01:00
Elias Naur 0d266c413d gpu,gpu/backend: implement GLSL 300 es shader variants
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:58 +01:00
Elias Naur 3a5a2cff6b app/internal/glimpl: add gl functions for uniform buffers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:37 +01:00