From nobody Tue Jan 26 22:41:13 2021 Authentication-Results: mail-b.sr.ht; dkim=pass header.d=platoteam.com header.i=@platoteam.com Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by mail-b.sr.ht (Postfix) with ESMTPS id 6D51011EFF6 for <~eliasnaur/gio@lists.sr.ht>; Tue, 26 Jan 2021 22:41:13 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id k132so158145ybf.2 for <~eliasnaur/gio@lists.sr.ht>; Tue, 26 Jan 2021 14:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=platoteam.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZJ+bH/HlklQFPjZfHj4NGJdczPIyGSA5HEZZjrMai8s=; b=XcakIZ633ULC/8uMAPWX/Sq7rJHoFuPVSrUuvORQHmDTzvedWUB4BV15R9bd1tT6XI hy2uamjpxVo03cHvkFt03Td+zFXWk5IrqEqsJwHXQpphqvnpw+e7R57KftoHKNNcmtjR O4xP/WzQPUC8Ih2aktdkdpCwlLCMnX5cvdVwntCFdDp7wKFz0Gx8RNDGO72xpOZl/24P 0SuTDI4nMgXDhO7XMCuGCu2wJeQeCiABQs1SS3QSoc7E6Bsrhe+4SxN99a4RqFOvF1wQ 5D/KcGoFtotKKOSbLUlah5yJ1kG0hnV3rJOdj1U7MWvn2cC1tt0Qo8pfkwP0uUTecb5X 25eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZJ+bH/HlklQFPjZfHj4NGJdczPIyGSA5HEZZjrMai8s=; b=MbyZhfWIOdi/GQpEdCECADtlonyhGM5hTLDYDvqSNyXMW9/7usvoKgjQDeXg2OD3pr 3MazB/7fyeN/WvvMKoQnCcBWwqwSX+99FXFlfuDYs/Ur1/5BmXM1+SpJU3Q0ZTYqpvwy rx44+TqxtBlY2M3cy1QR9/eRwhPKIEgasqAwrUG37wNUOnHud+WKsado8GWazaz8mdT2 NKJsIhBuFPUBtr+xoBw+NSHvfxtHIc60HbU5gXqWnKCsHbNNJ6befN9jsmrDYOIH21PF IolOdNXFMUuBmAgjcpJzuZCofRFncBSl/l3JZDGG7ekKTqv0WQ4wjugHtQsKfvqPgOWa 60/g== X-Gm-Message-State: AOAM530UBTm+jGTnKEwXV271HaLNR4x9Es7n5/mUh7rfu7KMiCJUlDoA 0UXX5nzuo7TsAmx0IjZEDzcWoQTFrUi7Ro01w8w4pI0W+ZCLYf5A X-Google-Smtp-Source: ABdhPJy3ScIdWM1amswdSFygUG1hSK0CMlBnE90i8Modh7wKaWfAXQXjE7nPyBwuDdon/9gLM+5aaz9YORyEhjy4hHM= X-Received: by 2002:a25:cc57:: with SMTP id l84mr961719ybf.379.1611700872664; Tue, 26 Jan 2021 14:41:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Zhao Wang Date: Tue, 26 Jan 2021 14:41:02 -0800 Message-ID: Subject: Embed Gio with other OpenGL rendering To: Elias Naur Cc: ~eliasnaur/gio@lists.sr.ht Content-Type: text/plain; charset="UTF-8" On Tue, Jan 26, 2021 at 5:51 AM Elias Naur wrote: > > If you don't mind, let's continue this discussion on the Gio mailing > list[0], as I'm sure embedding will interest others. If you agree, send > your replies CC'ed ~eliasnaur/gio@lists.sr.ht. > > [0] https://lists.sr.ht/~eliasnaur/gio > Sounds good. Sharing this with Gio mailing list now and modified title > On Mon Jan 25, 2021 at 17:40, Zhao Wang wrote: > > On Mon, Jan 25, 2021 at 2:05 AM Elias Naur wrote: > > > > > > On Mon Jan 25, 2021 at 7:08 AM CET, Zhao Wang wrote: > > > > Hi Elias, > > > > > > > > On Sat, Jan 23, 2021 at 2:12 AM Elias Naur wrote: > > > > > > > > > > On Sat Jan 23, 2021 at 9:53 AM CET, Zhao Wang wrote: > > > > > > > > > > Another option is to share rendered textures between D3D11 and OpenGL > > > > > ES. If you're using ANGLE for OpenGL ES anyway, there are extensions such > > > > > as [2] that may allow clean mixing of OpenGL and Direct3D. > > > > > > > > > > > > > Thanks for the info, I will take a look at this later too. However, we > > > > use standard > > > > OpenGL ES API, requiring to use extensions might not work for us as it > > > > will likely > > > > require many changes to existing game rendering libraries (written in > > > > TypeScript > > > > and bindings through JavascriptCore on iOS and V8 on android) > > > > > > > > > > The extension is question is an EGL extension, and (if it works) will > > > only be used by the top-level machinery to render D3D11 Gio content into > > > a shared texture that OpenGL can use as any other texture. > > > > > > In other words, I think (but haven't tried) the extension allows this > > > flow: > > > > > > 1. Create GLFW native window using ANGLE for as the OpenGL > > > implementation. > > > 2. Use ANGLE extension to create a texture shared between OpenGL > > > and D3D11. > > > 2. Render game content (OpenGL) into the window. > > > 3. Render Gio content (D3D11) into the off-screen texture. > > > 4. Use OpenGL to render the off-screen texture on top of the game > > > content. > > > > > > > The current GLFW example in gio-example is not doing this flow, right? > > I likely need to research more to understand this better. An example will > > be very helpful if you have one or can easily get one. > > > > I found an ANGLE test[1] that seems to demonstrate what we need. I also > found a possibly outdated article in the discontinued microsoft fork of > Angle, [2]. > > [1] https://github.com/google/angle/blob/master/src/tests/egl_tests/EGLPresentPathD3D11Test.cpp > [2] https://github.com/Microsoft/angle/wiki/Interop-with-other-DirectX-code > Cool, thank you, Will check this out > > > > > > > > > > > > The example mixes custom OpenGL and Gio. However, note that more work is > > > > > > > required to mix different GPU APIs. As long as separate windows are ok, > > > > > > > you can use Gio windows for Gio content and GLFW windows for OpenGL > > > > > > > content. > > > > > > > > > > > > > > > > > > > Currently, Is it possible to have a GIO window only for GIO contents, > > > > > > and > > > > > > then allow tapping GIO window buttons to display a GLFW window? Based on > > > > > > what you said above, it seems to be possible. I tried it earlier but > > > > > > failed. I will try again later. > > > > > > > > > > > > > > > > > > > > > > Mixing windows from GLFW and Gio *should* work, or be able to work with > > > > > few tweaks. If you have, say, a patch against the glfw example and an > > > > > error I can take a look. > > > > > > > > I used gio-example/multiwindow example, made a commit here[1]. Now when > > > > I click "More" button, it will cause the app non-responding without > > > > showing any errors. > > > > > > > > > > Which platform are you testing this on? Note that the app.Main call > > > blocks forever, which means that you should move the event processing of > > > the GLFW window into a separate goroutine. > > > > For this one, I was testing on Mac OS. I will make some changes to try > > to get it to work based on your suggestions. Thanks. > > > > Oh yes, Apple :) macOS has the additional requirement that all GUI > manipulation happen on the main thread. In particular there can only be > one NSApp delegate. Gio sets up its own delegate[3], and I'm sure GLFW > sets up a different one. > > I don't expect too much trouble getting Gio and GLFW to coordinate the > global state on macOS, but since you're going to need game/gui mixing > anyway, I suggest staying with only GLFW windows for now. You should > see no loss of functionality: a given GLFW window can certainly contain > either Gio content or game content, as demonstrated by the glfw example. > And you lose no generality because you require OpenGL, at least for now. > > [3] https://git.sr.ht/~eliasnaur/gio/tree/main/item/app/internal/window/os_macos.m#L216 > I see, making sense. Mac OS X will be something less priority for me. So will stick with GLFW for now > > > On Mon Jan 25, 2021 at 8:43 AM CET, Zhao Wang wrote: > > > > I just tried the GLFW example on windows, it failed as expected as > > > > shown by the attachment. > > > > > > > > It panic when trying to GetString for Extension during initializing a > > > > new backend. > > > > > > > > > > The OpenGL backend depends on ANGLE to work. I have an old build here[0] > > > if you like. Place the DLLs in the same directory as the GLFW binary (or > > > the current directory if you're using `go run`). > > > > > > > Regarding running the glfw example on windows, I put these DLLs in the > > same directory as the GLFW binary and do "go run". I got this error when > > creating new backend: > > > > "2021/01/25 16:52:52 failed to parse OpenGL ES version ()" > > > > It returns empty string for OpenGL ES version and thus failed at this line > > in NewBackend method: > > > > "glimpl.ParseGLVersion()" > > > > Will dig more into this to collect more information. > > > > I found and fixed an issue that should fix the above error [4]. Please > try again. > > Elias > > [4] https://gioui.org/commit/57872856e8c5b5de Tried again with latest Gio, seems still the same problem. I made a commit here [0]. Do I need to include the ANGEL binaries? I am not sure if the ones [1] you gave me already include everything we need. [0] https://github.com/zwang/gio-example/commit/3c34d05d121ba722f6bd8b926f21ef1fb3246988 [1] https://drive.google.com/file/d/1k2950mHNtR2iwhweHS1rJ7reChTa3rki/view?usp=sharing