Skip to content

Commit

Permalink
Merge branch 'rc/1.49.2' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Jan 2, 2024
2 parents 918ce93 + 57f6e53 commit acfe929
Show file tree
Hide file tree
Showing 60 changed files with 850 additions and 294 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.49.1'
implementation 'com.google.android.filament:filament-android:1.49.2'
}
```

Expand All @@ -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:

```shell
pod 'Filament', '~> 1.49.1'
pod 'Filament', '~> 1.49.2'
```

### Snapshots
Expand Down
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ A new header is inserted each time a *tag* is created.
Instead, if you are authoring a PR for the main branch, add your release note to
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).

## v1.49.2


## v1.49.1


Expand Down
16 changes: 8 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ buildscript {
ext.versions = [
'jdk': 17,
'minSdk': 19,
'targetSdk': 33,
'compileSdk': 33,
'kotlin': '1.9.0',
'kotlin_coroutines': '1.7.2',
'targetSdk': 34,
'compileSdk': 34,
'kotlin': '1.9.21',
'kotlin_coroutines': '1.7.3',
'buildTools': '34.0.0',
'ndk': '25.1.8937393',
'androidx_core': '1.10.1',
'androidx_annotations': '1.6.0'
'ndk': '26.1.10909125',
'androidx_core': '1.12.0',
'androidx_annotations': '1.7.0'
]

ext.deps = [
Expand All @@ -104,7 +104,7 @@ buildscript {
]

dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1876,11 +1876,44 @@ public static class MultiSampleAntiAliasingOptions {

/**
* Options for Temporal Anti-aliasing (TAA)
* Most TAA parameters are extremely costly to change, as they will trigger the TAA post-process
* shaders to be recompiled. These options should be changed or set during initialization.
* `filterWidth` and `feedback`, however, could be changed an any time.
* @see setTemporalAntiAliasingOptions()
*/
public static class TemporalAntiAliasingOptions {
public enum BoxType {
/**
* use an AABB neighborhood
*/
AABB,
/**
* use the variance of the neighborhood
*/
VARIANCE,
/**
* use both AABB and variance
*/
AABB_VARIANCE,
}

public enum BoxClipping {
/**
* Accurate box clipping
*/
ACCURATE,
/**
* clamping
*/
CLAMP,
/**
* no rejections (use for debugging)
*/
NONE,
}

/**
* reconstruction filter width typically between 0 (sharper, aliased) and 1 (smoother)
* reconstruction filter width typically between 0.2 (sharper, aliased) and 1 (smoother)
*/
public float filterWidth = 1.0f;
/**
Expand All @@ -1891,6 +1924,36 @@ public static class TemporalAntiAliasingOptions {
* enables or disables temporal anti-aliasing
*/
public boolean enabled = false;
/**
* whether to filter the history buffer
*/
public boolean filterHistory = true;
/**
* whether to apply the reconstruction filter to the input
*/
public boolean filterInput = true;
/**
* whether to use the YcoCg color-space for history rejection
*/
public boolean useYCoCg = false;
/**
* type of color gamut box
*/
@NonNull
public TemporalAntiAliasingOptions.BoxType boxType = TemporalAntiAliasingOptions.BoxType.VARIANCE;
/**
* clipping algorithm
*/
@NonNull
public TemporalAntiAliasingOptions.BoxClipping boxClipping = TemporalAntiAliasingOptions.BoxClipping.ACCURATE;
/**
* adjust the feedback dynamically to reduce flickering
*/
public boolean preventFlickering = false;
/**
* whether to apply history reprojection (debug option)
*/
public boolean historyReprojection = true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public void resize(int width, int height) {
@Override
public void detach() {
mTextureView.setSurfaceTextureListener(null);
setSurface(null);
}


Expand Down Expand Up @@ -382,6 +381,7 @@ public void onSurfaceTextureSizeChanged(
@Override
public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) {
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureDestroyed()");
setSurface(null);
destroySwapChain();
return true;
}
Expand Down Expand Up @@ -445,6 +445,9 @@ public RendererCallback getRenderCallback() {
* {@link #attachTo(TextureView)}, or {@link #attachTo(SurfaceHolder)}.
*/
public void detach() {
if (mRenderSurface != null) {
mRenderSurface.detach();
}
destroySwapChain();
mNativeWindow = null;
mRenderSurface = null;
Expand Down Expand Up @@ -590,6 +593,10 @@ private boolean attach(@NonNull Object nativeWindow) {
// nothing to do
return false;
}
if (mRenderSurface != null) {
mRenderSurface.detach();
mRenderSurface = null;
}
destroySwapChain();
}
mNativeWindow = nativeWindow;
Expand All @@ -604,9 +611,6 @@ private void createSwapChain(@NonNull Surface surface) {
}

private void destroySwapChain() {
if (mRenderSurface != null) {
mRenderSurface.detach();
}
if (mRenderCallback != null) {
mRenderCallback.onDetachedFromSurface();
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.google.android.filament
VERSION_NAME=1.49.1
VERSION_NAME=1.49.2

POM_DESCRIPTION=Real-time physically based rendering engine for Android.

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 18 additions & 7 deletions docs/remote/filament.js

Large diffs are not rendered by default.

Binary file modified docs/remote/filament.wasm
Binary file not shown.
15 changes: 14 additions & 1 deletion docs/webgl/filament.js

Large diffs are not rendered by default.

Binary file modified docs/webgl/filament.wasm
Binary file not shown.
Binary file modified docs/webgl/parquet.filamat
Binary file not shown.
Binary file modified docs/webgl/plastic.filamat
Binary file not shown.
3 changes: 3 additions & 0 deletions docs/webgl/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ <h2>class <a id='Engine' href='#Engine'>Engine</a></h2>
<li><em>overrides</em> Dictionary with one or more of the following properties: mapSize, shadowCascades, constantBias, normalBias, shadowFar, shadowNearHint, shadowFarHint, stable, polygonOffsetConstant, polygonOffsetSlope, \</li>
</ul>
</li>
<li><strong>engine.setStereoscopicOptions()</strong></li>
<li><strong>engine.setTemporalAntiAliasingOptions()</strong></li>
<li><strong>engine.setVignetteOptions()</strong></li>
</ul>
Expand Down Expand Up @@ -1462,6 +1463,8 @@ <h2>enum <a id='Texture$Usage' href='#Texture$Usage'>Texture$Usage</a></h2>
<li>STENCIL_ATTACHMENT</li>
<li>UPLOADABLE</li>
<li>SAMPLEABLE</li>
<li>BLIT_SRC</li>
<li>BLIT_DST</li>
<li>SUBPASS_INPUT</li>
</ul>
</div>
Expand Down
Binary file modified docs/webgl/textured.filamat
Binary file not shown.
Binary file modified docs/webgl/triangle.filamat
Binary file not shown.
4 changes: 2 additions & 2 deletions filament/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ foreach (mat_src ${MATERIAL_SRCS})
list(APPEND MATERIAL_BINS ${output_path})
endforeach()

if (FILAMENT_ENABLE_FEATURE_LEVEL_0 AND FILAMENT_SUPPORTS_OPENGL)
if (FILAMENT_ENABLE_FEATURE_LEVEL_0)
foreach (mat_src ${MATERIAL_FL0_SRCS})
get_filename_component(localname "${mat_src}" NAME_WE)
get_filename_component(fullname "${mat_src}" ABSOLUTE)
set(output_path "${MATERIAL_DIR}/${localname}.filamat")

add_custom_command(
OUTPUT ${output_path}
COMMAND matc -a opengl -p ${MATC_TARGET} ${MATC_OPT_FLAGS} -o ${output_path} ${fullname}
COMMAND matc ${MATC_BASE_FLAGS} -o ${output_path} ${fullname}
MAIN_DEPENDENCY ${fullname}
DEPENDS matc
COMMENT "Compiling material ${mat_src} to ${output_path}"
Expand Down
13 changes: 12 additions & 1 deletion filament/backend/src/metal/MetalDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <utils/Log.h>
#include <utils/debug.h>

#include <functional>
#include <mutex>
#include <vector>

namespace filament {
namespace backend {

Expand All @@ -52,20 +56,27 @@ class MetalDriver final : public DriverBase {

public:
static Driver* create(MetalPlatform* platform, const Platform::DriverConfig& driverConfig);
void runAtNextTick(const std::function<void()>& fn) noexcept;

private:

friend class MetalSwapChain;

MetalPlatform& mPlatform;

MetalContext* mContext;

ShaderModel getShaderModel() const noexcept final;

// Overrides the default implementation by wrapping the call to fn in an @autoreleasepool block.
void execute(std::function<void(void)> const& fn) noexcept final;

/*
* Tasks run regularly on the driver thread.
*/
void executeTickOps() noexcept;
std::vector<std::function<void()>> mTickOps;
std::mutex mTickOpsLock;

/*
* Driver interface
*/
Expand Down
18 changes: 18 additions & 0 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
}

void MetalDriver::tick(int) {
executeTickOps();
}

void MetalDriver::beginFrame(int64_t monotonic_clock_ns, uint32_t frameId) {
Expand Down Expand Up @@ -583,6 +584,8 @@
// This must be done before calling bufferPool->reset() to ensure no buffers are in flight.
finish();

executeTickOps();

mContext->bufferPool->reset();
mContext->commandQueue = nil;

Expand Down Expand Up @@ -1904,6 +1907,21 @@
void MetalDriver::resetState(int) {
}

void MetalDriver::runAtNextTick(const std::function<void()>& fn) noexcept {
std::lock_guard<std::mutex> const lock(mTickOpsLock);
mTickOps.push_back(fn);
}

void MetalDriver::executeTickOps() noexcept {
std::vector<std::function<void()>> ops;
mTickOpsLock.lock();
std::swap(ops, mTickOps);
mTickOpsLock.unlock();
for (const auto& f : ops) {
f();
}
}

// explicit instantiation of the Dispatcher
template class ConcreteDispatcher<MetalDriver>;

Expand Down
33 changes: 26 additions & 7 deletions filament/backend/src/metal/MetalHandles.mm
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,30 @@ static inline MTLTextureUsage getMetalTextureUsage(TextureUsage usage) {
}
}

struct PresentDrawableData {
void* drawable = nullptr;
MetalDriver* driver = nullptr;
};

void presentDrawable(bool presentFrame, void* user) {
// CFBridgingRelease here is used to balance the CFBridgingRetain inside of acquireDrawable.
id<CAMetalDrawable> drawable = (id<CAMetalDrawable>) CFBridgingRelease(user);
auto* presentDrawableData = static_cast<PresentDrawableData*>(user);

// CFBridgingRelease here is used to balance the CFBridgingRetain inside acquireDrawable.
id<CAMetalDrawable> drawable =
(id<CAMetalDrawable>)CFBridgingRelease(presentDrawableData->drawable);
if (presentFrame) {
[drawable present];
}
// The drawable will be released here when the "drawable" variable goes out of scope.

// Schedule the drawable destruction on the driver thread.
void* voidDrawable = (void*) CFBridgingRetain(drawable);
MetalDriver* driver = presentDrawableData->driver;
driver->runAtNextTick([voidDrawable]() {
// The drawable is released here.
CFBridgingRelease(voidDrawable);
});

delete presentDrawableData;
}

void MetalSwapChain::scheduleFrameScheduledCallback() {
Expand All @@ -266,13 +283,15 @@ void presentDrawable(bool presentFrame, void* user) {
// capture the _this_ pointer (MetalSwapChain*) instead of the drawable.
id<CAMetalDrawable> d = drawable;
void* userData = frameScheduledUserData;
MetalDriver* driver = context.driver;
[getPendingCommandBuffer(&context) addScheduledHandler:^(id<MTLCommandBuffer> cb) {
// CFBridgingRetain is used here to give the drawable a +1 retain count before
// casting it to a void*.
PresentCallable callable(presentDrawable, (void*) CFBridgingRetain(d));
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
callback(callable, userData);
});
auto* presentDrawableData = new PresentDrawableData;
presentDrawableData->drawable = (void*) CFBridgingRetain(d);
presentDrawableData->driver = driver;
PresentCallable callable(presentDrawable, (void*) presentDrawableData);
callback(callable, userData);
}];
}

Expand Down
3 changes: 2 additions & 1 deletion filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void OpenGLDriver::createProgramR(Handle<HwProgram> ph, Program&& program) {


if (UTILS_UNLIKELY(mContext.isES2())) {
// Here we patch the specification constants to enable or not the rec709 output
// Here we patch the specialization constants to enable or not the rec709 output
// color space emulation in this program. Obviously, the backend shouldn't know about
// specific spec-constants, so we need to handle failures gracefully. This cannot be
// done at Material creation time because only the backend has access to
Expand Down Expand Up @@ -2283,6 +2283,7 @@ void OpenGLDriver::setTextureData(GLTexture* t, uint32_t level,
PixelBufferDescriptor&& p) {
auto& gl = mContext;

assert_invariant(t != nullptr);
assert_invariant(xoffset + width <= std::max(1u, t->width >> level));
assert_invariant(yoffset + height <= std::max(1u, t->height >> level));
assert_invariant(t->samples <= 1);
Expand Down
3 changes: 2 additions & 1 deletion filament/backend/src/opengl/ShaderCompilerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ void ShaderCompilerService::compileShaders(OpenGLContext& context,
// add support for ARB_shading_language_packing if needed
auto const packingFunctions = process_ARB_shading_language_packing(context);

// split shader source, so we can insert the specification constants and the packing functions
// split shader source, so we can insert the specialization constants and the packing
// functions
auto const [prolog, body] = splitShaderSource(source);

const std::array<const char*, 4> sources = {
Expand Down
Loading

0 comments on commit acfe929

Please sign in to comment.