Currently, we run kernel4.comp with whatever texture was
bound (or none) when there are no materials in the set of layers.
However, Vulkan require every image binding to a compute shader to be
non-null and valid. This change works around that limitation by binding
a small dummy texture when no materials are needed.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Modern GPU API such as Metal and Vulkan use explicit render passes
and command buffers for recording rendering commands. They don't have
global state; each render pass starts with a clean set of bound
textures, pipeline etc.
Change our GPU abstraction to better match newer API and modify our two
renderers to explicitly describe their render passes.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
GPU contexts can hold on to a significant amount of resources. Clean
them up immediately instead of at test cleanup.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Don't copy the padding when stride is larger than the width. Applies to
Texture.Upload and Framebuffer.ReadPixels.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Unlike Raise, Close and other fire-and-forget methods on Window,
Config calls driverRun because it needs to wait for the result.
However, driverRun isn't guaranteed to block in all contexts.
This change avoids the synchronization dance altogether by removing the
Config method and introducing a ConfigEvent event. The event also makes
it clear when the configuration changes.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Switching to using a CAMetalLayer as the layer backing our NSView
implementation broke programs such as the opengl example. Somehow, using
ANGLE on top of a CAMetalLayer (but not a CAEAGLLayer) stops resizes
from triggering redraws.
This change invalidates the view in setFrameSize, to force a redraw
and no longer rely on the implicit redraws.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is based on a patch by Elias that improved drag scrolling
on the scrollbar by locking some parameters of the math at the start
of the scroll event.
I discovered while playing with that implementation that there was
an even simpler approach within his changeset. You can actually
use no information other than the delta between the current and
previous frame's scroll position to compute the scroll distance.
By simplifying the math to rely on no other inputs, the jitter that
we've been fighting simply disappears (it came from other inputs).
Turns out my attempts to make the logic smart were the problem.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Window.driverFunc says it can be run from any context. However, running
it from the Window.run event loop may deadlock, at least until an
unrelated event arrives from the driver (e.g. a mouse move).
Example:
Window.Invalidate is called, which caused Window.run to queue a driver
func, and notify the Window.wakeups channel. However, another
Window.Invalidate arrives just in time for Window.run to process that
before Window.wakeups, leading to a deadlock because only one driver
func can be queued.
This change fixes the problem by processing wakeups before potentially
queueing more driver functions.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
A previous change[0] moved all OpenGL function calls to the internal
opengl package, so that Gio can use desktop OpenGL and OpenGL ES (ANGLE)
in the same program without confusing the function pointers.
However the change also moved the glFlush that constitutes a buffer
swap, or present, on macOS. Other platforms don't need the flush, so
this change moves it back to macOS-specific code, in glContext.Present
where it belongs. It also uses dlopen and dlsym to avoid symbol
confusion between Apple's OpenGL framework and ANGLE's libGLESv2.dylib.
The motivation is that we're getting rid of the desktop OpenGL backend
on macOS in favor of Metal, and so should reduce the number of global
special-cases catering to that platform.
[0] https://gioui.org/commit/476d2269a
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit fixes a problem that could force the scroll indicator to
lay itself out outside of its configured bounds. This occurred when
the scroll indicator size was increased to meet the minimum size
configured on the style type while the scrollbar was near the end
of the list. The increased size did not take the start position
of the scroll indicator into account, which made the indicator begin
in the correct place, but extend beyond the end of its track.
This commit alters the logic to ensure that the scroll indicator can
never extend beyond the end of its track.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Previously, it was possible for fromListPosition to return
an end coordinate greater than 1, which would make scroll
indicators using those coordinates render beyond the
boundaries of their scroll tracks. One could argue that
this is a bug in the scroll indicator, but I don't think
this method should return data outside of its documented
range.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
d8 doesn't check and fails with an inscrutable error when using
unsupported JDK versions such as JDK 11.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Somehow, the explicit include and library directories needed for OpenBSD
are required for FreeBSD as well.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The _NET_WM_STATE protocol description[0] states that to change the
window mode for an X11,
"To change the state of a mapped window, a Client MUST send a
_NET_WM_STATE client message to the root window."
and that the window manager in turn
"The Window Manager MUST keep this property updated to reflect the
current state of the window."
However, our X11 implementation did both: send the message _and_ set or
deleted the property.
This change makes it so only the message is sent. It also replaces
toggling the property by setting or clearing, to ensure our mode and the
window manager's mode never gets out of sync.
Maybe fixes gio#265
[0] https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm46515148826720
Signed-off-by: Elias Naur <mail@eliasnaur.com>
A Window configuration with its current option values can now be fetched during a FrameEvent.
The WindowMode and Orientation options have moved to methods on their corresponding types.
Fixes#260
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
Now that Window.driverDefer can be run in any context, the special case
of setting the animation flag can use that mechanism instead of a
special purpose channel.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Driver methods are invoked during event processing, but some of them may
generate events that would in turn deadlock because event processing is
not re-entrant. However, a previous change moved all such calls outside
event processing and so chained events can no longer deadlock.
This change deletes the workarounds.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Window.driverRun is designed to run functions on the driver event
goroutine, to avoid race conditions with internal driver state and,
more importantly, to run on the designated main or UI thread for
platforms that require that.
However, driverRun runs functions during the processing of a driver
event, so if a function in turn triggers another driver event,
deadlock occurs.
This change introduces Window.driverDefer for functions that don't need
to block event processing. Functions passed to driverDefer may
themselves trigger new events.
A few callers of driverRun remain; they need the result of their
functions but are guaranteed not to trigger new events.
Fixes gio#263
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Since onFrameCallback runs on the app UI thread, using plain
invalidate() can be used instead of postInvalidate(). The latter just
schedules a call to invalidate() on the UI thread.
Also, since onFrameCallback is directly called by JNI, there is no need
to set up a new JNI environment to call back into Java.
Signed-off-by: Felix Lange <fjl@twurst.com>
Some window configurations lead to WM_SIZE messages when changed, which
leads to deadlock because our window proc is not re-entrant. Avoid the
issues by ignoring redundant messages.
Fixes gio#262
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, the renderLoop type implemented a rendering
goroutine for rendering off the event thread. However, it's not worth
the complexity, so remove it and render on the event thread.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The Android emulator creates a broken EGL surface if it is not created
on the same thread as the context is made current.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The Android system can in some cases replace the GioView of our Android
Activity before destroying the previous one. This change makes sure the
previous view is ignored, in particular its destroy event.
Signed-off-by: Elias Naur <mail@eliasnaur.com>