Introduce BufferObject API.

NOTE: after Metal and Vulkan support lands, we can potentially simplify
the Driver API by removing some of the old VertexBuffer entry points.

This introduces a new API-level object called `BufferObject`, and a new
backend-level object called `HwBufferObject`. This encapsulates a single
VBO. It's especially useful when clients need to share data between
multiple VertexBuffer objects. (e.g. for morphing).

In the future, buffer objects could perhaps be used for non-vertex data
(e.g. for compute).

The existing `VertexBuffer` class can now be configured to use buffer
objects by calling `enableBufferObjects` on the builder. By default its
API is unchanged. If buffer objects are enabled, then clients should use
`setBufferObjectAt` (which takes a buffer object) rather than
`setBufferAt` (which takes CPU data).

OpenGL is the trickiest backend for this, due to existence of VAOs.
The implementation in this PR uses a version-tracking scheme to
figure out when to update the VAO.
This commit is contained in:
Philip Rideout
2021-03-22 15:28:15 -07:00
parent 385a17b8a5
commit ded542a543
36 changed files with 1051 additions and 55 deletions

View File

@@ -40,6 +40,7 @@ set(COMMON_DIR ${ANDROID_DIR}/common)
include_directories(${JNI_INCLUDE_DIRS} ${ANDROID_DIR})
set(JNI_SOURCE_FILES
${FILAMENT_DIR}/src/main/cpp/BufferObject.cpp
${FILAMENT_DIR}/src/main/cpp/Camera.cpp
${FILAMENT_DIR}/src/main/cpp/Colors.cpp
${FILAMENT_DIR}/src/main/cpp/ColorGrading.cpp
@@ -116,6 +117,7 @@ get_filename_component(FILAMENT_JAVA_DIR ${FILAMENT_JAVA_DIR} ABSOLUTE)
set(JAVA_SOURCE_FILES
${FILAMENT_JAVA_DIR}/com/google/android/filament/Asserts.java
${FILAMENT_JAVA_DIR}/com/google/android/filament/Box.java
${FILAMENT_JAVA_DIR}/com/google/android/filament/BufferObject.java
${FILAMENT_JAVA_DIR}/com/google/android/filament/Camera.java
${FILAMENT_JAVA_DIR}/com/google/android/filament/Colors.java
${FILAMENT_JAVA_DIR}/com/google/android/filament/ColorGrading.java