Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ TileCache ]] Use HardwareBuffer for direct memory access on Android #7433

Open
wants to merge 4 commits into
base: develop
Choose a base branch
Loading
from

Conversation

livecodeian
Copy link
Contributor

@livecodeian livecodeian commented Sep 15, 2020

This patch modifies the creation and update of GL textures to use a
native hardware buffer. This allows fast upload of texture data by
accessing the underlying buffer and copying pixel data to the texture
directly.

To do:

  • Make compatible with API < 26 (AHardwareBuffer calls need to be dlsym'd)
  • Make work with 32-bit ARM

Of these the first is critical (otherwise the engine will not work on anything less than Android 8.0). The second would be nice, but isn't hugely important - 64-bit devices are common-place, even more so as API level increases.

@livecodeian livecodeian added this to the 9.7.0-dp-1 milestone Sep 15, 2020
@livecodeian livecodeian self-assigned this Sep 15, 2020
@runrevmark runrevmark changed the title [[ Tilecache ]] Use HardwareBuffer for direct memory access on Android [[ TileCache ]] Use HardwareBuffer for direct memory access on Android Sep 15, 2020
Copy link
Contributor

@runrevmark runrevmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I suggest making a simple API which returns false if hardwarebuffer stuff fails for the ciritcal places - perhaps MCTileCacheHardwareBuffer prefix. (Seems we only need Create / Unlock / Update / Destroy).

I suggest using forward references near the top, then implementing them at the bottom in an ifdef. If there is no hardwarebuffer implementation then the methods should just return false meaning the non-hardwarebuffer code is used.

This means that the only places we need to use the ifdefs are in the super_tile struct and around the methods - with dummy impls of the latter in the alternate.

Also, we need to make sure we dlsym the AHardwareBuffer symbols so things run on pre-8.0.

@@ -20,6 +20,12 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
#elif defined(TARGET_SUBPLATFORM_ANDROID)

/* TODO - Don't attempt to build on 32bit armv7 - needs ndk update */
#if !defined(__arm__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I need an idea on what (at least!) is involved in doing this to work out if it is worth the effort.

engine/src/glcontext.cpp Outdated Show resolved Hide resolved
engine/src/tilecachegl3.x.cpp Outdated Show resolved Hide resolved
engine/src/tilecachegl3.x.cpp Show resolved Hide resolved
engine/src/tilecachegl3.x.cpp Outdated Show resolved Hide resolved
engine/src/tilecachegl3.x.cpp Show resolved Hide resolved
@livecodeian livecodeian force-pushed the feature-android-gl-hardwarebuffer branch 2 times, most recently from 67245e1 to bb39db2 Compare October 28, 2020 17:19
@livecodeian
Copy link
Contributor Author

@runrevmark I've revised this PR so that platform-specific code is moved to a seperate source file, and implemented the fallback for Android < 26. I've also abstracted the hardwarebuffer stuff generally and moved the #ifdef`d stuff to the bottom of the tilecache source as advised

@livecodeian livecodeian force-pushed the feature-android-gl-hardwarebuffer branch from bb39db2 to 4e37411 Compare June 16, 2021 09:10
This patch adds an "external texture" program type to the glcontext
implementation which is similar to the regular texture program except
that an EGL extension is used to access an external texture.
This patch adds an API for obtaining a hardware buffer that can be bound
to a GL texture and locked for direct access to the memory buffer.

This is implemented on Android using the AHardwareBuffer C api. The API
functions are dynamically loaded to avoid linkage failures when
attempting to run on Android versions that don't support the APIs.
This patch modifies the creation and update of GL textures to use a
native hardware buffer. This allows fast upload of texture data by
accessing the underlying buffer and copying pixel data to the texture
directly.
This patch allows armv7 builds to complete successfully until the NDK
can be updated to one that includes the required headers
(android/hardware_buffer.h).
@livecodeian livecodeian force-pushed the feature-android-gl-hardwarebuffer branch from 4e37411 to 5baadb1 Compare July 20, 2021 10:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.