Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
791f51dcb4 | ||
|
|
4621f3ec5d | ||
|
|
ab9c09d0d9 | ||
|
|
dbf51c1c7d |
@@ -1,10 +0,0 @@
|
||||
FROM python:3.10.4
|
||||
|
||||
RUN pip3 install pygithub==1.55
|
||||
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
COPY verify_release_notes.py /verify_release_notes.py
|
||||
|
||||
RUN chmod +x /verify_release_notes.py
|
||||
ENTRYPOINT [ "/verify_release_notes.py" ]
|
||||
@@ -1,35 +0,0 @@
|
||||
name: 'Verify Release Notes'
|
||||
description: 'Verifies that a RELEASE_NOTES file has been modified'
|
||||
inputs:
|
||||
repo-token:
|
||||
description: 'The GitHub token'
|
||||
required: true
|
||||
pull-request-number:
|
||||
description: 'The Pull Request number'
|
||||
required: true
|
||||
bypass-label-name:
|
||||
description: 'The Label used to bypass this check'
|
||||
required: false
|
||||
default: 'internal'
|
||||
release-notes-file:
|
||||
description: 'The path to the RELEASE_NOTES file'
|
||||
required: false
|
||||
default: 'RELEASE_NOTES.md'
|
||||
pull-request-repo-full-name:
|
||||
description: 'The full name of the Pull Request repo'
|
||||
required: false
|
||||
default: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
pull-request-head-ref:
|
||||
description: 'The HEAD ref of the Pull Request'
|
||||
required: false
|
||||
default: ${{ github.event.pull_request.head.ref }}
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.repo-token }}
|
||||
- ${{ inputs.pull-request-number }}
|
||||
- ${{ inputs.bypass-label-name }}
|
||||
- ${{ inputs.release-notes-file }}
|
||||
- ${{ inputs.pull-request-repo-full-name }}
|
||||
- ${{ inputs.pull-request-head-ref }}
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2022 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from github import Github
|
||||
import sys, os
|
||||
|
||||
def print_usage():
|
||||
print('Verify that a GitHub pull request modifies a RELEASE_NOTES file')
|
||||
print()
|
||||
print('Usage:')
|
||||
print(' verify_release_notes.py [arguments]')
|
||||
print()
|
||||
print('Arguments:')
|
||||
print('1. github token')
|
||||
print('2. pull request number')
|
||||
print('3. bypass label name')
|
||||
print('4. release notes file path')
|
||||
print('5. pull request repo full name')
|
||||
print('6. pull request head ref')
|
||||
print()
|
||||
print('The GITHUB_REPOSITORY environment variable must be set (e.g., google/filament).')
|
||||
|
||||
def leave_single_comment(pull_request, comment_body):
|
||||
""" Leaves a comment on a PR once, without leaving a duplicate comment. """
|
||||
# To avoid spamming the PR author, we'll use this comment tag (which will render invisibly on
|
||||
# GitHub) to check if we've already left a comment on this PR.
|
||||
COMMENT_TAG = '<!-- verify_release_notes -->\n'
|
||||
comments = pull_request.get_issue_comments()
|
||||
for comment in comments:
|
||||
if comment.body.find(COMMENT_TAG) != -1:
|
||||
return
|
||||
# The GitHub token may not have WRITE permissions to leave a comment (for example, for 3P
|
||||
# contributors). In that case, we simply won't leave a comment.
|
||||
try:
|
||||
pull_request.create_issue_comment(f'{COMMENT_TAG}{comment_body}')
|
||||
except:
|
||||
print("Unable to leave comment. Continuing.")
|
||||
|
||||
# The first argument is the path to this script.
|
||||
if len(sys.argv) != 7:
|
||||
print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
authentication_token = sys.argv[1]
|
||||
pull_number = sys.argv[2]
|
||||
bypass_label_name = sys.argv[3]
|
||||
release_notes_file = sys.argv[4]
|
||||
pr_repo_full_name = sys.argv[5]
|
||||
pr_head_ref = sys.argv[6]
|
||||
|
||||
g = Github(authentication_token)
|
||||
|
||||
repo_name = os.environ.get('GITHUB_REPOSITORY')
|
||||
if repo_name is None:
|
||||
print("The GITHUB_REPOSITORY environment variable must be set.")
|
||||
sys.exit(1)
|
||||
|
||||
repo = g.get_repo(repo_name)
|
||||
|
||||
pull_request = repo.get_pull(int(pull_number))
|
||||
|
||||
# First check if the PR has the "bypass" label. This label is used for PRs that don't need to update
|
||||
# RELEASE_NOTES. If so, we can exit immediately.
|
||||
labels = [l.name for l in pull_request.labels]
|
||||
if bypass_label_name in labels:
|
||||
print(f"PR number {pull_number} in repo {repo_name} contains the '{bypass_label_name}' label.")
|
||||
print("Exiting with success.")
|
||||
sys.exit(0)
|
||||
|
||||
# Next, check if the release notes file (RELEASE_NOTES.md or similar) has been modified.
|
||||
files = pull_request.get_files()
|
||||
for file in files:
|
||||
if file.filename == release_notes_file:
|
||||
print(f"PR number {pull_number} in repo {repo_name} modifies '{release_notes_file}'.")
|
||||
print("Exiting with success.")
|
||||
sys.exit(0)
|
||||
|
||||
# At this point, we issue a warning to the PR author to remember to modify the release notes, and
|
||||
# exit with failure.
|
||||
edit_url = f"https://github.com/{pr_repo_full_name}/edit/{pr_head_ref}/{release_notes_file}"
|
||||
comment = (f"Please add a release note line to [{release_notes_file}]({edit_url}). "
|
||||
f"If this PR does not warrant a release note, add the '{bypass_label_name}' label "
|
||||
f"to this PR.")
|
||||
print(comment)
|
||||
leave_single_comment(pull_request, comment)
|
||||
|
||||
sys.exit(1)
|
||||
@@ -33,6 +33,10 @@ jobs:
|
||||
with:
|
||||
name: gltfio-android-release
|
||||
path: out/gltfio-android-release.aar
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: gltfio-android-lite-release
|
||||
path: out/gltfio-android-lite-release.aar
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-utils-android-release
|
||||
|
||||
@@ -126,6 +126,7 @@ jobs:
|
||||
mv out/filamat-android-release.aar out/filamat-${TAG}-android.aar
|
||||
mv out/filamat-android-lite-release.aar out/filamat-${TAG}-lite-android.aar
|
||||
mv out/gltfio-android-release.aar out/gltfio-${TAG}-android.aar
|
||||
mv out/gltfio-android-lite-release.aar out/gltfio-${TAG}-lite-android.aar
|
||||
mv out/filament-utils-android-release.aar out/filament-utils-${TAG}-android.aar
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.aar out/*.apk
|
||||
env:
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
name: Verify Release Notes
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
|
||||
jobs:
|
||||
verify-release-notes:
|
||||
name: Verify Release Notes
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# We *only* need to check out the .github/ directory.
|
||||
# The verify RELEASE_NOTES script uses the GitHub API to verify that RELEASE_NOTES was
|
||||
# modified.
|
||||
- name: Check out action
|
||||
uses: Bhacaz/checkout-files@73e17cfbe8d7e0c6b2672b20cb05a718e20d18d4
|
||||
with:
|
||||
files: .github
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Verify release notes
|
||||
uses: ./.github/actions/verify-release-notes
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
pull-request-number: ${{ github.event.pull_request.number }}
|
||||
+6
-7
@@ -144,9 +144,6 @@ make sure the command line tools are setup by running:
|
||||
$ xcode-select --install
|
||||
```
|
||||
|
||||
If you wish to run the Vulkan backend instead of the default Metal backend, you must install
|
||||
the LunarG SDK, enable "System Global Components", and reboot your machine.
|
||||
|
||||
Then run `cmake` and `ninja` to trigger a build:
|
||||
|
||||
```
|
||||
@@ -352,7 +349,7 @@ same version that our continuous builds use.
|
||||
|
||||
```
|
||||
cd <your chosen parent folder for the emscripten SDK>
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.zip > emsdk.zip
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.9.zip > emsdk.zip
|
||||
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
|
||||
python ./emsdk.py install latest
|
||||
python ./emsdk.py activate latest
|
||||
@@ -368,11 +365,13 @@ export EMSDK=<your chosen home for the emscripten SDK>
|
||||
|
||||
The EMSDK variable is required so that the build script can find the Emscripten SDK. The build
|
||||
creates a `samples` folder that can be used as the root of a simple static web server. Note that you
|
||||
cannot open the HTML directly from the filesystem due to CORS. We recommend using the emrun tool
|
||||
to create a quick localhost server:
|
||||
cannot open the HTML directly from the filesystem due to CORS. One way to deal with this is to
|
||||
use Python to create a quick localhost server:
|
||||
|
||||
```
|
||||
emrun out/cmake-webgl-release/web/samples --no_browser --port 8000
|
||||
cd out/cmake-webgl-release/web/samples
|
||||
python3 -m http.server # Python 3
|
||||
python -m SimpleHTTPServer # Python 2.7
|
||||
```
|
||||
|
||||
You can then open http://localhost:8000/suzanne.html in your web browser.
|
||||
|
||||
+17
-21
@@ -23,8 +23,6 @@ option(FILAMENT_SUPPORTS_XCB "Include XCB support in Linux builds" ON)
|
||||
|
||||
option(FILAMENT_SUPPORTS_XLIB "Include XLIB support in Linux builds" ON)
|
||||
|
||||
option(FILAMENT_SUPPORTS_EGL_ON_LINUX "Use EGL for OpenGL in Linux builds" OFF)
|
||||
|
||||
option(FILAMENT_SUPPORTS_WAYLAND "Include Wayland support in Linux builds" OFF)
|
||||
|
||||
option(FILAMENT_SKIP_SDL2 "Skip dependencies of SDL2, and SDL2" OFF)
|
||||
@@ -105,9 +103,6 @@ if (LINUX)
|
||||
if (FILAMENT_SUPPORTS_WAYLAND)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_WAYLAND)
|
||||
set(FILAMENT_SUPPORTS_X11 FALSE)
|
||||
elseif (FILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
set(FILAMENT_SUPPORTS_X11 FALSE)
|
||||
else ()
|
||||
if (FILAMENT_SUPPORTS_XCB)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_XCB)
|
||||
@@ -280,10 +275,6 @@ if (FILAMENT_USE_EXTERNAL_GLES3)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_EXTERNAL_GLES3")
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
set(EGL TRUE)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_USE_SWIFTSHADER)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFILAMENT_USE_SWIFTSHADER")
|
||||
endif()
|
||||
@@ -359,10 +350,6 @@ if (WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-rtti")
|
||||
endif()
|
||||
|
||||
if (WEBGL_PTHREADS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Debug compiler flags
|
||||
# ==================================================================================================
|
||||
@@ -405,8 +392,8 @@ endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GC_SECTIONS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GC_SECTIONS} ${B_SYMBOLIC_FUNCTIONS}")
|
||||
|
||||
if (WEBGL_PTHREADS)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
|
||||
if (WEBGL)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -597,6 +584,15 @@ if (FILAMENT_USE_SWIFTSHADER)
|
||||
find_library(SWIFTSHADER_VK NAMES vk_swiftshader HINTS "$ENV{SWIFTSHADER_LD_LIBRARY_PATH}")
|
||||
message(STATUS "Found SwiftShader VK library in: ${SWIFTSHADER_VK}.")
|
||||
add_definitions(-DFILAMENT_VKLIBRARY_PATH=\"${SWIFTSHADER_VK}\")
|
||||
elseif (FILAMENT_SUPPORTS_VULKAN)
|
||||
if (APPLE OR FILAMENT_LINUX_IS_MOBILE)
|
||||
find_library(Vulkan_LIBRARY NAMES vulkan HINTS "$ENV{VULKAN_SDK}/lib" "$ENV{VULKAN_SDK}/macOS/lib")
|
||||
if (Vulkan_LIBRARY)
|
||||
set(Vulkan_FOUND ON)
|
||||
message(STATUS "Found Vulkan library in SDK: ${Vulkan_LIBRARY}.")
|
||||
add_definitions(-DFILAMENT_VKLIBRARY_PATH=\"${Vulkan_LIBRARY}\")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -654,7 +650,6 @@ add_subdirectory(${LIBRARIES}/image)
|
||||
add_subdirectory(${LIBRARIES}/ktxreader)
|
||||
add_subdirectory(${LIBRARIES}/math)
|
||||
add_subdirectory(${LIBRARIES}/mathio)
|
||||
add_subdirectory(${LIBRARIES}/uberz)
|
||||
add_subdirectory(${LIBRARIES}/utils)
|
||||
add_subdirectory(${LIBRARIES}/viewer)
|
||||
add_subdirectory(${FILAMENT}/filament)
|
||||
@@ -692,6 +687,10 @@ if (FILAMENT_SUPPORTS_VULKAN)
|
||||
add_subdirectory(${EXTERNAL}/vkmemalloc/tnt)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
add_subdirectory(${EXTERNAL}/moltenvk/tnt)
|
||||
endif()
|
||||
|
||||
set(FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples)
|
||||
|
||||
if (WEBGL)
|
||||
@@ -703,9 +702,7 @@ if (IS_HOST_PLATFORM)
|
||||
if (FILAMENT_SUPPORTS_OPENGL)
|
||||
add_subdirectory(${LIBRARIES}/bluegl)
|
||||
endif()
|
||||
if (NOT FILAMENT_SKIP_SDL2)
|
||||
add_subdirectory(${LIBRARIES}/filamentapp)
|
||||
endif()
|
||||
add_subdirectory(${LIBRARIES}/filamentapp)
|
||||
add_subdirectory(${LIBRARIES}/imageio)
|
||||
|
||||
add_subdirectory(${FILAMENT}/samples)
|
||||
@@ -728,10 +725,9 @@ if (IS_HOST_PLATFORM)
|
||||
add_subdirectory(${TOOLS}/rgb-to-lmsr)
|
||||
add_subdirectory(${TOOLS}/roughness-prefilter)
|
||||
add_subdirectory(${TOOLS}/specular-color)
|
||||
add_subdirectory(${TOOLS}/uberz)
|
||||
endif()
|
||||
|
||||
# Generate exported executables for cross-compiled builds (Android, WebGL, and iOS)
|
||||
if (NOT CMAKE_CROSSCOMPILING)
|
||||
export(TARGETS matc cmgen filamesh mipgen resgen uberz glslminifier FILE ${IMPORT_EXECUTABLES})
|
||||
export(TARGETS matc cmgen filamesh mipgen resgen glslminifier FILE ${IMPORT_EXECUTABLES})
|
||||
endif()
|
||||
|
||||
+2
-1
@@ -164,7 +164,8 @@ private:
|
||||
|
||||
### Strings
|
||||
|
||||
- Never use `std::string` in the Filament core renderer. Prefer `utils::CString` or `std::string_view`.
|
||||
- Never use `std::string` in the Filament core renderer. Prefer `utils::CString` or
|
||||
`utils::StaticString`.
|
||||
- When using `std::string` in tools, always include the `std::` qualifier to disambiguate it
|
||||
from other string types.
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.filament:filament-android:1.25.5'
|
||||
implementation 'com.google.android.filament:filament-android:1.21.3'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
|
||||
iOS projects can use CocoaPods to install the latest release:
|
||||
|
||||
```
|
||||
pod 'Filament', '~> 1.25.5'
|
||||
pod 'Filament', '~> 1.21.3'
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
|
||||
+4
-35
@@ -50,13 +50,13 @@ Do not push to origin yet.
|
||||
git cherry-pick rc/$RELEASE
|
||||
```
|
||||
|
||||
Update the headers. The "main branch" header becomes a header for $NEXT_RELEASE, and a new "main
|
||||
branch" header is added.
|
||||
Update the headers. The "Next release" header becomes a header for $NEXT_RELEASE, and a new "Next
|
||||
release" header is added.
|
||||
|
||||
For example, this:
|
||||
|
||||
```
|
||||
## main branch
|
||||
## Next release (main branch)
|
||||
- foo
|
||||
- bar
|
||||
|
||||
@@ -68,7 +68,7 @@ For example, this:
|
||||
becomes:
|
||||
|
||||
```
|
||||
## main branch
|
||||
## Next release (main branch)
|
||||
|
||||
## v1.9.4
|
||||
- foo
|
||||
@@ -138,34 +138,3 @@ git push origin main
|
||||
```
|
||||
git push origin -u rc/$NEXT_RELEASE
|
||||
```
|
||||
|
||||
## 11. Rebuild the GitHub release (if failed).
|
||||
|
||||
Sometimes the GitHub release job will fail. In this case, you can manually re-run the release job.
|
||||
|
||||
### Remove any assets uploaded to the release (if needed).
|
||||
|
||||
For example, if rebuilding the Mac release, ensure that the `filament-<version>-mac.tgz` artifact
|
||||
is removed from the release assets.
|
||||
|
||||
### Update the release branch (if needed).
|
||||
|
||||
If you need to add one or more new commits to the release, perform the following:
|
||||
|
||||
First, push the new commit(s) to the `release` branch.
|
||||
|
||||
Then, with the release branch checked out with the new commit(s), run
|
||||
|
||||
```
|
||||
git tag -f -a <release tagname>
|
||||
git push origin -f <release tagname>
|
||||
```
|
||||
|
||||
This will update and force push the tag.
|
||||
|
||||
### Re-run the GitHub release workflow
|
||||
|
||||
Navigate to [Filament's release
|
||||
workflow](https://github.com/google/filament/actions/workflows/release.yml). Hit the _Run workflow_
|
||||
dropdown. Modify _Platform to build_ and _Release tag to build_, then hit _Run workflow_. This will
|
||||
initiate a new release run.
|
||||
|
||||
+1
-103
@@ -3,114 +3,12 @@
|
||||
This file contains one line summaries of commits that are worthy of mentioning in release notes.
|
||||
A new header is inserted each time a *tag* is created.
|
||||
|
||||
## main branch
|
||||
|
||||
## v1.25.5
|
||||
|
||||
- WebGL: upgraded the JS bindings to work with emsdk 3.1.15
|
||||
- WebGL: added missing IBL builder to TypeScript annotations
|
||||
- engine: Fix incorrect precision restoration when computing accurate world translations
|
||||
- engine: make `MaterialInstance` public API friendly to `std::string_view` parameters
|
||||
- gltfio: add 'detach' methods to allow ownership transfer of entities and components
|
||||
|
||||
## v1.25.4
|
||||
|
||||
- backend: streamline texture upload APIs [⚠️ **API Change**]
|
||||
|
||||
## v1.25.3
|
||||
|
||||
- engine: Fix Adreno gpu crash introduced by gpu morph target change
|
||||
- engine: Add optional memory configuration parameters to Engine initialization
|
||||
|
||||
## v1.25.2
|
||||
|
||||
- engine: `Camera::getNear()` and `Camera::getCullingFar()` now return `doubles`
|
||||
- Metal: implement scissor support.
|
||||
- engine: `Renderer::getUserTime()` now returns seconds as documented (#5722) [⚠️ **API Fix**]
|
||||
|
||||
## v1.25.1
|
||||
|
||||
- engine: add support for automatic instancing. Must be enabled with `Engine::setAutomaticInstancingEnabled(bool)`
|
||||
|
||||
## v1.25.0
|
||||
|
||||
- Vulkan: smol-v blobs are now 8-byte aligned within the filamat archive. [⚠️ **Recompile Materials**]
|
||||
- backend: added support for EGL on linux (headless)
|
||||
- uberz tool: add --append and --template arguments.
|
||||
- matc tool: add --template argument.
|
||||
|
||||
## v1.24.0
|
||||
|
||||
- ImGuiHelper: add support for Y flip.
|
||||
- Metal: ignore `MTLTexture` formatting when importing external textures.
|
||||
- materials: add a new `instanced` material parameter that is now mandatory in order to call `getInstanceIndex()`
|
||||
- gltfio: UbershaderProvider now takes the ubershader archive in its constructor [⚠️ **API Change**]
|
||||
- gltfio: Fix morphing with sparse accessors.
|
||||
- gltfio: Fix models that use signed integers for morphing.
|
||||
- engine: Documentation improvements regarding SkinningBuffer and fix an off-by-one assert when setting a SkinningBuffer.
|
||||
- picking is now exposed to JavaScript
|
||||
- gltf_viewer: Exercise picking functionality.
|
||||
- OpenGL: add WebGL support for ReadPixels
|
||||
- Vulkan: add assert and error message for OOM (debug builds)
|
||||
- Vulkan: fix crash with picking and 2-component ReadPixels.
|
||||
- backend: workaround broken GLES timer query on some Mali-Gxx old drivers
|
||||
- backend: revert c049a1 & reenable b2cdf9 ("don't issue a flush systematically after framegraph's execute")
|
||||
- gltfio: namespace now lives under Filament [⚠️ **API Change**]
|
||||
- gltfio: UbershaderLoader renamed to UbershaderProvider [⚠️ **API Change**]
|
||||
- gltfio: MaterialGenerator renamed to JitShaderProvider [⚠️ **API Change**]
|
||||
|
||||
## v1.23.2
|
||||
|
||||
- gltfio: Fix morphing for un-packed accessors.
|
||||
- gltfio: Ubershaders are now packaged into flexible archives.
|
||||
- gltfio: Remove poorly maintained lite flavor.
|
||||
- engine: Disable user scissor while rendering the Shadow Maps.
|
||||
- engine: Merge identical backend `RenderPrimitives` together.
|
||||
- engine: Improve `ResourceAllocator` performance a bit by reserving 128 cache entries.
|
||||
- utils: Remove `std::hash<T>` definitions for `libutils` types. Use `T::Hasher` explicitly instead. [⚠️ **API Change**]
|
||||
- backend: Fix WGL context attributes.
|
||||
- Metal: Fix potential invalid shaders when using gltfio in Ubershader mode. [⚠️ **Recompile Materials to get the fix**]
|
||||
|
||||
## v1.23.1
|
||||
|
||||
- gltfio: support skinning with bones that do not belong to any scene.
|
||||
- gltfio: add `attachSkin` / `detachSkin` method to FilamentAsset.
|
||||
- gltfio: ubershader mode: set sheen to `OPAQUE`.
|
||||
- Metal: fix issues seen with dynamic resolution on M1 Macs.
|
||||
- engine: add a "global" mode for render primitive's `blendOrder`.
|
||||
- engine: remove `RenderManager::setGeometryAt(index, count)`. [⚠️ **API Change**]
|
||||
- engine: fix overallocation by about 17MB.
|
||||
- WebGL: Add JS bindings for Texture class methods.
|
||||
|
||||
## v1.23.0
|
||||
|
||||
- engine: Changed UBOs layout [⚠️ **Material breakage**].
|
||||
- engine: Normals on morphed models have been fixed (core Filament change).
|
||||
- Java: View has several minor changes due to generated code, such as field ordering.
|
||||
- gltfio: Fix crash when reloading glTF assets.
|
||||
- gltfio: introduce cross-fade animation API [**NEW API**].
|
||||
|
||||
## v1.22.2
|
||||
|
||||
- Java: Minor API change: rename `ssctStartTraceDistance` to `ssctShadowDistance`. [⚠️ **API Change**]
|
||||
- Java: Minor API change: rename `blendingMode` to `blendMode`. [⚠️ **API Change**]
|
||||
- engine: Fix some memory leaks.
|
||||
|
||||
## v1.22.1
|
||||
|
||||
- Metal: Shaders now use `half` floating-point arithmetic when possible for improved performance. [⚠️ **Recompile Materials**]
|
||||
- engine: add support for presentation time in `Renderer`
|
||||
- engine: added guard bands support for screen-space effects
|
||||
- gltfio: Add multi-scene support.
|
||||
- gltfio: Various glTF-related cleanup and enhancements.
|
||||
- gltfio: Add support for KHR_texture_basisu.
|
||||
## v1.22.1 (currently main branch)
|
||||
|
||||
## v1.22.0
|
||||
|
||||
- engine: Changed UBOs layout [⚠️ **Material breakage**].
|
||||
- engine: Improve effects relying on mipmapping
|
||||
- engine: Fix assert seen with VSM shadows.
|
||||
- WebGL: Fix `isTextureFormatSupported` for ETC2 formats.
|
||||
|
||||
## v1.21.3
|
||||
|
||||
|
||||
+7
-11
@@ -81,10 +81,10 @@ buildscript {
|
||||
'minSdk': 19,
|
||||
'targetSdk': 31,
|
||||
'compileSdk': 31,
|
||||
'kotlin': '1.7.10',
|
||||
'kotlin_coroutines': '1.6.1',
|
||||
'buildTools': '33.0.0',
|
||||
'ndk': '25.0.8775105'
|
||||
'kotlin': '1.6.10',
|
||||
'kotlin_coroutines': '1.6.0',
|
||||
'buildTools': '32.0.0',
|
||||
'ndk': '23.1.7779620'
|
||||
]
|
||||
|
||||
ext.deps = [
|
||||
@@ -101,12 +101,11 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// NOTE: See TODO in gradle.properties once we move to Gradle 7.4
|
||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||
classpath 'com.android.tools.build:gradle:7.1.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
|
||||
}
|
||||
|
||||
ext.cmakeArgs = [
|
||||
"--no-warn-unused-cli",
|
||||
"-DANDROID_PIE=ON",
|
||||
"-DANDROID_PLATFORM=21",
|
||||
"-DANDROID_STL=c++_static",
|
||||
@@ -118,6 +117,8 @@ buildscript {
|
||||
|
||||
ext.cppFlags = [
|
||||
"-std=c++17",
|
||||
"-Wno-unused-command-line-argument",
|
||||
"-Wl,--hash-style=both", // Required to support API levels below 23
|
||||
"-fno-stack-protector",
|
||||
"-fno-exceptions",
|
||||
"-fno-unwind-tables",
|
||||
@@ -130,13 +131,8 @@ buildscript {
|
||||
"-fomit-frame-pointer",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-no-canonical-prefixes",
|
||||
"-Wformat",
|
||||
"-Werror=format-security",
|
||||
"-Wno-unused-command-line-argument",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-Bsymbolic-functions",
|
||||
"-Wl,--hash-style=both", // Required to support API levels below 23
|
||||
]
|
||||
|
||||
ext.abis = abis
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
plugins {
|
||||
id 'groovy-gradle-plugin'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
android {
|
||||
namespace 'com.google.android.filament.filamat'
|
||||
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
android {
|
||||
namespace 'com.google.android.filament'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation deps.androidx.annotations
|
||||
}
|
||||
|
||||
@@ -84,13 +84,13 @@ Java_com_google_android_filament_Camera_nLookAt(JNIEnv*, jclass, jlong nativeCam
|
||||
camera->lookAt({eye_x, eye_y, eye_z}, {center_x, center_y, center_z}, {up_x, up_y, up_z});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetNear(JNIEnv*, jclass, jlong nativeCamera) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
return camera->getNear();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetCullingFar(JNIEnv*, jclass,
|
||||
jlong nativeCamera) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
|
||||
@@ -316,15 +316,3 @@ Java_com_google_android_filament_Engine_nGetEntityManager(JNIEnv*, jclass, jlong
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) &engine->getEntityManager();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Engine_nSetAutomaticInstancingEnabled(JNIEnv*, jclass, jlong nativeEngine, jboolean enable) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
engine->setAutomaticInstancingEnabled(enable);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsAutomaticInstancingEnabled(JNIEnv*, jclass, jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jboolean)engine->isAutomaticInstancingEnabled();
|
||||
}
|
||||
|
||||
@@ -120,14 +120,6 @@ Java_com_google_android_filament_RenderableManager_nBuilderBlendOrder(JNIEnv*, j
|
||||
builder->blendOrder((size_t) index, (uint16_t) blendOrder);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderGlobalBlendOrderEnabled(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint index, jboolean enabled) {
|
||||
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
|
||||
builder->globalBlendOrderEnabled((size_t) index, (bool) enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderBoundingBox(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat cx, jfloat cy, jfloat cz, jfloat ex, jfloat ey, jfloat ez) {
|
||||
@@ -430,6 +422,15 @@ Java_com_google_android_filament_RenderableManager_nSetGeometryAt__JIIIJJII(JNIE
|
||||
(size_t) offset, (size_t) count);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetGeometryAt__JIIIII(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint primitiveIndex, jint primitiveType, jint offset,
|
||||
jint count) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
rm->setGeometryAt((RenderableManager::Instance) i, (size_t) primitiveIndex,
|
||||
(RenderableManager::PrimitiveType) primitiveType, (size_t) offset, (size_t) count);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetBlendOrderAt(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint primitiveIndex, jint blendOrder) {
|
||||
@@ -438,14 +439,6 @@ Java_com_google_android_filament_RenderableManager_nSetBlendOrderAt(JNIEnv*, jcl
|
||||
(uint16_t) blendOrder);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetGlobalBlendOrderEnabledAt(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint primitiveIndex, jboolean enabled) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
rm->setGlobalBlendOrderEnabledAt((RenderableManager::Instance) i, (size_t) primitiveIndex,
|
||||
(bool) enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nGetEnabledAttributesAt(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint primitiveIndex) {
|
||||
|
||||
@@ -156,9 +156,12 @@ Java_com_google_android_filament_Renderer_nResetUserTime(JNIEnv*, jclass, jlong
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nSetDisplayInfo(JNIEnv*, jclass, jlong nativeRenderer, jfloat refreshRate) {
|
||||
Java_com_google_android_filament_Renderer_nSetDisplayInfo(JNIEnv*, jclass, jlong nativeRenderer,
|
||||
jfloat refreshRate, jlong presentationDeadlineNanos, jlong vsyncOffsetNanos) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->setDisplayInfo({ .refreshRate = refreshRate });
|
||||
renderer->setDisplayInfo({ .refreshRate = refreshRate,
|
||||
.presentationDeadlineNanos = (uint64_t)presentationDeadlineNanos,
|
||||
.vsyncOffsetNanos = (uint64_t)vsyncOffsetNanos });
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -180,10 +183,3 @@ Java_com_google_android_filament_Renderer_nSetClearOptions(JNIEnv *, jclass ,
|
||||
.clear = (bool) clear,
|
||||
.discard = (bool) discard});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nSetPresentationTime(JNIEnv *, jclass ,
|
||||
jlong nativeRenderer, jlong monotonicClockNanos) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->setPresentationTime(monotonicClockNanos);
|
||||
}
|
||||
|
||||
@@ -188,6 +188,69 @@ Java_com_google_android_filament_Texture_nGetInternalFormat(JNIEnv*, jclass,
|
||||
return (jint) texture->getFormat();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage(JNIEnv* env, jclass, jlong nativeTexture,
|
||||
jlong nativeEngine, jint level, jint xoffset, jint yoffset, jint width, jint height,
|
||||
jobject storage, jint remaining,
|
||||
jint left, jint top, jint type, jint alignment,
|
||||
jint stride, jint format,
|
||||
jobject handler, jobject runnable) {
|
||||
Texture* texture = (Texture*) nativeTexture;
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
|
||||
size_t sizeInBytes = getTextureDataSize(texture, (size_t) level, (Texture::Format) format,
|
||||
(Texture::Type) type, (size_t) stride, (size_t) height, (size_t) alignment);
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
|
||||
(uint32_t) stride,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, (uint32_t) xoffset, (uint32_t) yoffset,
|
||||
(uint32_t) width, (uint32_t) height, std::move(desc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImageCompressed(JNIEnv *env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint level, jint xoffset, jint yoffset,
|
||||
jint width, jint height, jobject storage, jint remaining,
|
||||
jint, jint, jint, jint, jint compressedSizeInBytes, jint compressedFormat,
|
||||
jobject handler, jobject runnable) {
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
|
||||
size_t sizeInBytes = (size_t) compressedSizeInBytes;
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes,
|
||||
(backend::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, (uint32_t) xoffset, (uint32_t) yoffset,
|
||||
(uint32_t) width, (uint32_t) height, std::move(desc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage3D(JNIEnv* env, jclass, jlong nativeTexture,
|
||||
jlong nativeEngine, jint level,
|
||||
@@ -290,10 +353,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemap(JNIEnv *env, jclass,
|
||||
(uint32_t) stride,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
texture->setImage(*engine, (size_t) level, std::move(desc), faceOffsets);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -328,10 +388,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemapCompressed(JNIEnv *env,
|
||||
(backend::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
texture->setImage(*engine, (size_t) level, std::move(desc), faceOffsets);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -259,14 +259,14 @@ Java_com_google_android_filament_View_nSetAmbientOcclusionOptions(JNIEnv*, jclas
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetSSCTOptions(JNIEnv *, jclass, jlong nativeView,
|
||||
jfloat ssctLightConeRad, jfloat ssctShadowDistance, jfloat ssctContactDistanceMax,
|
||||
jfloat ssctLightConeRad, jfloat ssctStartTraceDistance, jfloat ssctContactDistanceMax,
|
||||
jfloat ssctIntensity, jfloat ssctLightDirX, jfloat ssctLightDirY, jfloat ssctLightDirZ,
|
||||
jfloat ssctDepthBias, jfloat ssctDepthSlopeBias, jint ssctSampleCount,
|
||||
jint ssctRayCount, jboolean ssctEnabled) {
|
||||
View* view = (View*) nativeView;
|
||||
View::AmbientOcclusionOptions options = view->getAmbientOcclusionOptions();
|
||||
options.ssct.lightConeRad = ssctLightConeRad;
|
||||
options.ssct.shadowDistance = ssctShadowDistance;
|
||||
options.ssct.shadowDistance = ssctStartTraceDistance;
|
||||
options.ssct.contactDistanceMax = ssctContactDistanceMax;
|
||||
options.ssct.intensity = ssctIntensity;
|
||||
options.ssct.lightDirection = math::float3{ ssctLightDirX, ssctLightDirY, ssctLightDirZ };
|
||||
@@ -461,11 +461,3 @@ Java_com_google_android_filament_View_nPick(JNIEnv* env, jclass,
|
||||
JniCallback::postToJavaAndDestroy(callback);
|
||||
}, callback->getHandler());
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetGuardBandOptions(JNIEnv *, jclass,
|
||||
jlong nativeView, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setGuardBandOptions({ .enabled = (bool)enabled });
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's model matrix.
|
||||
* Sets the camera's view matrix.
|
||||
* <p>
|
||||
* Helper method to set the camera's entity transform component.
|
||||
* Remember that the Camera "looks" towards its -z axis.
|
||||
@@ -412,29 +412,29 @@ public class Camera {
|
||||
* engine.getTransformManager().getInstance(camera->getEntity()), viewMatrix);
|
||||
* </pre>
|
||||
*
|
||||
* @param modelMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
* @param viewMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
*/
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float[] modelMatrix) {
|
||||
Asserts.assertMat4fIn(modelMatrix);
|
||||
nSetModelMatrix(getNativeObject(), modelMatrix);
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float[] viewMatrix) {
|
||||
Asserts.assertMat4fIn(viewMatrix);
|
||||
nSetModelMatrix(getNativeObject(), viewMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's model matrix.
|
||||
* Sets the camera's view matrix.
|
||||
* <p>
|
||||
* Helper method to set the camera's entity transform component.
|
||||
* Remember that the Camera "looks" towards its -z axis.
|
||||
* <p>
|
||||
*
|
||||
* @param modelMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
* @param viewMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
*/
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) double[] modelMatrix) {
|
||||
Asserts.assertMat4In(modelMatrix);
|
||||
nSetModelMatrixFp64(getNativeObject(), modelMatrix);
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) double[] viewMatrix) {
|
||||
Asserts.assertMat4In(viewMatrix);
|
||||
nSetModelMatrixFp64(getNativeObject(), viewMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's model matrix.
|
||||
* Sets the camera's view matrix.
|
||||
*
|
||||
* @param eyeX x-axis position of the camera in world space
|
||||
* @param eyeY y-axis position of the camera in world space
|
||||
@@ -456,7 +456,7 @@ public class Camera {
|
||||
* @return Distance to the near plane
|
||||
*/
|
||||
public float getNear() {
|
||||
return (float)nGetNear(getNativeObject());
|
||||
return nGetNear(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +464,7 @@ public class Camera {
|
||||
* @return Distance to the far plane
|
||||
*/
|
||||
public float getCullingFar() {
|
||||
return (float)nGetCullingFar(getNativeObject());
|
||||
return nGetCullingFar(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,10 +549,10 @@ public class Camera {
|
||||
/**
|
||||
* Retrieves the camera's view matrix. The view matrix is the inverse of the model matrix.
|
||||
*
|
||||
* @param out A 16-float array where the view matrix will be stored, or null in which
|
||||
* @param out A 16-float array where the model view will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-float array containing the camera's column-major view matrix.
|
||||
* @return A 16-float array containing the camera's view as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public float[] getViewMatrix(@Nullable @Size(min = 16) float[] out) {
|
||||
@@ -567,7 +567,7 @@ public class Camera {
|
||||
* @param out A 16-double array where the model view will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-double array containing the camera's column-major view matrix.
|
||||
* @return A 16-double array containing the camera's view as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public double[] getViewMatrix(@Nullable @Size(min = 16) double[] out) {
|
||||
@@ -787,8 +787,8 @@ public class Camera {
|
||||
private static native void nSetModelMatrix(long nativeCamera, float[] in);
|
||||
private static native void nSetModelMatrixFp64(long nativeCamera, double[] in);
|
||||
private static native void nLookAt(long nativeCamera, double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ);
|
||||
private static native double nGetNear(long nativeCamera);
|
||||
private static native double nGetCullingFar(long nativeCamera);
|
||||
private static native float nGetNear(long nativeCamera);
|
||||
private static native float nGetCullingFar(long nativeCamera);
|
||||
private static native void nGetProjectionMatrix(long nativeCamera, double[] out);
|
||||
private static native void nGetCullingProjectionMatrix(long nativeCamera, double[] out);
|
||||
private static native void nGetScaling(long nativeCamera, double[] out);
|
||||
|
||||
@@ -258,44 +258,6 @@ public class Engine {
|
||||
return sBackendValues[(int) nGetBackend(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to enable accurate translations.
|
||||
* If you need this Engine to handle a very large world space, one way to achieve this
|
||||
* automatically is to enable accurate translations in the TransformManager. This helper
|
||||
* provides a convenient way of doing that.
|
||||
* This is typically called once just after creating the Engine.
|
||||
*/
|
||||
public void enableAccurateTranslations() {
|
||||
getTransformManager().setAccurateTranslationsEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables automatic instancing of render primitives. Instancing of render primitive
|
||||
* can greatly reduce CPU overhead but requires the instanced primitives to be identical
|
||||
* (i.e. use the same geometry) and use the same MaterialInstance. If it is known that the
|
||||
* scene doesn't contain any identical primitives, automatic instancing can have some
|
||||
* overhead and it is then best to disable it.
|
||||
*
|
||||
* Disabled by default.
|
||||
*
|
||||
* @param enable true to enable, false to disable automatic instancing.
|
||||
*
|
||||
* @see RenderableManager
|
||||
* @see MaterialInstance
|
||||
*/
|
||||
public void setAutomaticInstancingEnabled(boolean enable) {
|
||||
nSetAutomaticInstancingEnabled(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if automatic instancing is enabled, false otherwise.
|
||||
* @see setAutomaticInstancingEnabled
|
||||
*/
|
||||
public boolean isAutomaticInstancingEnabled() {
|
||||
return nIsAutomaticInstancingEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
|
||||
// SwapChain
|
||||
|
||||
/**
|
||||
@@ -631,11 +593,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys all Filament-known components from this <code>entity</code>.
|
||||
* Destroys an <code>entity</code> and all its components.
|
||||
* <p>
|
||||
* This method destroys Filament components only, not the <code>entity</code> itself. To destroy
|
||||
* the <code>entity</code> use <code>EntityManager#destroy</code>.
|
||||
*
|
||||
* It is recommended to destroy components individually before destroying their
|
||||
* <code>entity</code>, this gives more control as to when the destruction really happens.
|
||||
* Otherwise, orphaned components are garbage collected, which can happen at a later time.
|
||||
@@ -758,6 +717,4 @@ public class Engine {
|
||||
private static native long nGetRenderableManager(long nativeEngine);
|
||||
private static native long nGetJobSystem(long nativeEngine);
|
||||
private static native long nGetEntityManager(long nativeEngine);
|
||||
private static native void nSetAutomaticInstancingEnabled(long nativeEngine, boolean enable);
|
||||
private static native boolean nIsAutomaticInstancingEnabled(long nativeEngine);
|
||||
}
|
||||
|
||||
+8
-11
@@ -104,12 +104,12 @@ public class MorphTargetBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates float4 positions for the given morph target.
|
||||
* Updates positions of morph target at the index.
|
||||
*
|
||||
* @param engine {@link Engine} instance
|
||||
* @param targetIndex The index of morph target to be updated
|
||||
* @param positions An array with at least count*4 floats
|
||||
* @param count Number of float4 vectors in positions to be consumed
|
||||
* @param positions Pointer to at least count positions
|
||||
* @param count Number of position elements in positions
|
||||
*/
|
||||
public void setPositionsAt(@NonNull Engine engine,
|
||||
@IntRange(from = 0) int targetIndex,
|
||||
@@ -122,15 +122,12 @@ public class MorphTargetBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates tangents for the given morph target.
|
||||
*
|
||||
* These quaternions must be represented as signed shorts, where real numbers in the [-1,+1]
|
||||
* range multiplied by 32767.
|
||||
* Updates tangents of morph target at the index.
|
||||
*
|
||||
* @param engine {@link Engine} instance
|
||||
* @param targetIndex The index of morph target to be updated
|
||||
* @param tangents An array with at least "count*4" shorts
|
||||
* @param count number of short4 quaternions in tangents
|
||||
* @param tangents Pointer to at least count tangents
|
||||
* @param count Number of tangent elements in tangents
|
||||
*/
|
||||
public void setTangentsAt(@NonNull Engine engine,
|
||||
@IntRange(from = 0) int targetIndex,
|
||||
@@ -143,14 +140,14 @@ public class MorphTargetBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of vertices in this {@link MorphTargetBuffer}
|
||||
* @return number of vertex count in this {@link MorphTargetBuffer}
|
||||
*/
|
||||
public int getVertexCount() {
|
||||
return nGetVertexCount(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of morph targets in this {@link MorphTargetBuffer}
|
||||
* @return number of target count in this {@link MorphTargetBuffer}
|
||||
*/
|
||||
public int getCount() {
|
||||
return nGetCount(mNativeObject);
|
||||
|
||||
+14
-34
@@ -191,9 +191,7 @@ public class RenderableManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawing order for blended primitives. The drawing order is either global or
|
||||
* local (default) to this Renderable. In either case, the Renderable priority takes
|
||||
* precedence.
|
||||
* Sets an ordering index for blended primitives that all live at the same Z value.
|
||||
*
|
||||
* @param index the primitive of interest
|
||||
* @param blendOrder draw order number (0 by default). Only the lowest 15 bits are used.
|
||||
@@ -205,18 +203,6 @@ public class RenderableManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the blend order is global or local to this Renderable (by default).
|
||||
*
|
||||
* @param index the primitive of interest
|
||||
* @param enabled true for global, false for local blend ordering.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder globalBlendOrderEnabled(@IntRange(from = 0) int index, boolean enabled) {
|
||||
nBuilderGlobalBlendOrderEnabled(mNativeBuilder, index, enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The axis-aligned bounding box of the renderable.
|
||||
*
|
||||
@@ -806,9 +792,18 @@ public class RenderableManager {
|
||||
0, indices.getIndexCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the drawing order for blended primitives. The drawing order is either global or
|
||||
* local (default) to this Renderable. In either case, the Renderable priority takes precedence.
|
||||
/**
|
||||
* Changes the geometry for the given primitive.
|
||||
*
|
||||
* @see Builder#geometry Builder.geometry
|
||||
*/
|
||||
public void setGeometryAt(@EntityInstance int i, @IntRange(from = 0) int primitiveIndex,
|
||||
@NonNull PrimitiveType type, @IntRange(from = 0) int offset, @IntRange(from = 0) int count) {
|
||||
nSetGeometryAt(mNativeObject, i, primitiveIndex, type.getValue(), offset, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the ordering index for blended primitives that all live at the same Z value.
|
||||
*
|
||||
* @see Builder#blendOrder
|
||||
*
|
||||
@@ -821,20 +816,6 @@ public class RenderableManager {
|
||||
nSetBlendOrderAt(mNativeObject, instance, primitiveIndex, blendOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether the blend order is global or local to this Renderable (by default).
|
||||
*
|
||||
* @see Builder#globalBlendOrderEnabled
|
||||
*
|
||||
* @param instance the renderable of interest
|
||||
* @param primitiveIndex the primitive of interest
|
||||
* @param enabled true for global, false for local blend ordering.
|
||||
*/
|
||||
public void setGlobalBlendOrderEnabledAt(@EntityInstance int instance, @IntRange(from = 0) int primitiveIndex,
|
||||
boolean enabled) {
|
||||
nSetGlobalBlendOrderEnabledAt(mNativeObject, instance, primitiveIndex, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the set of enabled attribute slots in the given primitive's VertexBuffer.
|
||||
*/
|
||||
@@ -872,7 +853,6 @@ public class RenderableManager {
|
||||
private static native void nBuilderGeometry(long nativeBuilder, int index, int value, long nativeVertexBuffer, long nativeIndexBuffer, int offset, int minIndex, int maxIndex, int count);
|
||||
private static native void nBuilderMaterial(long nativeBuilder, int index, long nativeMaterialInstance);
|
||||
private static native void nBuilderBlendOrder(long nativeBuilder, int index, int blendOrder);
|
||||
private static native void nBuilderGlobalBlendOrderEnabled(long nativeBuilder, int index, boolean enabled);
|
||||
private static native void nBuilderBoundingBox(long nativeBuilder, float cx, float cy, float cz, float ex, float ey, float ez);
|
||||
private static native void nBuilderLayerMask(long nativeBuilder, int select, int value);
|
||||
private static native void nBuilderPriority(long nativeBuilder, int priority);
|
||||
@@ -911,7 +891,7 @@ public class RenderableManager {
|
||||
private static native void nSetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex, long nativeMaterialInstance);
|
||||
private static native long nGetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex);
|
||||
private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, long nativeVertexBuffer, long nativeIndexBuffer, int offset, int count);
|
||||
private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, int offset, int count);
|
||||
private static native void nSetBlendOrderAt(long nativeRenderableManager, int i, int primitiveIndex, int blendOrder);
|
||||
private static native void nSetGlobalBlendOrderEnabledAt(long nativeRenderableManager, int i, int primitiveIndex, boolean enabled);
|
||||
private static native int nGetEnabledAttributesAt(long nativeRenderableManager, int i, int primitiveIndex);
|
||||
}
|
||||
|
||||
@@ -61,17 +61,13 @@ public class Renderer {
|
||||
/**
|
||||
* How far in advance a buffer must be queued for presentation at a given time in ns
|
||||
* On Android you can use {@link android.view.Display#getPresentationDeadlineNanos()}.
|
||||
* @deprecated this value is ignored
|
||||
*/
|
||||
@Deprecated
|
||||
public long presentationDeadlineNanos = 0;
|
||||
|
||||
/**
|
||||
* Offset by which vsyncSteadyClockTimeNano provided in beginFrame() is offset in ns
|
||||
* On Android you can use {@link android.view.Display#getAppVsyncOffsetNanos()}.
|
||||
* @deprecated this value is ignored
|
||||
*/
|
||||
@Deprecated
|
||||
public long vsyncOffsetNanos = 0;
|
||||
};
|
||||
|
||||
@@ -179,7 +175,8 @@ public class Renderer {
|
||||
*/
|
||||
public void setDisplayInfo(@NonNull DisplayInfo info) {
|
||||
mDisplayInfo = info;
|
||||
nSetDisplayInfo(getNativeObject(), info.refreshRate);
|
||||
nSetDisplayInfo(getNativeObject(),
|
||||
info.refreshRate, info.presentationDeadlineNanos, info.vsyncOffsetNanos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,23 +247,6 @@ public class Renderer {
|
||||
return mEngine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time at which the frame must be presented to the display.
|
||||
* <p>
|
||||
* This must be called between {@link #beginFrame} and {@link #endFrame}.
|
||||
* </p>
|
||||
*
|
||||
* @param monotonicClockNanos The time in nanoseconds corresponding to the system monotonic
|
||||
* up-time clock. The presentation time is typically set in the
|
||||
* middle of the period of interest and cannot be too far in the
|
||||
* future as it is limited by how many buffers are available in
|
||||
* the display sub-system. Typically it is set to 1 or 2 vsync
|
||||
* periods away.
|
||||
*/
|
||||
public void setPresentationTime(long monotonicClockNanos) {
|
||||
nSetPresentationTime(getNativeObject(), monotonicClockNanos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a frame for this <code>Renderer</code>.
|
||||
* <p><code>beginFrame</code> manages frame pacing, and returns whether or not a frame should be
|
||||
@@ -684,7 +664,6 @@ public class Renderer {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native void nSetPresentationTime(long nativeObject, long monotonicClockNanos);
|
||||
private static native boolean nBeginFrame(long nativeRenderer, long nativeSwapChain, long frameTimeNanos);
|
||||
private static native void nEndFrame(long nativeRenderer);
|
||||
private static native void nRender(long nativeRenderer, long nativeView);
|
||||
@@ -706,7 +685,8 @@ public class Renderer {
|
||||
Object handler, Runnable callback);
|
||||
private static native double nGetUserTime(long nativeRenderer);
|
||||
private static native void nResetUserTime(long nativeRenderer);
|
||||
private static native void nSetDisplayInfo(long nativeRenderer, float refreshRate);
|
||||
private static native void nSetDisplayInfo(long nativeRenderer,
|
||||
float refreshRate, long presentationDeadlineNanos, long vsyncOffsetNanos);
|
||||
private static native void nSetFrameRateOptions(long nativeRenderer,
|
||||
float interval, float headRoomRatio, float scaleRate, int history);
|
||||
private static native void nSetClearOptions(long nativeRenderer,
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.nio.ReadOnlyBufferException;
|
||||
* Stream supports three different configurations:
|
||||
*
|
||||
* <dl>
|
||||
* <dt>TEXTURE_ID</dt> <dd>takes an OpenGL texture ID and incurs a copy</dd>
|
||||
* <dt>ACQUIRED</dt> <dd>connects to an Android AHardwareBuffer</dd>
|
||||
* <dt>NATIVE</dt> <dd>connects to an Android SurfaceTexture</dd>
|
||||
* </dl>
|
||||
@@ -65,6 +66,12 @@ import java.nio.ReadOnlyBufferException;
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* The <b>TEXTURE_ID</b> configuration achieves synchronization automatically. In this mode,
|
||||
* Filament performs a copy on the main thread during beginFrame by blitting the external image into
|
||||
* an internal round-robin queue of images. This copy has a run-time cost.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* For <b>ACQUIRED</b> streams, there is no need to perform the copy because Filament explictly
|
||||
* acquires the stream, then releases it later via a callback function. This configuration is
|
||||
* especially useful when the Vulkan backend is enabled.
|
||||
@@ -111,7 +118,8 @@ public class Stream {
|
||||
* By default, Stream objects are {@link StreamType#ACQUIRED ACQUIRED} and must have external images pushed to them via
|
||||
* {@link #setAcquiredImage}.
|
||||
*
|
||||
* To create a {@link StreamType#NATIVE NATIVE} stream, call the <pre>stream</pre> method on the builder.
|
||||
* To create a {@link StreamType#NATIVE NATIVE} stream, call one of the <pre>stream</pre> methods
|
||||
* on the builder.
|
||||
*/
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources
|
||||
@@ -203,7 +211,7 @@ public class Stream {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this <code>Stream</code> is NATIVE or ACQUIRED.
|
||||
* Indicates whether this <code>Stream</code> is NATIVE, TEXTURE_ID, or ACQUIRED.
|
||||
*/
|
||||
public StreamType getStreamType() {
|
||||
return sStreamTypeValues[nGetStreamType(getNativeObject())];
|
||||
@@ -222,7 +230,7 @@ public class Stream {
|
||||
* also where the callback is invoked. This method can only be used for streams that were
|
||||
* constructed without calling the {@link Builder.stream} method.
|
||||
*
|
||||
* See {@link Stream} for more information about NATIVE and ACQUIRED configurations.
|
||||
* See {@link Stream} for more information about NATIVE, TEXTURE_ID, and ACQUIRED configurations.
|
||||
*
|
||||
* @param hwbuffer {@link android.hardware.HardwareBuffer HardwareBuffer} (requires API level 26)
|
||||
* @param handler {@link java.util.concurrent.Executor Executor} or {@link android.os.Handler Handler}.
|
||||
|
||||
@@ -912,7 +912,7 @@ public class Texture {
|
||||
public void setImage(@NonNull Engine engine,
|
||||
@IntRange(from = 0) int level,
|
||||
@NonNull PixelBufferDescriptor buffer) {
|
||||
setImage(engine, level, 0, 0, 0, getWidth(level), getHeight(level), 1, buffer);
|
||||
setImage(engine, level, 0, 0, getWidth(level), getHeight(level), buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -947,7 +947,25 @@ public class Texture {
|
||||
@IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset,
|
||||
@IntRange(from = 0) int width, @IntRange(from = 0) int height,
|
||||
@NonNull PixelBufferDescriptor buffer) {
|
||||
setImage(engine, level, xoffset, yoffset, 0, width, height, 1, buffer);
|
||||
int result;
|
||||
if (buffer.type == COMPRESSED) {
|
||||
result = nSetImageCompressed(getNativeObject(), engine.getNativeObject(), level,
|
||||
xoffset, yoffset, width, height,
|
||||
buffer.storage, buffer.storage.remaining(),
|
||||
buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
|
||||
buffer.compressedSizeInBytes, buffer.compressedFormat.ordinal(),
|
||||
buffer.handler, buffer.callback);
|
||||
} else {
|
||||
result = nSetImage(getNativeObject(), engine.getNativeObject(), level,
|
||||
xoffset, yoffset, width, height,
|
||||
buffer.storage, buffer.storage.remaining(),
|
||||
buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
|
||||
buffer.stride, buffer.format.ordinal(),
|
||||
buffer.handler, buffer.callback);
|
||||
}
|
||||
if (result < 0) {
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1028,9 +1046,7 @@ public class Texture {
|
||||
*
|
||||
* @see Builder#sampler
|
||||
* @see PixelBufferDescriptor
|
||||
* @deprecated use {@link #setImage(Engine, int, int, int, int, int, int, int, PixelBufferDescriptor)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setImage(@NonNull Engine engine, @IntRange(from = 0) int level,
|
||||
@NonNull PixelBufferDescriptor buffer,
|
||||
@NonNull @Size(min = 6) int[] faceOffsetsInBytes) {
|
||||
@@ -1242,6 +1258,18 @@ public class Texture {
|
||||
private static native int nGetTarget(long nativeTexture);
|
||||
private static native int nGetInternalFormat(long nativeTexture);
|
||||
|
||||
private static native int nSetImage(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int width, int height,
|
||||
Buffer storage, int remaining, int left, int top, int type, int alignment,
|
||||
int stride, int format,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native int nSetImageCompressed(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int width, int height,
|
||||
Buffer storage, int remaining, int left, int top, int type, int alignment,
|
||||
int compressedSizeInBytes, int compressedFormat,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native int nSetImage3D(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth,
|
||||
Buffer storage, int remaining, int left, int top, int type, int alignment,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+2
@@ -157,6 +157,8 @@ public class DisplayHelper {
|
||||
info = new Renderer.DisplayInfo();
|
||||
}
|
||||
info.refreshRate = DisplayHelper.getRefreshRate(display);
|
||||
info.presentationDeadlineNanos = DisplayHelper.getPresentationDeadlineNanos(display);
|
||||
info.vsyncOffsetNanos = DisplayHelper.getAppVsyncOffsetNanos(display);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.utils'
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDirs += "src/main/java"
|
||||
@@ -12,14 +10,14 @@ android {
|
||||
defaultConfig {
|
||||
missingDimensionStrategy 'functionality', 'full'
|
||||
}
|
||||
|
||||
// No need to package up the following shared libs, which arise as a side effect of our
|
||||
// externalNativeBuild dependencies. When clients pick and choose from project-level gradle
|
||||
// dependencies, these shared libs already get pulled in, so we need to avoid the error:
|
||||
// "More than one file was found with OS independent path ..."
|
||||
packagingOptions {
|
||||
// No need to package up the following shared libs, which arise as a side effect of our
|
||||
// externalNativeBuild dependencies. When clients pick and choose from project-level gradle
|
||||
// dependencies, these shared libs already get pulled in, so we need to avoid the error:
|
||||
// "More than one file was found with OS independent path ..."
|
||||
jniLibs {
|
||||
excludes += ['lib/*/libfilament-jni.so', 'lib/*/libgltfio-jni.so']
|
||||
}
|
||||
exclude 'lib/*/libfilament-jni.so'
|
||||
exclude 'lib/*/libgltfio-jni.so'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,6 @@ Java_com_google_android_filament_utils_AutomationEngine_nGetViewerOptions(JNIEnv
|
||||
const jfieldID cameraFocalLength = env->GetFieldID(klass, "cameraFocalLength", "F");
|
||||
const jfieldID cameraFocusDistance = env->GetFieldID(klass, "cameraFocusDistance", "F");
|
||||
const jfieldID autoScaleEnabled = env->GetFieldID(klass, "autoScaleEnabled", "Z");
|
||||
const jfieldID autoInstancingEnabled = env->GetFieldID(klass, "autoInstancingEnabled", "Z");
|
||||
|
||||
env->SetFloatField(result, cameraAperture, options.cameraAperture);
|
||||
env->SetFloatField(result, cameraSpeed, options.cameraSpeed);
|
||||
@@ -180,7 +179,6 @@ Java_com_google_android_filament_utils_AutomationEngine_nGetViewerOptions(JNIEnv
|
||||
env->SetFloatField(result, cameraFocalLength, options.cameraFocalLength);
|
||||
env->SetFloatField(result, cameraFocusDistance, options.cameraFocusDistance);
|
||||
env->SetBooleanField(result, autoScaleEnabled, options.autoScaleEnabled);
|
||||
env->SetBooleanField(result, autoInstancingEnabled, options.autoInstancingEnabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
|
||||
-1
@@ -103,7 +103,6 @@ public class AutomationEngine {
|
||||
public float cameraFocalLength = 28.0f;
|
||||
public float cameraFocusDistance = 0.0f;
|
||||
public boolean autoScaleEnabled = true;
|
||||
public boolean autoInstancingEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ class ModelViewer(
|
||||
view.scene = scene
|
||||
view.camera = camera
|
||||
|
||||
materialProvider = UbershaderProvider(engine)
|
||||
materialProvider = UbershaderLoader(engine)
|
||||
assetLoader = AssetLoader(engine, materialProvider, EntityManager.get())
|
||||
resourceLoader = ResourceLoader(engine, normalizeSkinningWeights, recomputeBoundingBoxes, ignoreBindTransform)
|
||||
|
||||
|
||||
@@ -23,57 +23,48 @@ add_library(basis_transcoder STATIC IMPORTED)
|
||||
set_target_properties(basis_transcoder PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbasis_transcoder.a)
|
||||
|
||||
add_library(zstd STATIC IMPORTED)
|
||||
set_target_properties(zstd PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libzstd.a)
|
||||
|
||||
add_library(utils STATIC IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
add_library(uberzlib STATIC IMPORTED)
|
||||
set_target_properties(uberzlib PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libuberzlib.a)
|
||||
add_library(gltfio_resources STATIC IMPORTED)
|
||||
set_target_properties(gltfio_resources PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_resources.a)
|
||||
|
||||
add_library(uberarchive STATIC IMPORTED)
|
||||
set_target_properties(uberarchive PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libuberarchive.a)
|
||||
add_library(gltfio_resources_lite STATIC IMPORTED)
|
||||
set_target_properties(gltfio_resources_lite PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_resources_lite.a)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.map")
|
||||
|
||||
set(GLTFIO_SRCS
|
||||
${GLTFIO_DIR}/include/gltfio/Animator.h
|
||||
${GLTFIO_DIR}/include/gltfio/AssetLoader.h
|
||||
${GLTFIO_DIR}/include/gltfio/MaterialProvider.h
|
||||
${GLTFIO_DIR}/include/gltfio/ResourceLoader.h
|
||||
${GLTFIO_DIR}/include/gltfio/FilamentAsset.h
|
||||
${GLTFIO_DIR}/include/gltfio/FilamentInstance.h
|
||||
${GLTFIO_DIR}/include/gltfio/MaterialProvider.h
|
||||
${GLTFIO_DIR}/include/gltfio/NodeManager.h
|
||||
${GLTFIO_DIR}/include/gltfio/ResourceLoader.h
|
||||
${GLTFIO_DIR}/include/gltfio/TextureProvider.h
|
||||
${GLTFIO_DIR}/include/gltfio/math.h
|
||||
|
||||
${GLTFIO_DIR}/src/ArchiveCache.cpp
|
||||
${GLTFIO_DIR}/src/ArchiveCache.h
|
||||
${GLTFIO_DIR}/src/Animator.cpp
|
||||
${GLTFIO_DIR}/src/AssetLoader.cpp
|
||||
${GLTFIO_DIR}/src/DependencyGraph.cpp
|
||||
${GLTFIO_DIR}/src/DependencyGraph.h
|
||||
${GLTFIO_DIR}/src/DracoCache.cpp
|
||||
${GLTFIO_DIR}/src/DracoCache.h
|
||||
${GLTFIO_DIR}/src/DependencyGraph.cpp
|
||||
${GLTFIO_DIR}/src/DependencyGraph.h
|
||||
${GLTFIO_DIR}/src/FFilamentAsset.h
|
||||
${GLTFIO_DIR}/src/FFilamentInstance.h
|
||||
${GLTFIO_DIR}/src/FilamentAsset.cpp
|
||||
${GLTFIO_DIR}/src/FFilamentInstance.h
|
||||
${GLTFIO_DIR}/src/FilamentInstance.cpp
|
||||
${GLTFIO_DIR}/src/FNodeManager.h
|
||||
${GLTFIO_DIR}/src/GltfEnums.h
|
||||
${GLTFIO_DIR}/src/Ktx2Provider.cpp
|
||||
${GLTFIO_DIR}/src/MaterialProvider.cpp
|
||||
${GLTFIO_DIR}/src/NodeManager.cpp
|
||||
${GLTFIO_DIR}/src/ResourceLoader.cpp
|
||||
${GLTFIO_DIR}/src/StbProvider.cpp
|
||||
${GLTFIO_DIR}/src/TangentsJob.cpp
|
||||
${GLTFIO_DIR}/src/TangentsJob.h
|
||||
${GLTFIO_DIR}/src/UbershaderProvider.cpp
|
||||
${GLTFIO_DIR}/src/TangentsJob.cpp
|
||||
${GLTFIO_DIR}/src/UbershaderLoader.cpp
|
||||
${GLTFIO_DIR}/src/Wireframe.cpp
|
||||
${GLTFIO_DIR}/src/Wireframe.h
|
||||
${GLTFIO_DIR}/src/upcast.h
|
||||
@@ -84,10 +75,11 @@ set(GLTFIO_SRCS
|
||||
src/main/cpp/FilamentInstance.cpp
|
||||
src/main/cpp/MaterialKey.cpp
|
||||
src/main/cpp/MaterialKey.h
|
||||
src/main/cpp/UbershaderProvider.cpp
|
||||
src/main/cpp/UbershaderLoader.cpp
|
||||
src/main/cpp/ResourceLoader.cpp
|
||||
|
||||
${FILAMENT_DIR}/include/gltfio/materials/uberarchive.h
|
||||
${FILAMENT_DIR}/include/gltfio/resources/gltfresources_lite.h
|
||||
${FILAMENT_DIR}/include/gltfio/resources/gltfresources.h
|
||||
|
||||
../common/NioUtils.cpp
|
||||
)
|
||||
@@ -95,9 +87,9 @@ set(GLTFIO_SRCS
|
||||
set(GLTFIO_INCLUDE_DIRS
|
||||
..
|
||||
${FILAMENT_DIR}/include
|
||||
${FILAMENT_DIR}/include/gltfio/resources
|
||||
../../filament/backend/include
|
||||
../../libs/gltfio/include
|
||||
../../third_party/basisu/zstd
|
||||
../../third_party/cgltf
|
||||
../../third_party/robin-map
|
||||
../../third_party/hat-trie
|
||||
@@ -110,8 +102,16 @@ add_library(gltfio-jni SHARED ${GLTFIO_SRCS})
|
||||
target_include_directories(gltfio-jni PRIVATE ${GLTFIO_INCLUDE_DIRS})
|
||||
set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.symbols)
|
||||
set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.map)
|
||||
target_link_libraries(gltfio-jni filament-jni utils uberzlib log stb ktxreader basis_transcoder zstd uberarchive)
|
||||
target_link_libraries(gltfio-jni dracodec)
|
||||
target_compile_definitions(gltfio-jni PUBLIC GLTFIO_DRACO_SUPPORTED=1)
|
||||
target_include_directories(gltfio-jni PRIVATE ${DRACO_DIR}/src)
|
||||
target_include_directories(gltfio-jni PRIVATE ${DRACO_DIR}/tnt)
|
||||
|
||||
if(GLTFIO_LITE)
|
||||
target_compile_definitions(gltfio-jni PUBLIC GLTFIO_LITE=1)
|
||||
target_link_libraries(gltfio-jni filament-jni utils log stb ktxreader basis_transcoder gltfio_resources_lite)
|
||||
else()
|
||||
target_link_libraries(gltfio-jni filament-jni utils log stb ktxreader basis_transcoder gltfio_resources)
|
||||
|
||||
# Enable Draco in the non-lite variant of gltfio.
|
||||
target_link_libraries(gltfio-jni dracodec)
|
||||
target_compile_definitions(gltfio-jni PUBLIC GLTFIO_DRACO_SUPPORTED=1)
|
||||
target_include_directories(gltfio-jni PRIVATE ${DRACO_DIR}/src)
|
||||
target_include_directories(gltfio-jni PRIVATE ${DRACO_DIR}/tnt)
|
||||
endif()
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
android {
|
||||
namespace 'com.google.android.filament.gltfio'
|
||||
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
dimension "functionality"
|
||||
}
|
||||
}
|
||||
packagingOptions {
|
||||
// No need to package up the following shared libs, which arise as a side effect of our
|
||||
// externalNativeBuild dependencies. When clients pick and choose from project-level gradle
|
||||
// dependencies, these shared libs already get pulled in, so we need to avoid the error:
|
||||
// "More than one file was found with OS independent path ..."
|
||||
jniLibs {
|
||||
excludes += ['lib/*/libfilament-jni.so']
|
||||
|
||||
lite {
|
||||
dimension "functionality"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DGLTFIO_LITE=ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No need to package up the following shared libs, which arise as a side effect of our
|
||||
// externalNativeBuild dependencies. When clients pick and choose from project-level gradle
|
||||
// dependencies, these shared libs already get pulled in, so we need to avoid the error:
|
||||
// "More than one file was found with OS independent path ..."
|
||||
packagingOptions {
|
||||
exclude 'lib/*/libfilament-jni.so'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -33,6 +40,11 @@ afterEvaluate { project ->
|
||||
artifactId = POM_ARTIFACT_ID_FULL
|
||||
from components.fullRelease
|
||||
}
|
||||
|
||||
liteRelease(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID_LITE
|
||||
from components.liteRelease
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::math;
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -36,13 +36,6 @@ Java_com_google_android_filament_gltfio_Animator_nUpdateBoneMatrices(JNIEnv*, jc
|
||||
animator->updateBoneMatrices();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_Animator_nApplyCrossFade(JNIEnv*, jclass, jlong nativeAnimator,
|
||||
jint previousAnimIndex, jfloat previousAnimTime, jfloat alpha) {
|
||||
Animator* animator = (Animator*) nativeAnimator;
|
||||
animator->applyCrossFade(previousAnimIndex, previousAnimTime, alpha);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_Animator_nResetBoneMatrices(JNIEnv*, jclass, jlong nativeAnimator) {
|
||||
Animator* animator = (Animator*) nativeAnimator;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "MaterialKey.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
class JavaMaterialProvider : public MaterialProvider {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::math;
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
@@ -120,34 +120,10 @@ extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetLightEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const jsize available = env->GetArrayLength(result);
|
||||
const size_t minCount = std::min(available, (jsize) asset->getLightEntityCount());
|
||||
if (minCount == 0) {
|
||||
return;
|
||||
}
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getLightEntities(), minCount, entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetRenderableEntityCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return asset->getRenderableEntityCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetRenderableEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const jsize available = env->GetArrayLength(result);
|
||||
const size_t minCount = std::min(available, (jsize) asset->getRenderableEntityCount());
|
||||
if (minCount == 0) {
|
||||
return;
|
||||
}
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getRenderableEntities(), minCount, entities);
|
||||
std::copy_n(asset->getLightEntities(),
|
||||
std::min(available, (jsize) asset->getLightEntityCount()), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
@@ -155,13 +131,10 @@ extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetCameraEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const jsize available = env->GetArrayLength(result);
|
||||
const size_t minCount = std::min(available, (jsize) asset->getCameraEntityCount());
|
||||
if (minCount == 0) {
|
||||
return;
|
||||
}
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getCameraEntities(), minCount, entities);
|
||||
std::copy_n(asset->getCameraEntities(),
|
||||
std::min(available, (jsize) asset->getCameraEntityCount()), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
@@ -340,19 +313,3 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nReleaseSourceData(JNIEnv*
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
asset->releaseSourceData();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nAttachSkin(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint skinIndex, jint targetEntity) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity target = Entity::import(targetEntity);
|
||||
asset->attachSkin(skinIndex, target);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nDetachSkin(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint skinIndex, jint targetEntity) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity target = Entity::import(targetEntity);
|
||||
asset->detachSkin(skinIndex, target);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "MaterialKey.h"
|
||||
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
|
||||
MaterialKeyHelper& MaterialKeyHelper::get() {
|
||||
static MaterialKeyHelper helper;
|
||||
|
||||
@@ -22,12 +22,10 @@
|
||||
|
||||
class MaterialKeyHelper {
|
||||
public:
|
||||
using MaterialKey = filament::gltfio::MaterialKey;
|
||||
|
||||
static MaterialKeyHelper& get();
|
||||
|
||||
void copy(JNIEnv* env, MaterialKey& dst, jobject src);
|
||||
void copy(JNIEnv* env, jobject dst, const MaterialKey& src);
|
||||
void copy(JNIEnv* env, gltfio::MaterialKey& dst, jobject src);
|
||||
void copy(JNIEnv* env, jobject dst, const gltfio::MaterialKey& src);
|
||||
|
||||
void init(JNIEnv* env); // called only from the Java static class constructor
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
static void destroy(void*, size_t, void *userData) {
|
||||
|
||||
+8
-9
@@ -17,38 +17,37 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include <gltfio/MaterialProvider.h>
|
||||
#include <gltfio/materials/uberarchive.h>
|
||||
|
||||
#include <utils/debug.h>
|
||||
|
||||
#include "MaterialKey.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::gltfio;
|
||||
using namespace gltfio;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nCreateUbershaderProvider(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_gltfio_UbershaderLoader_nCreateUbershaderLoader(JNIEnv*, jclass,
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) createUbershaderProvider(engine, UBERARCHIVE_DEFAULT_DATA, UBERARCHIVE_DEFAULT_SIZE);
|
||||
return (jlong) createUbershaderLoader(engine);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nDestroyUbershaderProvider(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_gltfio_UbershaderLoader_nDestroyUbershaderLoader(JNIEnv*, jclass,
|
||||
jlong nativeProvider) {
|
||||
auto provider = (MaterialProvider*) nativeProvider;
|
||||
delete provider;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nDestroyMaterials(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_gltfio_UbershaderLoader_nDestroyMaterials(JNIEnv*, jclass,
|
||||
jlong nativeProvider) {
|
||||
auto provider = (MaterialProvider*) nativeProvider;
|
||||
provider->destroyMaterials();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT long JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nCreateMaterialInstance(JNIEnv* env, jclass,
|
||||
Java_com_google_android_filament_gltfio_UbershaderLoader_nCreateMaterialInstance(JNIEnv* env, jclass,
|
||||
jlong nativeProvider, jobject materialKey, jintArray uvmap, jstring label) {
|
||||
MaterialKey nativeKey = {};
|
||||
|
||||
@@ -81,14 +80,14 @@ Java_com_google_android_filament_gltfio_UbershaderProvider_nCreateMaterialInstan
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nGetMaterialCount(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_gltfio_UbershaderLoader_nGetMaterialCount(JNIEnv*, jclass,
|
||||
jlong nativeProvider) {
|
||||
auto provider = (MaterialProvider*) nativeProvider;
|
||||
return provider->getMaterialsCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nGetMaterials(JNIEnv* env, jclass,
|
||||
Java_com_google_android_filament_gltfio_UbershaderLoader_nGetMaterials(JNIEnv* env, jclass,
|
||||
jlong nativeProvider, jlongArray result) {
|
||||
auto provider = (MaterialProvider *) nativeProvider;
|
||||
auto materials = provider->getMaterials();
|
||||
@@ -66,27 +66,6 @@ public class Animator {
|
||||
nUpdateBoneMatrices(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a blended transform to the union of nodes affected by two animations.
|
||||
* Used for cross-fading from a previous skinning-based animation or rigid body animation.
|
||||
*
|
||||
* First, this stashes the current transform hierarchy into a transient memory buffer.
|
||||
*
|
||||
* Next, this applies previousAnimIndex / previousAnimTime to the actual asset by internally
|
||||
* calling applyAnimation().
|
||||
*
|
||||
* Finally, the stashed local transforms are lerped (via the scale / translation / rotation
|
||||
* components) with their live counterparts, and the results are pushed to the asset.
|
||||
*
|
||||
* To achieve a cross fade effect with skinned models, clients will typically call animator
|
||||
* methods in this order: (1) applyAnimation (2) applyCrossFade (3) updateBoneMatrices. The
|
||||
* animation that clients pass to applyAnimation is the "current" animation corresponding to
|
||||
* alpha=1, while the "previous" animation passed to applyCrossFade corresponds to alpha=0.
|
||||
*/
|
||||
public void applyCrossFade(int previousAnimIndex, float previousAnimTime, float alpha) {
|
||||
nApplyCrossFade(getNativeObject(), previousAnimIndex, previousAnimTime, alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the identity matrix into all bone nodes, useful for returning to the T pose.
|
||||
*
|
||||
@@ -139,7 +118,6 @@ public class Animator {
|
||||
|
||||
private static native void nApplyAnimation(long nativeAnimator, int index, float time);
|
||||
private static native void nUpdateBoneMatrices(long nativeAnimator);
|
||||
private static native void nApplyCrossFade(long nativeAnimator, int animIndex, float animTime, float alpha);
|
||||
private static native void nResetBoneMatrices(long nativeAnimator);
|
||||
private static native int nGetAnimationCount(long nativeAnimator);
|
||||
private static native float nGetAnimationDuration(long nativeAnimator, int index);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ import java.nio.Buffer;
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* materialProvider = UbershaderProvider(engine)
|
||||
* materialProvider = UbershaderLoader(engine)
|
||||
* assetLoader = AssetLoader(engine, materialProvider, EntityManager.get())
|
||||
*
|
||||
* filamentAsset = assets.open("models/lucy.gltf").use { input ->
|
||||
|
||||
+5
-40
@@ -30,9 +30,9 @@ import com.google.android.filament.MaterialInstance;
|
||||
*
|
||||
* <p>For usage instructions, see the documentation for {@link AssetLoader}.</p>
|
||||
*
|
||||
* <p>This class owns a hierarchy of entities that have been loaded from a glTF asset. Every entity
|
||||
* has a <code>TransformManager</code> component, and some entities also have compnents managed by
|
||||
* <code>NameComponentManager</code>, <code>RenderableManager</code>, and others.</p>
|
||||
* <p>This class owns a hierarchy of entities that have been loaded from a glTF asset. Every entity has
|
||||
* a <code>TransformManager</code> component, and some entities also have
|
||||
* <code>NameComponentManager</code> and/or <code>RenderableManager</code> components.</p>
|
||||
*
|
||||
* <p>In addition to the aforementioned entities, an asset has strong ownership over a list of
|
||||
* <code>VertexBuffer</code>, <code>IndexBuffer</code>, <code>MaterialInstance</code>, and
|
||||
@@ -113,15 +113,6 @@ public class FilamentAsset {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the entities that have renderable components.
|
||||
*/
|
||||
public @NonNull @Entity int[] getRenderableEntities() {
|
||||
int[] result = new int[nGetRenderableEntityCount(mNativeObject)];
|
||||
nGetRenderableEntities(mNativeObject, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the entities that have camera components.
|
||||
*
|
||||
@@ -241,37 +232,17 @@ public class FilamentAsset {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given skin to the given node, which must have an associated mesh with
|
||||
* BONE_INDICES and BONE_WEIGHTS attributes.
|
||||
*
|
||||
* This is a no-op if the given skin index or target is invalid.
|
||||
*/
|
||||
public void attachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) {
|
||||
nAttachSkin(getNativeObject(), skinIndex, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given skin to the given node, which must have an associated mesh with
|
||||
* BONE_INDICES and BONE_WEIGHTS attributes.
|
||||
*
|
||||
* This is a no-op if the given skin index or target is invalid.
|
||||
*/
|
||||
public void detachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) {
|
||||
nDetachSkin(getNativeObject(), skinIndex, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the joint count at skin index in this asset.
|
||||
*/
|
||||
public int getJointCountAt(@IntRange(from = 0) int skinIndex) {
|
||||
public int getJointCountAt(int skinIndex) {
|
||||
return nGetJointCountAt(getNativeObject(), skinIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets joints at skin index in this asset.
|
||||
*/
|
||||
public @NonNull @Entity int[] getJointsAt(@IntRange(from = 0) int skinIndex) {
|
||||
public @NonNull @Entity int[] getJointsAt(int skinIndex) {
|
||||
int[] result = new int[getJointCountAt(skinIndex)];
|
||||
nGetJointsAt(getNativeObject(), skinIndex, result);
|
||||
return result;
|
||||
@@ -350,9 +321,6 @@ public class FilamentAsset {
|
||||
private static native int nGetLightEntityCount(long nativeAsset);
|
||||
private static native void nGetLightEntities(long nativeAsset, int[] result);
|
||||
|
||||
private static native int nGetRenderableEntityCount(long nativeAsset);
|
||||
private static native void nGetRenderableEntities(long nativeAsset, int[] result);
|
||||
|
||||
private static native int nGetCameraEntityCount(long nativeAsset);
|
||||
private static native void nGetCameraEntities(long nativeAsset, int[] result);
|
||||
|
||||
@@ -365,9 +333,6 @@ public class FilamentAsset {
|
||||
private static native int nGetMorphTargetCount(long nativeAsset, int entity);
|
||||
private static native void nGetMorphTargetNames(long nativeAsset, int entity, String[] result);
|
||||
|
||||
private static native void nAttachSkin(long nativeAsset, int skinIndex, int entity);
|
||||
private static native void nDetachSkin(long nativeAsset, int skinIndex, int entity);
|
||||
|
||||
private static native void nGetBoundingBox(long nativeAsset, float[] box);
|
||||
private static native String nGetName(long nativeAsset, int entity);
|
||||
private static native String nGetExtras(long nativeAsset, int entity);
|
||||
|
||||
+6
-6
@@ -31,7 +31,7 @@ import androidx.annotation.Size;
|
||||
* <p>This class is used by {@link AssetLoader} to create Filament materials.
|
||||
* Client applications do not need to call methods on it.</p>
|
||||
*/
|
||||
public class UbershaderProvider implements MaterialProvider {
|
||||
public class UbershaderLoader implements MaterialProvider {
|
||||
private static final VertexBuffer.VertexAttribute[] sVertexAttributesValues =
|
||||
VertexBuffer.VertexAttribute.values();
|
||||
|
||||
@@ -42,16 +42,16 @@ public class UbershaderProvider implements MaterialProvider {
|
||||
*
|
||||
* @param engine the engine used to create materials
|
||||
*/
|
||||
public UbershaderProvider(Engine engine) {
|
||||
public UbershaderLoader(Engine engine) {
|
||||
long nativeEngine = engine.getNativeObject();
|
||||
mNativeObject = nCreateUbershaderProvider(nativeEngine);
|
||||
mNativeObject = nCreateUbershaderLoader(nativeEngine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the native material provider.
|
||||
* */
|
||||
public void destroy() {
|
||||
nDestroyUbershaderProvider(mNativeObject);
|
||||
nDestroyUbershaderLoader(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public class UbershaderProvider implements MaterialProvider {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
private static native long nCreateUbershaderProvider(long nativeEngine);
|
||||
private static native void nDestroyUbershaderProvider(long nativeProvider);
|
||||
private static native long nCreateUbershaderLoader(long nativeEngine);
|
||||
private static native void nDestroyUbershaderLoader(long nativeProvider);
|
||||
private static native void nDestroyMaterials(long nativeProvider);
|
||||
private static native long nCreateMaterialInstance(long nativeProvider,
|
||||
MaterialKey config, int[] uvmap, String label);
|
||||
@@ -1,5 +1,5 @@
|
||||
GROUP=com.google.android.filament
|
||||
VERSION_NAME=1.25.5
|
||||
VERSION_NAME=1.21.3
|
||||
|
||||
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#Wed Nov 17 10:40:18 PST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Vendored
-14
@@ -14,17 +14,3 @@
|
||||
-keepclassmembers class * {
|
||||
@com.google.android.filament.proguard.UsedBy* *;
|
||||
}
|
||||
|
||||
# These classes is loaded via env->FindClass() from Utils.cpp
|
||||
# They are in the utils namespace and therefore not covered by previous rules.
|
||||
-keep class com.google.android.filament.utils.KTX1Loader
|
||||
-keep class com.google.android.filament.utils.HDRLoader
|
||||
|
||||
# These native JNI methods are loaded via env->RegisterNatives() from Utils.cpp
|
||||
-keepclassmembers class com.google.android.filament.utils.KTX1Loader {
|
||||
native <methods>;
|
||||
}
|
||||
-keepclassmembers class com.google.android.filament.utils.HDRLoader {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.gltf'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.gltf"
|
||||
@@ -34,7 +32,6 @@ android {
|
||||
targetSdkVersion versions.targetSdk
|
||||
missingDimensionStrategy 'functionality', 'full'
|
||||
}
|
||||
|
||||
// NOTE: This is a workaround required because the AGP task collectReleaseDependencies
|
||||
// is not configuration-cache friendly yet; this is only useful for Play publication
|
||||
dependenciesInfo {
|
||||
|
||||
@@ -16,8 +16,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.hellocam'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.hellocamera"
|
||||
|
||||
@@ -16,8 +16,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.hellotriangle'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.hellotriangle"
|
||||
|
||||
@@ -22,8 +22,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.ibl'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.ibl"
|
||||
|
||||
@@ -15,8 +15,6 @@ clean.doFirst {
|
||||
delete "src/main/assets"
|
||||
}
|
||||
android {
|
||||
namespace 'com.google.android.filament.litcube'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.litcube"
|
||||
|
||||
@@ -4,8 +4,6 @@ apply plugin: 'kotlin-android'
|
||||
project.ext.isSample = true
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.livewallpaper'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.livewallpaper"
|
||||
|
||||
@@ -19,8 +19,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.material_builder'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.material_builder"
|
||||
|
||||
@@ -15,8 +15,6 @@ clean.doFirst {
|
||||
delete "src/main/assets"
|
||||
}
|
||||
android {
|
||||
namespace 'com.google.android.filament.multiview'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.multiview"
|
||||
|
||||
@@ -18,8 +18,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.pagecurl'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.pagecurl"
|
||||
|
||||
@@ -59,7 +59,7 @@ vertex {
|
||||
vec3 p1 = deformPoint(theta, apex, uv.s + e, uv.t);
|
||||
vec3 p2 = deformPoint(theta, apex, uv.s, uv.t + e);
|
||||
vec3 normal = normalize(cross(p1 - p, p2 - p));
|
||||
material.worldNormal = getWorldFromModelNormalMatrix() * normal;
|
||||
material.worldNormal = objectUniforms.worldFromModelNormalMatrix * normal;
|
||||
mat4 transform = getWorldFromModelMatrix();
|
||||
material.worldPosition = mulMat4x4Float3(transform, p);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.streamtest'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.streamtest"
|
||||
|
||||
@@ -16,8 +16,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.textureview'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.textureview"
|
||||
|
||||
@@ -22,8 +22,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.textured'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.textured"
|
||||
|
||||
@@ -16,8 +16,6 @@ clean.doFirst {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.transparentrendering'
|
||||
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.filament.textureview"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -e
|
||||
|
||||
# Host tools required by Android, WebGL, and iOS builds
|
||||
MOBILE_HOST_TOOLS="matc resgen cmgen filamesh uberz"
|
||||
MOBILE_HOST_TOOLS="matc resgen cmgen filamesh"
|
||||
WEB_HOST_TOOLS="${MOBILE_HOST_TOOLS} mipgen filamesh"
|
||||
|
||||
function print_help {
|
||||
@@ -44,8 +44,6 @@ function print_help {
|
||||
echo " Add iOS simulator support to the iOS build."
|
||||
echo " -t"
|
||||
echo " Enable SwiftShader support for Vulkan in desktop builds."
|
||||
echo " -e"
|
||||
echo " Enable EGL on Linux support for desktop builds."
|
||||
echo " -l"
|
||||
echo " Build arm64/x86_64 universal libraries."
|
||||
echo " For iOS, this builds universal binaries for devices and the simulator (implies -s)."
|
||||
@@ -157,8 +155,6 @@ VULKAN_ANDROID_GRADLE_OPTION=""
|
||||
|
||||
SWIFTSHADER_OPTION="-DFILAMENT_USE_SWIFTSHADER=OFF"
|
||||
|
||||
EGL_ON_LINUX_OPTION="-DFILAMENT_SUPPORTS_EGL_ON_LINUX=OFF"
|
||||
|
||||
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=OFF"
|
||||
MATDBG_GRADLE_OPTION=""
|
||||
|
||||
@@ -219,7 +215,6 @@ function build_desktop_target {
|
||||
-DCMAKE_BUILD_TYPE="$1" \
|
||||
-DCMAKE_INSTALL_PREFIX="../${lc_target}/filament" \
|
||||
${SWIFTSHADER_OPTION} \
|
||||
${EGL_ON_LINUX_OPTION} \
|
||||
${MATDBG_OPTION} \
|
||||
${deployment_target} \
|
||||
${architectures} \
|
||||
@@ -483,12 +478,14 @@ function build_android {
|
||||
|
||||
if [[ "${INSTALL_COMMAND}" ]]; then
|
||||
echo "Installing out/filamat-android-debug.aar..."
|
||||
cp filamat-android/build/outputs/aar/filamat-android-lite-debug.aar ../out/
|
||||
cp filamat-android/build/outputs/aar/filamat-android-full-debug.aar ../out/filamat-android-debug.aar
|
||||
|
||||
echo "Installing out/filament-android-debug.aar..."
|
||||
cp filament-android/build/outputs/aar/filament-android-debug.aar ../out/
|
||||
|
||||
echo "Installing out/gltfio-android-debug.aar..."
|
||||
cp gltfio-android/build/outputs/aar/gltfio-android-lite-debug.aar ../out/
|
||||
cp gltfio-android/build/outputs/aar/gltfio-android-full-debug.aar ../out/gltfio-android-debug.aar
|
||||
|
||||
echo "Installing out/filament-utils-android-debug.aar..."
|
||||
@@ -537,6 +534,7 @@ function build_android {
|
||||
cp filament-android/build/outputs/aar/filament-android-release.aar ../out/
|
||||
|
||||
echo "Installing out/gltfio-android-release.aar..."
|
||||
cp gltfio-android/build/outputs/aar/gltfio-android-lite-release.aar ../out/
|
||||
cp gltfio-android/build/outputs/aar/gltfio-android-full-release.aar ../out/gltfio-android-release.aar
|
||||
|
||||
echo "Installing out/filament-utils-android-release.aar..."
|
||||
@@ -740,7 +738,7 @@ function run_tests {
|
||||
|
||||
pushd "$(dirname "$0")" > /dev/null
|
||||
|
||||
while getopts ":hacCfijmp:q:uvslwtedk:" opt; do
|
||||
while getopts ":hacCfijmp:q:uvslwtdk:" opt; do
|
||||
case ${opt} in
|
||||
h)
|
||||
print_help
|
||||
@@ -847,10 +845,6 @@ while getopts ":hacCfijmp:q:uvslwtedk:" opt; do
|
||||
SWIFTSHADER_OPTION="-DFILAMENT_USE_SWIFTSHADER=ON"
|
||||
echo "SwiftShader support enabled."
|
||||
;;
|
||||
e)
|
||||
EGL_ON_LINUX_OPTION="-DFILAMENT_SUPPORTS_EGL_ON_LINUX=ON -DFILAMENT_SKIP_SDL2=ON -DFILAMENT_SKIP_SAMPLES=ON"
|
||||
echo "EGL on Linux support enabled; skipping SDL2."
|
||||
;;
|
||||
l)
|
||||
IOS_BUILD_SIMULATOR=true
|
||||
BUILD_UNIVERSAL_LIBRARIES=true
|
||||
|
||||
@@ -49,8 +49,7 @@ FILAMENT_NDK_VERSION=${FILAMENT_NDK_VERSION:-$(cat `dirname $0`/ndk.version)}
|
||||
|
||||
# Install the required NDK version specifically (if not present)
|
||||
if [[ ! -d "${ANDROID_HOME}/ndk/$FILAMENT_NDK_VERSION" ]]; then
|
||||
# NOTE: We MUST use Java 1.8 to run sdkmanager currently, it fails starting with Java 11
|
||||
JAVA_HOME=${JAVA_HOME_8_X64} ${ANDROID_HOME}/tools/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
|
||||
${ANDROID_HOME}/tools/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
|
||||
fi
|
||||
|
||||
# Only build 1 64 bit target during presubmit to cut down build times during presubmit
|
||||
|
||||
@@ -1 +1 @@
|
||||
25.0.8775105
|
||||
23.1.7779620
|
||||
@@ -7,7 +7,7 @@ Deprecated==1.2.13
|
||||
idna==3.3
|
||||
pycparser==2.21
|
||||
PyGithub==1.55
|
||||
PyJWT==2.4.0
|
||||
PyJWT==2.3.0
|
||||
PyNaCl==1.5.0
|
||||
requests==2.27.1
|
||||
urllib3==1.26.9
|
||||
|
||||
@@ -17,7 +17,7 @@ export PATH="$PWD:$PATH"
|
||||
# npm install -g typescript
|
||||
|
||||
# Install emscripten.
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.zip > emsdk.zip
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.9.zip > emsdk.zip
|
||||
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
|
||||
./emsdk install latest
|
||||
./emsdk activate latest
|
||||
|
||||
@@ -119,8 +119,9 @@ cmake ..\.. ^
|
||||
:: Some resource libraries require significant heap space to compile, so first compile them serially.
|
||||
@echo on
|
||||
cmake --build . --target filagui --config %config% || exit /b
|
||||
cmake --build . --target uberarchive --config %config% || exit /b
|
||||
cmake --build . --target gltf-demo-resources --config %config% || exit /b
|
||||
cmake --build . --target gltfio_resources --config %config% || exit /b
|
||||
cmake --build . --target gltfio_resources_lite --config %config% || exit /b
|
||||
cmake --build . --target gltf-resources --config %config% || exit /b
|
||||
cmake --build . --target filamentapp-resources --config %config% || exit /b
|
||||
cmake --build . --target sample-resources --config %config% || exit /b
|
||||
cmake --build . --target suzanne-resources --config %config% || exit /b
|
||||
|
||||
@@ -3682,7 +3682,7 @@ However we only need the real bases:
|
||||
|
||||
$$\begin{align*}
|
||||
y^{m > 0}_l &= \sqrt{2} K^m_l cos(m \phi) P^m_l(cos \theta) \\
|
||||
y^{m < 0}_l &= \sqrt{2} K^m_l sin(|m| \phi) P^{|m|}_l(cos \theta) \\
|
||||
y^{m < 0}_l &= \sqrt{2} K^m_l sin(m \phi) P^{|m|}_l(cos \theta) \\
|
||||
y^0_l &= K^0_l P^0_l(cos \theta)
|
||||
\end{align*}$$
|
||||
|
||||
@@ -3716,18 +3716,19 @@ $l = 2$ | $y^{-2}_2$ $y^{-1}_2$ $y^0_2$ $y^1_2$ $y^2_2$
|
||||
It’s also fairly easy to compute the trigonometric terms recursively:
|
||||
|
||||
$$\begin{align*}
|
||||
C_m &\equiv cos(m \phi)sin(\theta)^m \\
|
||||
S_m &\equiv sin(m \phi)sin(\theta)^m \\
|
||||
C_m &\equiv cos(m \phi) \\
|
||||
S_m &\equiv sin(m \phi) \\
|
||||
\{ x, y, z \} &= \{ cos \phi sin \theta, sin \phi sin \theta, cos \theta \}
|
||||
\end{align*}$$
|
||||
|
||||
Using the angle sum trigonometric identities:
|
||||
|
||||
$$\begin{align*}
|
||||
cos(m \phi + \phi) &= cos(m \phi) cos(\phi) - sin(m \phi) sin(\phi) \Leftrightarrow C_{m + 1} = x C_m - y S_m \\
|
||||
sin(m \phi + \phi) &= sin(m \phi) cos(\phi) + cos(m \phi) sin(\phi) \Leftrightarrow S_{m + 1} = x S_m - y C_m
|
||||
cos(m \phi + \phi) &= cos(m \phi) cos(\phi) - sin(m \phi) sin(\phi) \Leftrightarrow C_{m + 1} = \frac{(x C_m - y S_m)}{sin(\theta)^{|m + 1|}} \\
|
||||
sin(m \phi + \phi) &= sin(m \phi) sin(\phi) + cos(m \phi) sin(\phi) \Leftrightarrow S_{m + 1} = \frac{(x S_m - y C_m)}{sin(\theta)^{|m + 1|}}
|
||||
\end{align*}$$
|
||||
|
||||
The equations above have an extra term $sin(\theta)^{-|m + 1|}$ but we can compensate for that in the $P^{|m|}_l(z)$ recursion by multiplying $P^l_l(z)$ by $sin(\theta)^{|m + 1|}$ which greatly simplifies the third equation in $\ref{shRecursions}$ because $P^l_l(cos \theta) sin(\theta)^{-l} = (-1)^l(2l - 1)!!$.
|
||||
|
||||
Listing [nonNormalizedSHBasis] shows the C++ code to compute the non-normalized SH basis $\frac{y^m_l(s)}{\sqrt{2} K^m_l}$:
|
||||
|
||||
|
||||
+13
-39
@@ -118,7 +118,6 @@ counter-increment: h6;margin-right:10px}
|
||||
<a href="#materialdefinitions/materialblock/shading:customsurfaceshading" class="level3"><span class="tocNumber">4.2.31 </span>Shading: customSurfaceShading</a><br>
|
||||
<a href="#materialdefinitions/vertexblock" class="level2"><span class="tocNumber">4.3 </span>Vertex block</a><br>
|
||||
<a href="#materialdefinitions/vertexblock/materialvertexinputs" class="level3"><span class="tocNumber">4.3.1 </span>Material vertex inputs</a><br>
|
||||
<a href="#materialdefinitions/vertexblock/customvertexattributes" class="level3"><span class="tocNumber">4.3.2 </span>Custom vertex attributes</a><br>
|
||||
<a href="#materialdefinitions/fragmentblock" class="level2"><span class="tocNumber">4.4 </span>Fragment block</a><br>
|
||||
<a href="#materialdefinitions/fragmentblock/preparematerialfunction" class="level3"><span class="tocNumber">4.4.1 </span>prepareMaterial function</a><br>
|
||||
<a href="#materialdefinitions/fragmentblock/materialfragmentinputs" class="level3"><span class="tocNumber">4.4.2 </span>Material fragment inputs</a><br>
|
||||
@@ -1537,7 +1536,7 @@ non-shader data.
|
||||
|
||||
</p><dl><dt>Type</dt><dd><p> array of <code>string</code>
|
||||
|
||||
</p></dd><dt>Value</dt><dd><p> Each entry must be any of <code>dynamicLighting</code>, <code>directionalLighting</code>, <code>shadowReceiver</code>,<code>skinning</code> or <code>ssr</code>.
|
||||
</p></dd><dt>Value</dt><dd><p> Each entry must be any of <code>dynamicLighting</code>, <code>directionalLighting</code>, <code>shadowReceiver</code> or <code>skinning</code>.
|
||||
|
||||
</p></dd><dt>Description</dt><dd><p> Used to specify a list of shader variants that the application guarantees will never be
|
||||
needed. These shader variants are skipped during the code generation phase, thus reducing
|
||||
@@ -1562,9 +1561,7 @@ non-shader data.
|
||||
</li>
|
||||
<li class="minus"><code>fog</code>, used when global fog is applied to the scene
|
||||
</li>
|
||||
<li class="minus"><code>vsm</code>, used when VSM shadows are enabled and the object is a shadow receiver
|
||||
</li>
|
||||
<li class="minus"><code>ssr</code>, used when screen-space reflections are enabled in the View</li></ul>
|
||||
<li class="minus"><code>vsm</code>, used when VSM shadows are enabled and the object is a shadow receiver</li></ul>
|
||||
|
||||
<p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> name : <span class="hljs-string">"Invisible shadow plane"</span>,</span>
|
||||
@@ -1610,8 +1607,7 @@ non-shader data.
|
||||
|
||||
</p><dl><dt>Type</dt><dd><p> array of <code>string</code>
|
||||
|
||||
</p></dd><dt>Value</dt><dd><p> Each entry must be any of <code>uv0</code>, <code>uv1</code>, <code>color</code>, <code>position</code>, <code>tangents</code>, <code>custom0</code>
|
||||
through <code>custom7</code>.
|
||||
</p></dd><dt>Value</dt><dd><p> Each entry must be any of <code>uv0</code>, <code>uv1</code>, <code>color</code>, <code>position</code>, <code>tangents</code>.
|
||||
|
||||
</p></dd><dt>Description</dt><dd><p> Lists the vertex attributes required by the material. The <code>position</code> attribute is always
|
||||
required and does not need to be specified. The <code>tangents</code> attribute is automatically required
|
||||
@@ -1626,8 +1622,7 @@ non-shader data.
|
||||
<span class="line"> },</span>
|
||||
<span class="line"> ],</span>
|
||||
<span class="line"> requires : [</span>
|
||||
<span class="line"> uv0,</span>
|
||||
<span class="line"> custom0</span>
|
||||
<span class="line"> uv0</span>
|
||||
<span class="line"> ],</span>
|
||||
<span class="line"> shadingModel : lit,</span>
|
||||
<span class="line">}</span>
|
||||
@@ -1636,7 +1631,6 @@ non-shader data.
|
||||
<span class="line"> void material(inout MaterialInputs material) {</span>
|
||||
<span class="line"> prepareMaterial(material);</span>
|
||||
<span class="line"> material.baseColor = texture(materialParams_texture, getUV0());</span>
|
||||
<span class="line"> material.baseColor.rgb *= getCustom0().rgb;</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="vertexandattributes:variables"> </a><a class="target" name="materialdefinitions/materialblock/vertexandattributes:variables"> </a><a class="target" name="toc4.2.8"> </a><h3>Vertex and attributes: variables</h3>
|
||||
@@ -1765,9 +1759,8 @@ non-shader data.
|
||||
render target is brightened.
|
||||
</li>
|
||||
<li class="minus"><strong class="asterisk">Masked</strong>: blending is disabled. This blending mode enables alpha masking. The alpha channel
|
||||
of the material's output defines whether a fragment is discarded or not. Additionally,
|
||||
ALPHA_TO_COVERAGE is enabled for non-translucent views. See the maskThreshold section for more
|
||||
information.</li></ul>
|
||||
of the material's output defines whether a fragment is discarded or not. See the maskThreshold
|
||||
section for more information.</li></ul>
|
||||
|
||||
<p></p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> blending : transparent</span>
|
||||
@@ -1858,9 +1851,8 @@ and sorting issues are minimized or eliminated</span></center></div></center>
|
||||
</p></dd><dt>Value</dt><dd><p> A value between <code>0.0</code> and <code>1.0</code>. Defaults to <code>0.4</code>.
|
||||
|
||||
</p></dd><dt>Description</dt><dd><p> Sets the minimum alpha value a fragment must have to not be discarded when the <code>blending</code> mode
|
||||
is set to <code>masked</code>. If the fragment is not discarded, its source alpha is set to 1. When the
|
||||
blending mode is not <code>masked</code>, this value is ignored. This value can be used to controlled the
|
||||
appearance of alpha-masked objects.
|
||||
is set to <code>masked</code>. When the blending mode is not <code>masked</code>, this value is ignored. This value
|
||||
can be used to controlled the appearance of alpha-masked objects.
|
||||
|
||||
</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> blending : masked,</span>
|
||||
@@ -2282,31 +2274,15 @@ APIs listed in the <a href="#shaderpublicapis">Shader public APIs</a> section.
|
||||
this behavior using the <code>flipUV</code> property and setting it to <code>false</code>.</p></div>
|
||||
|
||||
<p></p>
|
||||
<a class="target" name="customvertexattributes"> </a><a class="target" name="materialdefinitions/vertexblock/customvertexattributes"> </a><a class="target" name="toc4.3.2"> </a><h3>Custom vertex attributes</h3>
|
||||
<p>
|
||||
|
||||
|
||||
You can use up to 8 custom vertex attributes, all of type <code>float4</code>. These attributes can be accessed
|
||||
using the vertex block shader functions <code>getCustom0()</code> to <code>getCustom7()</code>. However, before using
|
||||
custom attributes, you <em class="asterisk">must</em> declare those attributes as required in the <code>requires</code> property of
|
||||
the material:
|
||||
|
||||
</p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> requires : [</span>
|
||||
<span class="line"> custom0,</span>
|
||||
<span class="line"> custom1,</span>
|
||||
<span class="line"> custom2</span>
|
||||
<span class="line"> ]</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="fragmentblock"> </a><a class="target" name="materialdefinitions/fragmentblock"> </a><a class="target" name="toc4.4"> </a><h2>Fragment block</h2>
|
||||
<p>
|
||||
|
||||
|
||||
The fragment block must be used to control the fragment shading stage of the material. The fragment
|
||||
The fragment block must be used to control the fragment shading stage of the material. The vertex
|
||||
block must contain valid
|
||||
<a href="https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf">ESSL 3.0</a>
|
||||
code (the version of GLSL supported in OpenGL ES 3.0). You are free to create multiple functions
|
||||
inside the fragment block but you <strong class="asterisk">must</strong> declare the <code>material</code> function:
|
||||
inside the vertex block but you <strong class="asterisk">must</strong> declare the <code>material</code> function:
|
||||
|
||||
</p><pre class="listing tilde"><code><span class="line">fragment {</span>
|
||||
<span class="line"> <span class="hljs-type">void</span> material(<span class="hljs-keyword">inout</span> MaterialInputs material) {</span>
|
||||
@@ -2340,7 +2316,7 @@ standard lit shading model:
|
||||
|
||||
|
||||
Note that you <strong class="asterisk">must</strong> call <code>prepareMaterial(material)</code> before exiting the <code>material()</code> function.
|
||||
This <code>prepareMaterial</code> function sets up the internal state of the material model. Some of the APIs
|
||||
This <code>prepareMaterial</code> function sets up the internal state of the material mdoel. Some of the APIs
|
||||
described in the Fragment APIs section - like <code>shading_normal</code> for instance - can only be accessed
|
||||
<em class="underscore">after</em> invoking <code>prepareMaterial()</code>.
|
||||
|
||||
@@ -2640,7 +2616,7 @@ type aliases:
|
||||
<p>
|
||||
|
||||
</p><div class="table"><table class="table"><tbody><tr><th style="text-align:left"> Name </th><th style="text-align:center"> Type </th><th style="text-align:left"> Description </th></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getResolution()</strong> </td><td style="text-align:center"> float4 </td><td style="text-align:left"> Dimensions of the view's effective viewport in pixels: <code>width</code>, <code>height</code>, <code>1 / width</code>, <code>1 / height</code>. This might be different from <code>View::getViewport()</code> for instance because of added rendering guard-bands. This can be used in conjunction with <code>getNormalizedViewportCoord()</code> to generate pixel coordinates. </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getResolution()</strong> </td><td style="text-align:center"> float4 </td><td style="text-align:left"> Resolution of the view in pixels: <code>width</code>, <code>height</code>, <code>1 / width</code>, <code>1 / height</code> </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldCameraPosition()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Position of the camera/eye in world space </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldOffset()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> The shift required to obtain API-level world space </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getTime()</strong> </td><td style="text-align:center"> float </td><td style="text-align:left"> Current time as a remainder of 1 second. Yields a value between 0 and 1 </td></tr>
|
||||
@@ -2845,9 +2821,7 @@ variants:
|
||||
</li>
|
||||
<li class="minus"><code>fog</code>, used when global fog is applied to the scene
|
||||
</li>
|
||||
<li class="minus"><code>vsm</code>, used when VSM shadows are enabled and the object is a shadow receiver
|
||||
</li>
|
||||
<li class="minus"><code>ssr</code>, used when screen-space reflections are enabled in the View</li></ul>
|
||||
<li class="minus"><code>vsm</code>, used when VSM shadows are enabled and the object is a shadow receiver</li></ul>
|
||||
|
||||
<p></p><p>
|
||||
|
||||
|
||||
+5
-46
@@ -1119,35 +1119,13 @@ material {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
### General: instanced
|
||||
|
||||
Type
|
||||
: `boolean`
|
||||
|
||||
Value
|
||||
: `true` or `false`. Defaults to `false`.
|
||||
|
||||
Description
|
||||
: Allows a material to access the instance index (i.e.: **`gl_InstanceIndex`**) of instanced
|
||||
primitives using `getInstanceIndex()` in the material's shader code. Never use
|
||||
**`gl_InstanceIndex`** directly. This is typically used with
|
||||
`RenderableManager::Builder::instances()`. `getInstanceIndex()` is available in both the
|
||||
vertex and fragment shader.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
|
||||
material {
|
||||
instanced : true
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
### Vertex and attributes: requires
|
||||
|
||||
Type
|
||||
: array of `string`
|
||||
|
||||
Value
|
||||
: Each entry must be any of `uv0`, `uv1`, `color`, `position`, `tangents`, `custom0`
|
||||
through `custom7`.
|
||||
: Each entry must be any of `uv0`, `uv1`, `color`, `position`, `tangents`.
|
||||
|
||||
Description
|
||||
: Lists the vertex attributes required by the material. The `position` attribute is always
|
||||
@@ -1164,8 +1142,7 @@ material {
|
||||
},
|
||||
],
|
||||
requires : [
|
||||
uv0,
|
||||
custom0
|
||||
uv0
|
||||
],
|
||||
shadingModel : lit,
|
||||
}
|
||||
@@ -1174,7 +1151,6 @@ fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
prepareMaterial(material);
|
||||
material.baseColor = texture(materialParams_texture, getUV0());
|
||||
material.baseColor.rgb *= getCustom0().rgb;
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -1865,30 +1841,13 @@ struct MaterialVertexInputs {
|
||||
of the current mesh: `material.uv0 = vec2(mesh_uv0.x, 1.0 - mesh_uv0.y)`. You can control
|
||||
this behavior using the `flipUV` property and setting it to `false`.
|
||||
|
||||
### Custom vertex attributes
|
||||
|
||||
You can use up to 8 custom vertex attributes, all of type `float4`. These attributes can be accessed
|
||||
using the vertex block shader functions `getCustom0()` to `getCustom7()`. However, before using
|
||||
custom attributes, you *must* declare those attributes as required in the `requires` property of
|
||||
the material:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
|
||||
material {
|
||||
requires : [
|
||||
custom0,
|
||||
custom1,
|
||||
custom2
|
||||
]
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
## Fragment block
|
||||
|
||||
The fragment block must be used to control the fragment shading stage of the material. The fragment
|
||||
The fragment block must be used to control the fragment shading stage of the material. The vertex
|
||||
block must contain valid
|
||||
[ESSL 3.0](https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf)
|
||||
code (the version of GLSL supported in OpenGL ES 3.0). You are free to create multiple functions
|
||||
inside the fragment block but you **must** declare the `material` function:
|
||||
inside the vertex block but you **must** declare the `material` function:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GLSL
|
||||
fragment {
|
||||
@@ -1923,7 +1882,7 @@ fragment {
|
||||
### prepareMaterial function
|
||||
|
||||
Note that you **must** call `prepareMaterial(material)` before exiting the `material()` function.
|
||||
This `prepareMaterial` function sets up the internal state of the material model. Some of the APIs
|
||||
This `prepareMaterial` function sets up the internal state of the material mdoel. Some of the APIs
|
||||
described in the Fragment APIs section - like `shading_normal` for instance - can only be accessed
|
||||
_after_ invoking `prepareMaterial()`.
|
||||
|
||||
|
||||
@@ -15,17 +15,22 @@
|
||||
*/
|
||||
|
||||
// If you are bundling this with rollup, webpack, or esbuild, the following URL should be trimmed.
|
||||
import { LitElement, html, css } from "https://unpkg.com/lit?module";
|
||||
import { LitElement, html, css } from "https://unpkg.com/lit-element?module";
|
||||
|
||||
// This little utility checks if the Filament module is ready for action.
|
||||
// If so, it immediately calls the given function. If not, it asks the Filament
|
||||
// loader to call it as soon as the module becomes ready.
|
||||
// To allow the DOM to render before the Filament WASM module is ready, we maintain a little
|
||||
// queue of tasks that get invoked as soon as the module is done loading.
|
||||
class FilamentTasks {
|
||||
constructor() {
|
||||
this.tasks = []
|
||||
if (!Filament.Engine) {
|
||||
Filament.init([], () => { for (const task of this.tasks) task(); });
|
||||
}
|
||||
}
|
||||
add(callback) {
|
||||
if (Filament.isReady) {
|
||||
callback();
|
||||
if (!Filament.Engine) {
|
||||
this.tasks.push(callback);
|
||||
} else {
|
||||
Filament.init([], callback);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +68,6 @@ class FilamentViewer extends LitElement {
|
||||
this.sky = null; // Path to skybox ktx.
|
||||
this.enableDrop = null; // Enables drag and drop.
|
||||
this.intensity = 30000; // Intensity of the image based light.
|
||||
this.materialVariant = 0; // Index of material variant.
|
||||
|
||||
// Private properties:
|
||||
this.filamentTasks = new FilamentTasks();
|
||||
@@ -80,7 +84,6 @@ class FilamentViewer extends LitElement {
|
||||
sky: { type: String },
|
||||
enableDrop: { type: Boolean },
|
||||
intensity: { type: Number },
|
||||
materialVariant: { type: Number },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +116,6 @@ class FilamentViewer extends LitElement {
|
||||
if (props.has("intensity") && this.indirectLight) {
|
||||
this.indirectLight.setIntensity(this.intensity);
|
||||
}
|
||||
if (props.has("materialVariant") && this.asset) this._applyMaterialVariant();
|
||||
}
|
||||
|
||||
static get styles() {
|
||||
@@ -246,7 +248,7 @@ class FilamentViewer extends LitElement {
|
||||
return response.arrayBuffer();
|
||||
}).then(arrayBuffer => {
|
||||
const ktxData = new Uint8Array(arrayBuffer);
|
||||
this.indirectLight = this.engine.createIblFromKtx1(ktxData);
|
||||
this.indirectLight = this.engine.createIblFromKtx(ktxData);
|
||||
this.indirectLight.setIntensity(this.intensity);
|
||||
this.scene.setIndirectLight(this.indirectLight);
|
||||
});
|
||||
@@ -264,7 +266,7 @@ class FilamentViewer extends LitElement {
|
||||
return response.arrayBuffer();
|
||||
}).then(arrayBuffer => {
|
||||
const ktxData = new Uint8Array(arrayBuffer);
|
||||
this.skybox = this.engine.createSkyFromKtx1(ktxData);
|
||||
this.skybox = this.engine.createSkyFromKtx(ktxData);
|
||||
this.scene.setSkybox(this.skybox);
|
||||
});
|
||||
}
|
||||
@@ -309,7 +311,7 @@ class FilamentViewer extends LitElement {
|
||||
asyncInterval: 30
|
||||
};
|
||||
|
||||
const doneAddingResources = (resourceLoader, stbProvider, ktx2Provider) => {
|
||||
const doneAddingResources = resourceLoader => {
|
||||
this.srcBlobResources = {};
|
||||
resourceLoader.asyncBeginLoad(this.asset);
|
||||
const timer = setInterval(() => {
|
||||
@@ -318,8 +320,6 @@ class FilamentViewer extends LitElement {
|
||||
if (progress >= 1) {
|
||||
clearInterval(timer);
|
||||
resourceLoader.delete();
|
||||
stbProvider.delete();
|
||||
ktx2Provider.delete();
|
||||
this.animator = this.asset.getAnimator();
|
||||
this.animationStartTime = Date.now();
|
||||
}
|
||||
@@ -337,20 +337,13 @@ class FilamentViewer extends LitElement {
|
||||
config.recomputeBoundingBoxes,
|
||||
config.ignoreBindTransform);
|
||||
|
||||
const stbProvider = new Filament.gltfio$StbProvider(this.engine);
|
||||
const ktx2Provider = new Filament.gltfio$Ktx2Provider(this.engine);
|
||||
|
||||
resourceLoader.addStbProvider("image/jpeg", stbProvider);
|
||||
resourceLoader.addStbProvider("image/png", stbProvider);
|
||||
resourceLoader.addKtx2Provider("image/ktx2", ktx2Provider);
|
||||
|
||||
let remaining = Object.keys(this.srcBlobResources).length;
|
||||
for (const name in this.srcBlobResources) {
|
||||
this.srcBlobResources[name].arrayBuffer().then(buffer => {
|
||||
const desc = getBufferDescriptor(new Uint8Array(buffer));
|
||||
resourceLoader.addResourceData(name, getBufferDescriptor(desc));
|
||||
if (--remaining === 0) {
|
||||
doneAddingResources(resourceLoader, stbProvider, ktx2Provider);
|
||||
doneAddingResources(resourceLoader);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -382,7 +375,6 @@ class FilamentViewer extends LitElement {
|
||||
this.asset.loadResources(() => {
|
||||
this.animator = this.asset.getAnimator();
|
||||
this.animationStartTime = Date.now();
|
||||
this._applyMaterialVariant();
|
||||
}, null, basePath);
|
||||
|
||||
this._updateOverlay();
|
||||
@@ -391,11 +383,9 @@ class FilamentViewer extends LitElement {
|
||||
|
||||
_updateAsset() {
|
||||
// Invoke the first glTF animation if it exists.
|
||||
if (this.animator) {
|
||||
if (this.animator.getAnimationCount() > 0) {
|
||||
const ms = Date.now() - this.animationStartTime;
|
||||
this.animator.applyAnimation(0, ms / 1000);
|
||||
}
|
||||
if (this.animator && this.animator.getAnimationCount() > 0) {
|
||||
const ms = Date.now() - this.animationStartTime;
|
||||
this.animator.applyAnimation(0, ms / 1000);
|
||||
this.animator.updateBoneMatrices();
|
||||
}
|
||||
|
||||
@@ -436,20 +426,6 @@ class FilamentViewer extends LitElement {
|
||||
|
||||
window.requestAnimationFrame(this._renderFrame.bind(this));
|
||||
}
|
||||
|
||||
_applyMaterialVariant() {
|
||||
if (!this.hasAttribute("materialVariant")) {
|
||||
return;
|
||||
}
|
||||
const names = this.asset.getMaterialVariantNames();
|
||||
const index = this.materialVariant;
|
||||
if (index < 0 || index >= names.length) {
|
||||
console.error(`Material variant ${index} does not exist in this asset.`);
|
||||
return;
|
||||
}
|
||||
console.info(this.src, `Applying material variant: ${names[index]}`);
|
||||
this.asset.applyMaterialVariant(index);
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("filament-viewer", FilamentViewer);
|
||||
|
||||
@@ -43,7 +43,7 @@ filament-viewer::part(canvas) {
|
||||
</p>
|
||||
|
||||
</main>
|
||||
<script src="https://unpkg.com/filament@1.25.3/filament.js"></script>
|
||||
<script src="https://unpkg.com/filament/filament.js"></script>
|
||||
<script src="https://unpkg.com/gltumble"></script>
|
||||
<script src="filament-viewer.js" type="module"></script>
|
||||
</body>
|
||||
|
||||
@@ -63,7 +63,6 @@ set(SRCS
|
||||
src/FrameSkipper.cpp
|
||||
src/Froxelizer.cpp
|
||||
src/Frustum.cpp
|
||||
src/HwRenderPrimitiveFactory.cpp
|
||||
src/IndexBuffer.cpp
|
||||
src/IndirectLight.cpp
|
||||
src/LightManager.cpp
|
||||
@@ -132,7 +131,6 @@ set(SRCS
|
||||
|
||||
set(PRIVATE_HDRS
|
||||
src/Allocators.h
|
||||
src/BufferPoolAllocator.h
|
||||
src/ColorSpace.h
|
||||
src/Culler.h
|
||||
src/DFG.h
|
||||
@@ -141,7 +139,6 @@ set(PRIVATE_HDRS
|
||||
src/FrameInfo.h
|
||||
src/FrameSkipper.h
|
||||
src/Froxelizer.h
|
||||
src/HwRenderPrimitiveFactory.h
|
||||
src/Intersections.h
|
||||
src/MaterialParser.h
|
||||
src/PerViewUniforms.h
|
||||
@@ -459,34 +456,6 @@ add_custom_command(
|
||||
APPEND
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${MATERIAL_DIR}/separableGaussianBlur1L.filamat"
|
||||
DEPENDS src/materials/separableGaussianBlur.vs
|
||||
DEPENDS src/materials/separableGaussianBlur.fs
|
||||
APPEND
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${MATERIAL_DIR}/separableGaussianBlur2L.filamat"
|
||||
DEPENDS src/materials/separableGaussianBlur.vs
|
||||
DEPENDS src/materials/separableGaussianBlur.fs
|
||||
APPEND
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${MATERIAL_DIR}/separableGaussianBlur3L.filamat"
|
||||
DEPENDS src/materials/separableGaussianBlur.vs
|
||||
DEPENDS src/materials/separableGaussianBlur.fs
|
||||
APPEND
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${MATERIAL_DIR}/separableGaussianBlur4L.filamat"
|
||||
DEPENDS src/materials/separableGaussianBlur.vs
|
||||
DEPENDS src/materials/separableGaussianBlur.fs
|
||||
APPEND
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${RESGEN_OUTPUTS}
|
||||
COMMAND resgen ${RESGEN_FLAGS} ${MATERIAL_BINS}
|
||||
|
||||
+4
-5
@@ -44,11 +44,10 @@ To link against debug builds of Filament, you must also link against:
|
||||
|
||||
- `matdbg`, Support library that adds an interactive web-based debugger to Filament
|
||||
|
||||
To use the Vulkan backend on macOS you must install the LunarG SDK, enable "System Global
|
||||
Components", and reboot your machine.
|
||||
|
||||
The easiest way to install those files is to use the macOS
|
||||
[LunarG Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) installer.
|
||||
To use the Vulkan backend on macOS you must also make the following libraries available at runtime:
|
||||
- `MoltenVK_icd.json`
|
||||
- `libMoltenVK.dylib`
|
||||
- `libvulkan.1.dylib`
|
||||
|
||||
## Linking against Filament
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ set(PUBLIC_HDRS
|
||||
include/backend/PipelineState.h
|
||||
include/backend/PixelBufferDescriptor.h
|
||||
include/backend/Platform.h
|
||||
include/backend/SamplerDescriptor.h
|
||||
include/backend/TargetBufferInfo.h
|
||||
)
|
||||
|
||||
@@ -99,8 +98,6 @@ if (FILAMENT_SUPPORTS_OPENGL AND NOT FILAMENT_USE_EXTERNAL_GLES3 AND NOT FILAMEN
|
||||
elseif (LINUX)
|
||||
if (FILAMENT_SUPPORTS_X11)
|
||||
list(APPEND SRCS src/opengl/platforms/PlatformGLX.cpp)
|
||||
elseif (FILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
list(APPEND SRCS src/opengl/platforms/PlatformEGLHeadless.cpp)
|
||||
endif()
|
||||
elseif (WIN32)
|
||||
list(APPEND SRCS src/opengl/platforms/PlatformWGL.cpp)
|
||||
@@ -307,9 +304,6 @@ endif()
|
||||
|
||||
if (LINUX)
|
||||
target_link_libraries(${TARGET} PRIVATE dl)
|
||||
if(FILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
target_link_libraries(${TARGET} PUBLIC EGL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -395,8 +389,6 @@ if (APPLE)
|
||||
test/test_MRT.cpp
|
||||
test/test_LoadImage.cpp
|
||||
test/test_RenderExternalImage.cpp
|
||||
test/test_StencilBuffer.cpp
|
||||
test/test_Scissor.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(backend_test PRIVATE
|
||||
@@ -445,3 +437,16 @@ if (APPLE AND NOT IOS)
|
||||
target_link_libraries(backend_test_mac PRIVATE -force_load backend_test)
|
||||
endif()
|
||||
|
||||
if (APPLE AND NOT Vulkan_LIBRARY AND NOT FILAMENT_USE_SWIFTSHADER)
|
||||
message(STATUS "No Vulkan SDK was found, using prebuilt MoltenVK.")
|
||||
set(MOLTENVK_DIR "../../third_party/moltenvk")
|
||||
configure_file(
|
||||
${MOLTENVK_DIR}/libvulkan.1.dylib
|
||||
${PROJECT_BINARY_DIR}/libvulkan.1.dylib COPYONLY)
|
||||
configure_file(
|
||||
${MOLTENVK_DIR}/MoltenVK_icd.json
|
||||
${PROJECT_BINARY_DIR}/MoltenVK_icd.json COPYONLY)
|
||||
configure_file(
|
||||
${MOLTENVK_DIR}/libMoltenVK.dylib
|
||||
${PROJECT_BINARY_DIR}/libMoltenVK.dylib COPYONLY)
|
||||
endif()
|
||||
|
||||
@@ -128,6 +128,7 @@ inline constexpr TargetBufferFlags getTargetBufferFlagsAt(size_t index) noexcept
|
||||
enum class BufferUsage : uint8_t {
|
||||
STATIC, //!< content modified once, used many times
|
||||
DYNAMIC, //!< content modified frequently, used many times
|
||||
STREAM, //!< content invalidated and modified frequently, used many times
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -177,18 +178,16 @@ static constexpr uint64_t FENCE_WAIT_FOR_EVER = uint64_t(-1);
|
||||
/**
|
||||
* Shader model.
|
||||
*
|
||||
* These enumerants are used across all backends and refer to a level of functionality and quality.
|
||||
*
|
||||
* For example, the OpenGL backend returns `MOBILE` if it supports OpenGL ES, or `DESKTOP` if it
|
||||
* supports Desktop OpenGL, this is later used to select the proper shader.
|
||||
*
|
||||
* Shader quality vs. performance is also affected by ShaderModel.
|
||||
* These enumerants are used across all backends and refer to a level of functionality, rather
|
||||
* than to an OpenGL specific shader model.
|
||||
*/
|
||||
enum class ShaderModel : uint8_t {
|
||||
MOBILE = 1, //!< Mobile level functionality
|
||||
DESKTOP = 2, //!< Desktop level functionality
|
||||
//! For testing
|
||||
UNKNOWN = 0,
|
||||
GL_ES_30 = 1, //!< Mobile level functionality
|
||||
GL_CORE_41 = 2, //!< Desktop level functionality
|
||||
};
|
||||
static constexpr size_t SHADER_MODEL_COUNT = 2;
|
||||
static constexpr size_t SHADER_MODEL_COUNT = 3;
|
||||
|
||||
/**
|
||||
* Primitive types
|
||||
@@ -237,12 +236,11 @@ enum class Precision : uint8_t {
|
||||
|
||||
//! Texture sampler type
|
||||
enum class SamplerType : uint8_t {
|
||||
SAMPLER_2D, //!< 2D texture
|
||||
SAMPLER_2D_ARRAY, //!< 2D array texture
|
||||
SAMPLER_CUBEMAP, //!< Cube map texture
|
||||
SAMPLER_EXTERNAL, //!< External texture
|
||||
SAMPLER_3D, //!< 3D texture
|
||||
SAMPLER_CUBEMAP_ARRAY, //!< Cube map array texture (feature level 2)
|
||||
SAMPLER_2D, //!< 2D texture
|
||||
SAMPLER_2D_ARRAY, //!< 2D array texture
|
||||
SAMPLER_CUBEMAP, //!< Cube map texture
|
||||
SAMPLER_EXTERNAL, //!< External texture
|
||||
SAMPLER_3D, //!< 3D texture
|
||||
};
|
||||
|
||||
//! Subpass type
|
||||
@@ -645,6 +643,50 @@ inline constexpr int operator +(TextureCubemapFace rhs) noexcept {
|
||||
return int(rhs);
|
||||
}
|
||||
|
||||
//! Face offsets for all faces of a cubemap
|
||||
struct FaceOffsets {
|
||||
using size_type = size_t;
|
||||
union {
|
||||
struct {
|
||||
size_type px; //!< +x face offset in bytes
|
||||
size_type nx; //!< -x face offset in bytes
|
||||
size_type py; //!< +y face offset in bytes
|
||||
size_type ny; //!< -y face offset in bytes
|
||||
size_type pz; //!< +z face offset in bytes
|
||||
size_type nz; //!< -z face offset in bytes
|
||||
};
|
||||
size_type offsets[6];
|
||||
};
|
||||
size_type operator[](size_t n) const noexcept { return offsets[n]; }
|
||||
size_type& operator[](size_t n) { return offsets[n]; }
|
||||
FaceOffsets() noexcept = default;
|
||||
explicit FaceOffsets(size_type faceSize) noexcept {
|
||||
px = faceSize * 0;
|
||||
nx = faceSize * 1;
|
||||
py = faceSize * 2;
|
||||
ny = faceSize * 3;
|
||||
pz = faceSize * 4;
|
||||
nz = faceSize * 5;
|
||||
}
|
||||
FaceOffsets(const FaceOffsets& rhs) noexcept {
|
||||
px = rhs.px;
|
||||
nx = rhs.nx;
|
||||
py = rhs.py;
|
||||
ny = rhs.ny;
|
||||
pz = rhs.pz;
|
||||
nz = rhs.nz;
|
||||
}
|
||||
FaceOffsets& operator=(const FaceOffsets& rhs) noexcept {
|
||||
px = rhs.px;
|
||||
nx = rhs.nx;
|
||||
py = rhs.py;
|
||||
ny = rhs.ny;
|
||||
pz = rhs.pz;
|
||||
nz = rhs.nz;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
//! Sampler Wrap mode
|
||||
enum class SamplerWrapMode : uint8_t {
|
||||
CLAMP_TO_EDGE, //!< clamp-to-edge. The edge of the texture extends to infinity.
|
||||
@@ -677,7 +719,7 @@ enum class SamplerCompareMode : uint8_t {
|
||||
COMPARE_TO_TEXTURE = 1
|
||||
};
|
||||
|
||||
//! comparison function for the depth / stencil sampler
|
||||
//! comparison function for the depth sampler
|
||||
enum class SamplerCompareFunc : uint8_t {
|
||||
// don't change the enums values
|
||||
LE = 0, //!< Less or equal
|
||||
@@ -686,11 +728,11 @@ enum class SamplerCompareFunc : uint8_t {
|
||||
G, //!< Strictly greater than
|
||||
E, //!< Equal
|
||||
NE, //!< Not equal
|
||||
A, //!< Always. Depth / stencil testing is deactivated.
|
||||
N //!< Never. The depth / stencil test always fails.
|
||||
A, //!< Always. Depth testing is deactivated.
|
||||
N //!< Never. The depth test always fails.
|
||||
};
|
||||
|
||||
//! Sampler parameters
|
||||
//! Sampler paramters
|
||||
struct SamplerParams { // NOLINT
|
||||
union {
|
||||
struct {
|
||||
@@ -743,18 +785,6 @@ enum class BlendFunction : uint8_t {
|
||||
SRC_ALPHA_SATURATE //!< f(src, dst) = (1,1,1) * min(src.a, 1 - dst.a), 1
|
||||
};
|
||||
|
||||
//! stencil operation
|
||||
enum class StencilOperation : uint8_t {
|
||||
KEEP, //!< Keeps the current value.
|
||||
ZERO, //!< Sets the value to 0.
|
||||
REPLACE, //!< Sets the value to the stencil reference value.
|
||||
INCR, //!< Increments the current value. Clamps to the maximum representable unsigned value.
|
||||
INCR_WRAP, //!< Increments the current value. Wraps value to zero when incrementing the maximum representable unsigned value.
|
||||
DECR, //!< Decrements the current value. Clamps to 0.
|
||||
DECR_WRAP, //!< Decrements the current value. Wraps value to the maximum representable unsigned value when decrementing a value of zero.
|
||||
INVERT, //!< Bitwise inverts the current value.
|
||||
};
|
||||
|
||||
//! Stream for external textures
|
||||
enum class StreamType {
|
||||
NATIVE, //!< Not synchronized but copy-free. Good for video.
|
||||
@@ -787,11 +817,9 @@ struct RasterState {
|
||||
using DepthFunc = backend::SamplerCompareFunc;
|
||||
using BlendEquation = backend::BlendEquation;
|
||||
using BlendFunction = backend::BlendFunction;
|
||||
using StencilFunction = backend::SamplerCompareFunc;
|
||||
using StencilOperation = backend::StencilOperation;
|
||||
|
||||
RasterState() noexcept { // NOLINT
|
||||
static_assert(sizeof(RasterState) == sizeof(uint64_t),
|
||||
static_assert(sizeof(RasterState) == sizeof(uint32_t),
|
||||
"RasterState size not what was intended");
|
||||
culling = CullingMode::BACK;
|
||||
blendEquationRGB = BlendEquation::ADD;
|
||||
@@ -800,10 +828,6 @@ struct RasterState {
|
||||
blendFunctionSrcAlpha = BlendFunction::ONE;
|
||||
blendFunctionDstRGB = BlendFunction::ZERO;
|
||||
blendFunctionDstAlpha = BlendFunction::ZERO;
|
||||
stencilFunc = StencilFunction::A;
|
||||
stencilOpStencilFail = StencilOperation::KEEP;
|
||||
stencilOpDepthFail = StencilOperation::KEEP;
|
||||
stencilOpDepthStencilPass = StencilOperation::KEEP;
|
||||
}
|
||||
|
||||
bool operator == (RasterState rhs) const noexcept { return u == rhs.u; }
|
||||
@@ -832,56 +856,40 @@ struct RasterState {
|
||||
union {
|
||||
struct {
|
||||
//! culling mode
|
||||
CullingMode culling : 2; // 2
|
||||
CullingMode culling : 2; // 2
|
||||
|
||||
//! blend equation for the red, green and blue components
|
||||
BlendEquation blendEquationRGB : 3; // 5
|
||||
BlendEquation blendEquationRGB : 3; // 5
|
||||
//! blend equation for the alpha component
|
||||
BlendEquation blendEquationAlpha : 3; // 8
|
||||
BlendEquation blendEquationAlpha : 3; // 8
|
||||
|
||||
//! blending function for the source color
|
||||
BlendFunction blendFunctionSrcRGB : 4; // 12
|
||||
BlendFunction blendFunctionSrcRGB : 4; // 12
|
||||
//! blending function for the source alpha
|
||||
BlendFunction blendFunctionSrcAlpha : 4; // 16
|
||||
BlendFunction blendFunctionSrcAlpha : 4; // 16
|
||||
//! blending function for the destination color
|
||||
BlendFunction blendFunctionDstRGB : 4; // 20
|
||||
BlendFunction blendFunctionDstRGB : 4; // 20
|
||||
//! blending function for the destination alpha
|
||||
BlendFunction blendFunctionDstAlpha : 4; // 24
|
||||
BlendFunction blendFunctionDstAlpha : 4; // 24
|
||||
|
||||
//! Whether depth-buffer writes are enabled
|
||||
bool depthWrite : 1; // 25
|
||||
bool depthWrite : 1; // 25
|
||||
//! Depth test function
|
||||
DepthFunc depthFunc : 3; // 28
|
||||
DepthFunc depthFunc : 3; // 28
|
||||
|
||||
//! Whether color-buffer writes are enabled
|
||||
bool colorWrite : 1; // 29
|
||||
bool colorWrite : 1; // 29
|
||||
|
||||
//! use alpha-channel as coverage mask for anti-aliasing
|
||||
bool alphaToCoverage : 1; // 30
|
||||
bool alphaToCoverage : 1; // 30
|
||||
|
||||
//! whether front face winding direction must be inverted
|
||||
bool inverseFrontFaces : 1; // 31
|
||||
bool inverseFrontFaces : 1; // 31
|
||||
|
||||
//! Whether stencil-buffer writes are enabled
|
||||
bool stencilWrite : 1; // 32
|
||||
//! Stencil reference value
|
||||
uint8_t stencilRef : 8; // 40
|
||||
//! Stencil test function
|
||||
StencilFunction stencilFunc : 3; // 43
|
||||
//! Stencil operation when stencil test fails
|
||||
StencilOperation stencilOpStencilFail : 3; // 46
|
||||
//! padding, must be 0
|
||||
uint8_t padding0 : 2; // 48
|
||||
//! Stencil operation when stencil test passes but depth test fails
|
||||
StencilOperation stencilOpDepthFail : 3; // 51
|
||||
//! Stencil operation when both stencil and depth test pass
|
||||
StencilOperation stencilOpDepthStencilPass : 3; // 54
|
||||
//! padding, must be 0
|
||||
uint8_t padding1 : 2; // 56
|
||||
//! padding, must be 0
|
||||
uint8_t padding2 : 8; // 64
|
||||
uint8_t padding : 1; // 32
|
||||
};
|
||||
uint64_t u = 0;
|
||||
uint32_t u = 0;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -985,9 +993,7 @@ enum class Workaround : uint16_t {
|
||||
SPLIT_EASU,
|
||||
// Backend allows feedback loop with ancillary buffers (depth/stencil) as long as they're read-only for
|
||||
// the whole render pass.
|
||||
ALLOW_READ_ONLY_ANCILLARY_FEEDBACK_LOOP,
|
||||
// for some uniform arrays, it's needed to do an initialization to avoid crash on adreno gpu
|
||||
ADRENO_UNIFORM_ARRAY_CRASH
|
||||
ALLOW_READ_ONLY_ANCILLARY_FEEDBACK_LOOP
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
@@ -1022,6 +1028,7 @@ utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::Textu
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::BufferObjectBinding binding);
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureSwizzle swizzle);
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::AttributeArray& type);
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::FaceOffsets& type);
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PolygonOffset& po);
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::RasterState& rs);
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::RenderPassParams& b);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
|
||||
@@ -37,10 +37,6 @@ public:
|
||||
uintptr_t image = 0;
|
||||
};
|
||||
|
||||
struct DriverConfig {
|
||||
size_t handleArenaSize = 0; // size of handle arena in bytes. Setting to 0 indicates default value is to be used. Driver clamps to valid values.
|
||||
};
|
||||
|
||||
virtual ~Platform() noexcept;
|
||||
|
||||
/**
|
||||
@@ -57,12 +53,10 @@ public:
|
||||
* @param sharedContext an optional shared context. This is not meaningful with all graphic
|
||||
* APIs and platforms.
|
||||
* For EGL platforms, this is an EGLContext.
|
||||
*
|
||||
* @param driverConfig specifies driver initialization parameters
|
||||
*
|
||||
* @return nullptr on failure, or a pointer to the newly created driver.
|
||||
*/
|
||||
virtual backend::Driver* createDriver(void* sharedContext, const DriverConfig& driverConfig) noexcept = 0;
|
||||
virtual backend::Driver* createDriver(void* sharedContext) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Processes the platform's event queue when called from its primary event-handling thread.
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef TNT_FILAMENT_BACKEND_SAMPLERDESCRIPTOR_H
|
||||
#define TNT_FILAMENT_BACKEND_SAMPLERDESCRIPTOR_H
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
#include <backend/Handle.h>
|
||||
|
||||
#include <utils/compiler.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
struct UTILS_PUBLIC SamplerDescriptor {
|
||||
Handle<HwTexture> t;
|
||||
SamplerParams s{};
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_SAMPLERDESCRIPTOR_H
|
||||
@@ -23,6 +23,10 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB
|
||||
# define FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB 1
|
||||
#endif
|
||||
|
||||
namespace filament {
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/ThreadUtils.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <thread>
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#include <utils/compiler.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Command debugging off. debugging virtuals are not called.
|
||||
|
||||
@@ -217,14 +217,7 @@ DECL_DRIVER_API_R_N(backend::TextureHandle, importTexture,
|
||||
DECL_DRIVER_API_R_N(backend::SamplerGroupHandle, createSamplerGroup,
|
||||
uint32_t, size)
|
||||
|
||||
DECL_DRIVER_API_R_N(backend::RenderPrimitiveHandle, createRenderPrimitive,
|
||||
backend::VertexBufferHandle, vbh,
|
||||
backend::IndexBufferHandle, ibh,
|
||||
backend::PrimitiveType, pt,
|
||||
uint32_t, offset,
|
||||
uint32_t, minIndex,
|
||||
uint32_t, maxIndex,
|
||||
uint32_t, count)
|
||||
DECL_DRIVER_API_R_0(backend::RenderPrimitiveHandle, createRenderPrimitive)
|
||||
|
||||
DECL_DRIVER_API_R_N(backend::ProgramHandle, createProgram,
|
||||
backend::Program&&, program)
|
||||
@@ -325,17 +318,18 @@ DECL_DRIVER_API_N(updateBufferObject,
|
||||
backend::BufferDescriptor&&, data,
|
||||
uint32_t, byteOffset)
|
||||
|
||||
DECL_DRIVER_API_N(updateBufferObjectUnsynchronized,
|
||||
backend::BufferObjectHandle, ibh,
|
||||
backend::BufferDescriptor&&, data,
|
||||
uint32_t, byteOffset)
|
||||
|
||||
DECL_DRIVER_API_N(resetBufferObject,
|
||||
backend::BufferObjectHandle, ibh)
|
||||
|
||||
DECL_DRIVER_API_N(updateSamplerGroup,
|
||||
backend::SamplerGroupHandle, ubh,
|
||||
backend::BufferDescriptor&&, data)
|
||||
backend::SamplerGroup&&, samplerGroup)
|
||||
|
||||
DECL_DRIVER_API_N(update2DImage,
|
||||
backend::TextureHandle, th,
|
||||
uint32_t, level,
|
||||
uint32_t, xoffset,
|
||||
uint32_t, yoffset,
|
||||
uint32_t, width,
|
||||
uint32_t, height,
|
||||
backend::PixelBufferDescriptor&&, data)
|
||||
|
||||
DECL_DRIVER_API_N(setMinMaxLevels,
|
||||
backend::TextureHandle, th,
|
||||
@@ -353,6 +347,12 @@ DECL_DRIVER_API_N(update3DImage,
|
||||
uint32_t, depth,
|
||||
backend::PixelBufferDescriptor&&, data)
|
||||
|
||||
DECL_DRIVER_API_N(updateCubeImage,
|
||||
backend::TextureHandle, th,
|
||||
uint32_t, level,
|
||||
backend::PixelBufferDescriptor&&, data,
|
||||
backend::FaceOffsets, faceOffsets)
|
||||
|
||||
DECL_DRIVER_API_N(generateMipmaps,
|
||||
backend::TextureHandle, th)
|
||||
|
||||
@@ -377,6 +377,19 @@ DECL_DRIVER_API_0(endRenderPass)
|
||||
|
||||
DECL_DRIVER_API_0(nextSubpass)
|
||||
|
||||
DECL_DRIVER_API_N(setRenderPrimitiveBuffer,
|
||||
backend::RenderPrimitiveHandle, rph,
|
||||
backend::VertexBufferHandle, vbh,
|
||||
backend::IndexBufferHandle, ibh)
|
||||
|
||||
DECL_DRIVER_API_N(setRenderPrimitiveRange,
|
||||
backend::RenderPrimitiveHandle, rph,
|
||||
backend::PrimitiveType, pt,
|
||||
uint32_t, offset,
|
||||
uint32_t, minIndex,
|
||||
uint32_t, maxIndex,
|
||||
uint32_t, count)
|
||||
|
||||
DECL_DRIVER_API_N(beginTimerQuery,
|
||||
backend::TimerQueryHandle, query)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class MetalPlatform : public DefaultPlatform {
|
||||
public:
|
||||
~MetalPlatform() override;
|
||||
|
||||
Driver* createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) noexcept override;
|
||||
Driver* createDriver(void* sharedContext) noexcept override;
|
||||
int getOSVersion() const noexcept override { return 0; }
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ protected:
|
||||
* Derived classes can use this to instantiate the default OpenGLDriver backend.
|
||||
* This is typically called from your implementation of createDriver()
|
||||
*/
|
||||
static Driver* createDefaultDriver(OpenGLPlatform* platform, void* sharedContext, const DriverConfig& driverConfig);
|
||||
static Driver* createDefaultDriver(OpenGLPlatform* platform, void* sharedContext);
|
||||
|
||||
public:
|
||||
~OpenGLPlatform() noexcept override;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
@@ -68,8 +67,6 @@ public:
|
||||
utils::Invocable<utils::io::ostream&(utils::io::ostream& out)>&& logger);
|
||||
|
||||
// sets one of the program's shader (e.g. vertex, fragment)
|
||||
// string-based shaders are null terminated, consequently the size parameter must include the
|
||||
// null terminating character.
|
||||
Program& shader(Shader shader, void const* data, size_t size) noexcept;
|
||||
|
||||
// sets the 'bindingPoint' uniform block's name for this program.
|
||||
@@ -78,7 +75,7 @@ public:
|
||||
// not permitted in glsl. The backend needs a way to associate a uniform block
|
||||
// to a binding point.
|
||||
//
|
||||
Program& setUniformBlock(size_t bindingPoint, std::string_view uniformBlockName) noexcept;
|
||||
Program& setUniformBlock(size_t bindingPoint, utils::CString uniformBlockName) noexcept;
|
||||
|
||||
// sets the 'bindingPoint' sampler group descriptor for this program.
|
||||
// 'samplers' can be destroyed after this call.
|
||||
@@ -87,14 +84,10 @@ public:
|
||||
Program& setSamplerGroup(size_t bindingPoint, ShaderStageFlags stageFlags,
|
||||
Sampler const* samplers, size_t count) noexcept;
|
||||
|
||||
// string-based shaders are null terminated, consequently the size parameter must include the
|
||||
// null terminating character.
|
||||
Program& withVertexShader(void const* data, size_t size) {
|
||||
return shader(Shader::VERTEX, data, size);
|
||||
}
|
||||
|
||||
// string-based shaders are null terminated, consequently the size parameter must include the
|
||||
// null terminating character.
|
||||
Program& withFragmentShader(void const* data, size_t size) {
|
||||
return shader(Shader::FRAGMENT, data, size);
|
||||
}
|
||||
|
||||
@@ -17,79 +17,141 @@
|
||||
#ifndef TNT_FILAMENT_BACKEND_PRIVATE_SAMPLERGROUP_H
|
||||
#define TNT_FILAMENT_BACKEND_PRIVATE_SAMPLERGROUP_H
|
||||
|
||||
#include "private/backend/DriverApiForward.h"
|
||||
#include <array>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/FixedCapacityVector.h>
|
||||
#include <utils/bitset.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
#include <backend/Handle.h>
|
||||
#include <backend/SamplerDescriptor.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
class BufferDescriptor;
|
||||
|
||||
/*
|
||||
* FIXME: this should eventually be moved into Filament, outside of backend.
|
||||
* (but it is currently used by metal/vulkan backens)
|
||||
*/
|
||||
namespace filament {
|
||||
namespace backend {
|
||||
|
||||
class SamplerGroup {
|
||||
public:
|
||||
|
||||
using SamplerParams = backend::SamplerParams;
|
||||
|
||||
SamplerGroup() noexcept {} // NOLINT
|
||||
struct Sampler {
|
||||
Handle<HwTexture> t;
|
||||
SamplerParams s{};
|
||||
};
|
||||
|
||||
SamplerGroup() noexcept { } // NOLINT
|
||||
|
||||
// create a sampler group
|
||||
explicit SamplerGroup(size_t count) noexcept;
|
||||
|
||||
// can be copied. Sets dirty flag.
|
||||
// can be copied -- this preserves dirty bits
|
||||
SamplerGroup(const SamplerGroup& rhs) noexcept;
|
||||
SamplerGroup& operator=(const SamplerGroup& rhs) noexcept;
|
||||
|
||||
// and moved. Leaves rhs empty, keep diry flag on new SamplerGroup.
|
||||
SamplerGroup(SamplerGroup&& rhs) noexcept = default;
|
||||
SamplerGroup& operator=(SamplerGroup&& rhs) = default;
|
||||
// and moved -- this cleans rhs's dirty flags
|
||||
SamplerGroup(SamplerGroup&& rhs) noexcept;
|
||||
SamplerGroup& operator=(SamplerGroup&& rhs) noexcept;
|
||||
|
||||
// copy the rhs samplers into this group and sets the dirty flag
|
||||
SamplerGroup& setSamplers(SamplerGroup const& rhs) noexcept;
|
||||
|
||||
~SamplerGroup() noexcept = default;
|
||||
|
||||
BufferDescriptor toBufferDescriptor(DriverApi& driver) const noexcept;
|
||||
// Efficiently move a SamplerGroup to the command stream. Always use std::move() on the
|
||||
// returned value, as in the future this might return SamplerGroup by value.
|
||||
SamplerGroup& toCommandStream() const noexcept;
|
||||
|
||||
// pointer to the sampler group
|
||||
Sampler const* getSamplers() const noexcept { return mBuffer.data(); }
|
||||
|
||||
// sampler count
|
||||
size_t getSize() const noexcept { return mBuffer.size(); }
|
||||
|
||||
// return if any samplers has been changed
|
||||
bool isDirty() const noexcept {
|
||||
return mDirty;
|
||||
}
|
||||
bool isDirty() const noexcept { return mDirty.any(); }
|
||||
|
||||
// mark the whole group as clean (no modified uniforms)
|
||||
void clean() const noexcept { mDirty = false; }
|
||||
void clean() const noexcept { mDirty.reset(); }
|
||||
|
||||
// set sampler at given index
|
||||
void setSampler(size_t index, backend::SamplerDescriptor sampler) noexcept;
|
||||
void setSampler(size_t index, Sampler sampler) noexcept;
|
||||
|
||||
inline void clearSampler(size_t index) {
|
||||
setSampler(index, {});
|
||||
inline void setSampler(size_t index, Handle<HwTexture> t, SamplerParams s) {
|
||||
setSampler(index, { t, s });
|
||||
}
|
||||
|
||||
|
||||
// FIXME: This is now [[deprecated]]. Currently it is only used by the Vulkan/Metal backends.
|
||||
backend::SamplerDescriptor* data() noexcept { return mBuffer.data(); }
|
||||
inline void clearSampler(size_t index) {
|
||||
setSampler(index, {});
|
||||
}
|
||||
|
||||
private:
|
||||
#if !defined(NDEBUG)
|
||||
friend utils::io::ostream& operator<<(utils::io::ostream& out, const SamplerGroup& rhs);
|
||||
#endif
|
||||
|
||||
utils::FixedCapacityVector<backend::SamplerDescriptor> mBuffer;
|
||||
mutable bool mDirty = false;
|
||||
// This could probably be cleaned-up and moved to libutils
|
||||
template<class T, size_t N>
|
||||
class static_vector { //NOLINT
|
||||
typename std::aligned_storage<sizeof(T), alignof(T)>::type mData[N];
|
||||
uint32_t mSize = 0;
|
||||
public:
|
||||
static_vector() = default; //NOLINT
|
||||
|
||||
~static_vector() noexcept {
|
||||
for (auto& elem : *this) {
|
||||
elem.~T();
|
||||
}
|
||||
}
|
||||
|
||||
explicit static_vector(size_t count) noexcept : mSize(count) {
|
||||
assert_invariant(count < N);
|
||||
std::uninitialized_fill_n(begin(), count, T{});
|
||||
}
|
||||
|
||||
static_vector(static_vector const& rhs) noexcept : mSize(rhs.mSize) {
|
||||
std::uninitialized_copy(rhs.begin(), rhs.end(), begin());
|
||||
}
|
||||
|
||||
size_t size() const noexcept { return mSize; }
|
||||
|
||||
T* data() noexcept { return reinterpret_cast<T*>(&mData[0]); }
|
||||
|
||||
T const* data() const noexcept { return reinterpret_cast<T const*>(&mData[0]); }
|
||||
|
||||
static_vector& operator=(static_vector const& rhs) noexcept {
|
||||
if (this != &rhs) {
|
||||
const size_t n = std::min(mSize, rhs.mSize);
|
||||
std::copy_n(rhs.begin(), n, begin());
|
||||
for (size_t pos = n, c = mSize; pos < c; ++pos) {
|
||||
data()[pos].~T();
|
||||
}
|
||||
std::uninitialized_copy(rhs.begin() + n, rhs.end(), begin() + n);
|
||||
mSize = rhs.mSize;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const T& operator[](size_t pos) const noexcept {
|
||||
assert_invariant(pos < mSize);
|
||||
return data()[pos];
|
||||
}
|
||||
|
||||
T& operator[](size_t pos) noexcept {
|
||||
assert_invariant(pos < mSize);
|
||||
return data()[pos];
|
||||
}
|
||||
|
||||
T* begin() { return data(); }
|
||||
T* end() { return data() + mSize; }
|
||||
T const* begin() const { return data(); }
|
||||
T const* end() const { return data() + mSize; }
|
||||
};
|
||||
|
||||
static_vector<Sampler, backend::MAX_SAMPLER_COUNT> mBuffer; // 128 bytes
|
||||
mutable utils::bitset32 mDirty;
|
||||
};
|
||||
|
||||
} // namespace filament::backend
|
||||
} // namespace backend
|
||||
} // namespace filament
|
||||
|
||||
#endif // TNT_FILAMENT_BACKEND_PRIVATE_SAMPLERGROUP_H
|
||||
|
||||
@@ -83,9 +83,9 @@ void CommandBufferQueue::flush() noexcept {
|
||||
// circular buffer is too small, we corrupted the stream
|
||||
ASSERT_POSTCONDITION(used <= mFreeSpace,
|
||||
"Backend CommandStream overflow. Commands are corrupted and unrecoverable.\n"
|
||||
"Please increase minCommandBufferSizeMB inside the Config passed to Engine::create.\n"
|
||||
"Please increase FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB (currently %u MiB).\n"
|
||||
"Space used at this time: %u bytes",
|
||||
(unsigned)used);
|
||||
(unsigned)FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB, (unsigned)used);
|
||||
|
||||
// wait until there is enough space in the buffer
|
||||
mFreeSpace -= used;
|
||||
|
||||
@@ -40,13 +40,12 @@ public:
|
||||
// trailing channels. This is useful for platforms that only accept 4-component data, since
|
||||
// users often wish to submit (or receive) 3-component data.
|
||||
template<typename componentType, size_t srcChannelCount, size_t dstChannelCount>
|
||||
static void reshape(void* UTILS_RESTRICT dest, const void* UTILS_RESTRICT src,
|
||||
size_t numSrcBytes) {
|
||||
static void reshape(void* dest, const void* src, size_t numSrcBytes) {
|
||||
const componentType maxValue = getMaxValue<componentType>();
|
||||
const componentType* in = (const componentType*) src;
|
||||
componentType* out = (componentType*) dest;
|
||||
const size_t width = (numSrcBytes / sizeof(componentType)) / srcChannelCount;
|
||||
constexpr size_t minChannelCount = math::min(srcChannelCount, dstChannelCount);
|
||||
const int minChannelCount = filament::math::min(srcChannelCount, dstChannelCount);
|
||||
for (size_t column = 0; column < width; ++column) {
|
||||
for (size_t channel = 0; channel < minChannelCount; ++channel) {
|
||||
out[channel] = in[channel];
|
||||
@@ -59,28 +58,36 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Converts a n-channel image of UBYTE, INT, UINT, or FLOAT to a different type.
|
||||
// Converts a 4-channel image of UBYTE, INT, UINT, or FLOAT to a different type.
|
||||
template<typename dstComponentType, typename srcComponentType>
|
||||
static void reshapeImage(uint8_t* UTILS_RESTRICT dest, const uint8_t* UTILS_RESTRICT src,
|
||||
size_t srcBytesPerRow,
|
||||
size_t srcChannelCount, size_t dstBytesPerRow, size_t dstChannelCount,
|
||||
size_t width, size_t height, bool swizzle) {
|
||||
static void reshapeImage(uint8_t* dest, const uint8_t* src, size_t srcBytesPerRow,
|
||||
size_t dstBytesPerRow, size_t dstChannelCount, size_t height, bool swizzle, bool flip) {
|
||||
const size_t srcChannelCount = 4;
|
||||
const dstComponentType dstMaxValue = getMaxValue<dstComponentType>();
|
||||
const srcComponentType srcMaxValue = getMaxValue<srcComponentType>();
|
||||
const size_t minChannelCount = math::min(srcChannelCount, dstChannelCount);
|
||||
const size_t width = (srcBytesPerRow / sizeof(srcComponentType)) / srcChannelCount;
|
||||
const size_t minChannelCount = filament::math::min(srcChannelCount, dstChannelCount);
|
||||
assert_invariant(minChannelCount <= 4);
|
||||
UTILS_ASSUME(minChannelCount <= 4);
|
||||
const int inds[4] = { swizzle ? 2 : 0, 1, swizzle ? 0 : 2, 3 };
|
||||
const int inds[4] = {swizzle ? 2 : 0, 1, swizzle ? 0 : 2, 3};
|
||||
|
||||
int srcStride;
|
||||
if (flip) {
|
||||
src += srcBytesPerRow * (height - 1);
|
||||
srcStride = -srcBytesPerRow;
|
||||
} else {
|
||||
srcStride = srcBytesPerRow;
|
||||
}
|
||||
|
||||
for (size_t row = 0; row < height; ++row) {
|
||||
const srcComponentType* in = (const srcComponentType*)src;
|
||||
dstComponentType* out = (dstComponentType*)dest;
|
||||
const srcComponentType* in = (const srcComponentType*) src;
|
||||
dstComponentType* out = (dstComponentType*) dest;
|
||||
for (size_t column = 0; column < width; ++column) {
|
||||
for (size_t channel = 0; channel < minChannelCount; ++channel) {
|
||||
if constexpr (std::is_same_v<dstComponentType, srcComponentType>) {
|
||||
out[channel] = in[inds[channel]];
|
||||
} else {
|
||||
// FIXME: beware of overflows in the multiply
|
||||
// FIXME: probably not correct for _INTEGER src/dst
|
||||
// TODO: beware of overflows in the multiply
|
||||
// TODO: probably not correct for _INTEGER src/dst
|
||||
out[channel] = in[inds[channel]] * dstMaxValue / srcMaxValue;
|
||||
}
|
||||
}
|
||||
@@ -90,15 +97,15 @@ public:
|
||||
in += srcChannelCount;
|
||||
out += dstChannelCount;
|
||||
}
|
||||
src += srcBytesPerRow;
|
||||
src += srcStride;
|
||||
dest += dstBytesPerRow;
|
||||
}
|
||||
}
|
||||
|
||||
// Converts a n-channel image of UBYTE, INT, UINT, or FLOAT to a different type.
|
||||
static bool reshapeImage(PixelBufferDescriptor* UTILS_RESTRICT dst, PixelDataType srcType,
|
||||
uint32_t srcChannelCount, const uint8_t* UTILS_RESTRICT srcBytes, int srcBytesPerRow,
|
||||
int width, int height, bool swizzle) {
|
||||
// Converts a 4-channel image of UBYTE, INT, UINT, or FLOAT to a different type.
|
||||
static bool reshapeImage(PixelBufferDescriptor* dst, PixelDataType srcType,
|
||||
const uint8_t* srcBytes, int srcBytesPerRow, int width, int height, bool swizzle,
|
||||
bool flip) {
|
||||
size_t dstChannelCount;
|
||||
switch (dst->format) {
|
||||
case PixelDataFormat::R_INTEGER: dstChannelCount = 1; break;
|
||||
@@ -111,9 +118,8 @@ public:
|
||||
case PixelDataFormat::RGBA: dstChannelCount = 4; break;
|
||||
default: return false;
|
||||
}
|
||||
void (*reshaper)(uint8_t* dest, const uint8_t* src, size_t srcBytesPerRow,
|
||||
size_t srcChannelCount, size_t dstBytesPerRow, size_t dstChannelCount,
|
||||
size_t width, size_t height, bool swizzle) = nullptr;
|
||||
void (*reshaper)(uint8_t*, const uint8_t*, size_t, size_t, size_t, size_t, bool, bool)
|
||||
= nullptr;
|
||||
constexpr auto UBYTE = PixelDataType::UBYTE, FLOAT = PixelDataType::FLOAT,
|
||||
UINT = PixelDataType::UINT, INT = PixelDataType::INT;
|
||||
switch (dst->type) {
|
||||
@@ -159,10 +165,11 @@ public:
|
||||
uint8_t* dstBytes = (uint8_t*) dst->buffer;
|
||||
const int dstBytesPerRow = PixelBufferDescriptor::computeDataSize(dst->format, dst->type,
|
||||
dst->stride ? dst->stride : width, 1, dst->alignment);
|
||||
reshaper(dstBytes, srcBytes, srcBytesPerRow, srcChannelCount, dstBytesPerRow,
|
||||
dstChannelCount, width, height, swizzle);
|
||||
reshaper(dstBytes, srcBytes, srcBytesPerRow, dstBytesPerRow, dstChannelCount, height,
|
||||
swizzle, flip);
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<> inline float getMaxValue() { return 1.0f; }
|
||||
|
||||
@@ -104,7 +104,10 @@ struct HwProgram : public HwBase {
|
||||
};
|
||||
|
||||
struct HwSamplerGroup : public HwBase {
|
||||
// NOTE: we have to use out-of-line allocation here because the size of a Handle<> is limited
|
||||
std::unique_ptr<SamplerGroup> sb; // FIXME: this shouldn't depend on filament::SamplerGroup
|
||||
HwSamplerGroup() noexcept = default;
|
||||
explicit HwSamplerGroup(size_t size) noexcept : sb(new SamplerGroup(size)) { }
|
||||
};
|
||||
|
||||
struct HwTexture : public HwBase {
|
||||
|
||||
@@ -53,10 +53,6 @@
|
||||
#if defined (FILAMENT_DRIVER_SUPPORTS_VULKAN)
|
||||
#include "vulkan/PlatformVkLinuxX11.h"
|
||||
#endif
|
||||
#elif defined(FILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
#if defined(FILAMENT_SUPPORTS_OPENGL) && !defined(FILAMENT_USE_EXTERNAL_GLES3) && !defined(FILAMENT_USE_SWIFTSHADER)
|
||||
#include "opengl/platforms/PlatformEGLHeadless.h"
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(WIN32)
|
||||
#if defined(FILAMENT_SUPPORTS_OPENGL) && !defined(FILAMENT_USE_EXTERNAL_GLES3) && !defined(FILAMENT_USE_SWIFTSHADER)
|
||||
@@ -82,7 +78,6 @@ filament::backend::DefaultPlatform* createDefaultMetalPlatform();
|
||||
#include "noop/PlatformNoop.h"
|
||||
|
||||
namespace filament {
|
||||
|
||||
namespace backend {
|
||||
|
||||
// this generates the vtable in this translation unit
|
||||
@@ -162,8 +157,6 @@ DefaultPlatform* DefaultPlatform::create(Backend* backend) noexcept {
|
||||
#elif defined(__linux__)
|
||||
#if defined(FILAMENT_SUPPORTS_X11)
|
||||
return new PlatformGLX();
|
||||
#elif defined(FILAMENT_SUPPORTS_EGL_ON_LINUX)
|
||||
return new PlatformEGLHeadless();
|
||||
#endif
|
||||
#elif defined(WIN32)
|
||||
return new PlatformWGL();
|
||||
|
||||
@@ -40,8 +40,8 @@ Program& Program::shader(Program::Shader shader, void const* data, size_t size)
|
||||
return *this;
|
||||
}
|
||||
|
||||
Program& Program::setUniformBlock(size_t bindingPoint, std::string_view uniformBlockName) noexcept {
|
||||
mUniformBlocks[bindingPoint] = { uniformBlockName.data(), uniformBlockName.size() };
|
||||
Program& Program::setUniformBlock(size_t bindingPoint, utils::CString uniformBlockName) noexcept {
|
||||
mUniformBlocks[bindingPoint] = std::move(uniformBlockName);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,53 +16,64 @@
|
||||
|
||||
#include "private/backend/SamplerGroup.h"
|
||||
|
||||
#include "private/backend/DriverApi.h"
|
||||
|
||||
#include "backend/BufferDescriptor.h"
|
||||
|
||||
namespace filament::backend {
|
||||
namespace filament {
|
||||
namespace backend {
|
||||
|
||||
// create a sampler buffer
|
||||
SamplerGroup::SamplerGroup(size_t count) noexcept
|
||||
: mBuffer(count) {
|
||||
}
|
||||
|
||||
SamplerGroup::SamplerGroup(const SamplerGroup& rhs) noexcept :
|
||||
mBuffer(rhs.mBuffer), mDirty(true) {
|
||||
SamplerGroup::SamplerGroup(const SamplerGroup& rhs) noexcept = default;
|
||||
|
||||
SamplerGroup::SamplerGroup(SamplerGroup&& rhs) noexcept
|
||||
: mBuffer(rhs.mBuffer), mDirty(rhs.mDirty) {
|
||||
rhs.clean();
|
||||
}
|
||||
|
||||
SamplerGroup& SamplerGroup::operator=(const SamplerGroup& rhs) noexcept {
|
||||
SamplerGroup& SamplerGroup::operator=(const SamplerGroup& rhs) noexcept = default;
|
||||
|
||||
SamplerGroup& SamplerGroup::operator=(SamplerGroup&& rhs) noexcept {
|
||||
if (this != &rhs) {
|
||||
mBuffer = rhs.mBuffer;
|
||||
mDirty = true;
|
||||
mDirty = rhs.mDirty;
|
||||
rhs.clean();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SamplerGroup::setSampler(size_t index, SamplerDescriptor sampler) noexcept {
|
||||
if (UTILS_LIKELY(index < mBuffer.size())) {
|
||||
// We cannot compare two texture handles to determine if an update is needed. Texture
|
||||
// handles are (quickly) recycled and therefore can't be used for that purpose. e.g. if a
|
||||
// texture is destroyed, its handle could be reused quickly by another texture.
|
||||
// TODO: find a way to avoid marking dirty if the texture does not change.
|
||||
mBuffer[index] = sampler;
|
||||
mDirty = true;
|
||||
}
|
||||
SamplerGroup& SamplerGroup::toCommandStream() const noexcept {
|
||||
/*
|
||||
* This works because our move ctor preserves the data and cleans the dirty flags.
|
||||
* if we changed the implementation in the future to do a real move, we'd have to change
|
||||
* this method to return SamplerGroup by value, e.g.:
|
||||
* SamplerGroup copy(*this);
|
||||
* this->clean();
|
||||
* return copy;
|
||||
*/
|
||||
return const_cast<SamplerGroup&>(*this);
|
||||
}
|
||||
|
||||
BufferDescriptor SamplerGroup::toBufferDescriptor(DriverApi& driver) const noexcept {
|
||||
BufferDescriptor p;
|
||||
p.size = mBuffer.size() * sizeof(SamplerDescriptor);
|
||||
p.buffer = driver.allocate(p.size); // TODO: use out-of-line buffer if too large
|
||||
memcpy(p.buffer, static_cast<const void*>(mBuffer.data()), p.size); // inlined
|
||||
clean();
|
||||
return p;
|
||||
SamplerGroup& SamplerGroup::setSamplers(SamplerGroup const& rhs) noexcept {
|
||||
if (this != &rhs) {
|
||||
mBuffer = rhs.mBuffer;
|
||||
mDirty.setValue((1u << rhs.mBuffer.size()) - 1u);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SamplerGroup::setSampler(size_t index, Sampler sampler) noexcept {
|
||||
if (UTILS_LIKELY(index < mBuffer.size())) {
|
||||
mBuffer[index] = sampler;
|
||||
mDirty.set(index);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const SamplerGroup& rhs) {
|
||||
return out << "SamplerGroup(size=" << rhs.getSize() << ")";
|
||||
return out << "SamplerGroup(data=" << rhs.getSamplers() << ", size=" << rhs.getSize() << ")";
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace filament::backend
|
||||
} // namespace backend
|
||||
} // namespace filament
|
||||
|
||||
@@ -365,7 +365,7 @@ void MetalBlitter::blitDepthPlane(id<MTLCommandBuffer> cmdBuffer, bool blitColor
|
||||
[encoder setViewport:viewport];
|
||||
|
||||
DepthStencilState depthStencilState {
|
||||
.depthCompare = MTLCompareFunctionAlways,
|
||||
.compareFunction = MTLCompareFunctionAlways,
|
||||
.depthWriteEnabled = blitDepth
|
||||
};
|
||||
id<MTLDepthStencilState> depthStencil =
|
||||
|
||||
@@ -42,8 +42,7 @@ public:
|
||||
* Update the buffer with data inside src. Potentially allocates a new buffer allocation to hold
|
||||
* the bytes which will be released when the current frame is finished.
|
||||
*/
|
||||
void copyIntoBuffer(void* src, size_t size, size_t byteOffset);
|
||||
void copyIntoBufferUnsynchronized(void* src, size_t size, size_t byteOffset);
|
||||
void copyIntoBuffer(void* src, size_t size, size_t byteOffset = 0);
|
||||
|
||||
/**
|
||||
* Denotes that this buffer is used for a draw call ensuring that its allocation remains valid
|
||||
@@ -52,9 +51,18 @@ public:
|
||||
* @return The MTLBuffer representing the current state of the buffer to bind, or nil if there
|
||||
* is no device allocation.
|
||||
*
|
||||
* For STREAM buffers, getGpuBufferStreamOffset() should be called to retrieve the correct
|
||||
* buffer offset.
|
||||
*
|
||||
*/
|
||||
id<MTLBuffer> getGpuBufferForDraw(id<MTLCommandBuffer> cmdBuffer) noexcept;
|
||||
|
||||
/**
|
||||
* Returns the offset into the buffer returned by getGpuBufferForDraw. This is always 0 for
|
||||
* non-STREAM buffers.
|
||||
*/
|
||||
size_t getGpuBufferStreamOffset() noexcept { return mCurrentStreamStart; }
|
||||
|
||||
void* getCpuBuffer() const noexcept { return mCpuBuffer; }
|
||||
|
||||
enum Stage {
|
||||
@@ -74,10 +82,15 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
id<MTLBuffer> mBuffer = nil;
|
||||
BufferUsage mUsage;
|
||||
size_t mBufferSize = 0;
|
||||
size_t mCurrentStreamStart = 0;
|
||||
size_t mCurrentStreamEnd = 0;
|
||||
const MetalBufferPoolEntry* mBufferPoolEntry = nullptr;
|
||||
void* mCpuBuffer = nullptr;
|
||||
MetalContext& mContext;
|
||||
|
||||
void copyIntoStreamBuffer(void* src, size_t size);
|
||||
};
|
||||
|
||||
} // namespace backend
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user