Skip to content

Commit

Permalink
Merge branch 'rc/1.56.4' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
poweifeng committed Dec 18, 2024
2 parents 8ef8b34 + aaac6e7 commit 4695e93
Show file tree
Hide file tree
Showing 39 changed files with 140 additions and 49 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.56.3'
implementation 'com.google.android.filament:filament-android:1.56.4'
}
```

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.56.3'
pod 'Filament', '~> 1.56.4'
```

## Documentation
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.56.4


## v1.56.3


Expand Down
2 changes: 1 addition & 1 deletion android/filament-android/src/main/cpp/EntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Java_com_google_android_filament_EntityManager_nCreateArray(JNIEnv* env, jclass,
// (which it is), but still.
em->create((size_t) n, reinterpret_cast<Entity *>(entities));

env->ReleaseIntArrayElements(entities_, entities, JNI_ABORT);
env->ReleaseIntArrayElements(entities_, entities, 0);
}

extern "C" JNIEXPORT jint JNICALL
Expand Down
4 changes: 2 additions & 2 deletions android/filament-android/src/main/cpp/IndirectLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Java_com_google_android_filament_IndirectLight_nGetDirectionEstimateStatic(JNIEn
jfloat *outDirection = env->GetFloatArrayElements(outDirection_, NULL);
*reinterpret_cast<filament::math::float3*>(outDirection) = IndirectLight::getDirectionEstimate((filament::math::float3*)sh);
env->ReleaseFloatArrayElements(outDirection_, outDirection, 0);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
env->ReleaseFloatArrayElements(sh_, sh, 0);
}

extern "C" JNIEXPORT void JNICALL
Expand All @@ -178,5 +178,5 @@ Java_com_google_android_filament_IndirectLight_nGetColorEstimateStatic(JNIEnv *e
*reinterpret_cast<filament::math::float4*>(outColor) =
IndirectLight::getColorEstimate((filament::math::float3*)sh, math::float3{x, y, z});
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
env->ReleaseFloatArrayElements(sh_, sh, 0);
}
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.56.3
VERSION_NAME=1.56.4

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

Expand Down
13 changes: 11 additions & 2 deletions docs/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,12 @@
declare a variable called <code>eyeDirection</code> you can access it in the fragment shader using
<code>variable_eyeDirection</code>. In the vertex shader, the interpolant name is simply a member of
the <code>MaterialVertexInputs</code> structure (<code>material.eyeDirection</code> in your example). Each
interpolant is of type <code>float4</code> (<code>vec4</code>) in the shaders.
interpolant is of type <code>float4</code> (<code>vec4</code>) in the shaders. By default the precision of the
interpolant is <code>highp</code> in <em class="asterisk">both</em> the vertex and fragment shaders.
An alternate syntax can be used to specify both the name and precision of the interpolant.
In this case the specified precision is used as-is in both fragment and vertex stages, in
particular if <code>default</code> is specified the default precision is used is the fragment shader
(<code>mediump</code>) and in the vertex shader (<code>highp</code>).

</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
<span class="line"> name : Skybox,</span>
Expand All @@ -1798,7 +1803,11 @@
<span class="line"> }</span>
<span class="line"> ],</span>
<span class="line"> variables : [</span>
<span class="line"> eyeDirection</span>
<span class="line"> eyeDirection,</span>
<span class="line"> {</span>
<span class="line"> name : eyeColor,</span>
<span class="line"> precision : medium</span>
<span class="line"> }</span>
<span class="line"> ],</span>
<span class="line"> vertexDomain : device,</span>
<span class="line"> depthWrite : <span class="hljs-literal">false</span>,</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/remote/filament.js

Large diffs are not rendered by default.

Binary file modified docs/remote/filament.wasm
Binary file not shown.
Binary file modified docs/webgl/albedo.ktx2
Binary file not shown.
Binary file modified docs/webgl/ao.ktx2
Binary file not shown.
Binary file modified docs/webgl/default_env/default_env_ibl.ktx
Binary file not shown.
Binary file modified docs/webgl/default_env/default_env_skybox.ktx
Binary file not shown.
Binary file modified docs/webgl/default_env/default_env_skybox_tiny.ktx
Binary file not shown.
12 changes: 9 additions & 3 deletions 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/metallic.ktx2
Binary file not shown.
Binary file modified docs/webgl/normal.ktx2
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.
Binary file modified docs/webgl/roughness.ktx2
Binary file not shown.
Binary file modified docs/webgl/suzanne.filamesh
Binary file not shown.
Binary file modified docs/webgl/textured.filamat
Binary file not shown.
Binary file modified docs/webgl/triangle.filamat
Binary file not shown.
1 change: 1 addition & 0 deletions filament/backend/src/metal/MetalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct MetalContext {
bool supportsTextureSwizzling = false;
bool supportsAutoDepthResolve = false;
bool supportsMemorylessRenderTargets = false;
bool supportsDepthClamp = false;
uint8_t maxColorRenderTargets = 4;
struct {
uint8_t common;
Expand Down
18 changes: 13 additions & 5 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
mContext->highestSupportedGpuFamily.mac >= 2; // newer macOS GPUs
}

mContext->supportsDepthClamp = false;
if (@available(macOS 10.11, iOS 11.0, *)) {
mContext->supportsDepthClamp = true;
}

// In order to support resolve store action on depth attachment, the GPU needs to support it.
// Note that support for depth resolve implies support for stencil resolve using .sample0 resolve filter.
// (Other resolve filters are supported starting .apple5 and .mac2 families).
Expand Down Expand Up @@ -1063,7 +1068,7 @@
}

bool MetalDriver::isDepthClampSupported() {
return true;
return mContext->supportsDepthClamp;
}

bool MetalDriver::isWorkaroundNeeded(Workaround workaround) {
Expand Down Expand Up @@ -1258,6 +1263,7 @@
mContext->cullModeState.invalidate();
mContext->windingState.invalidate();
mContext->scissorRectState.invalidate();
mContext->depthClampState.invalidate();
mContext->currentPolygonOffset = {0.0f, 0.0f};

mContext->finalizedDescriptorSets.clear();
Expand Down Expand Up @@ -1729,10 +1735,12 @@
}

// depth clip mode
MTLDepthClipMode depthClipMode = rs.depthClamp ? MTLDepthClipModeClamp : MTLDepthClipModeClip;
mContext->depthClampState.updateState(depthClipMode);
if (mContext->depthClampState.stateChanged()) {
[mContext->currentRenderPassEncoder setDepthClipMode:depthClipMode];
if (mContext->supportsDepthClamp) {
MTLDepthClipMode depthClipMode = rs.depthClamp ? MTLDepthClipModeClamp : MTLDepthClipModeClip;
mContext->depthClampState.updateState(depthClipMode);
if (mContext->depthClampState.stateChanged()) {
[mContext->currentRenderPassEncoder setDepthClipMode:depthClipMode];
}
}

// Set the depth-stencil state, if a state change is needed.
Expand Down
8 changes: 5 additions & 3 deletions filament/backend/src/metal/MetalShaderCompiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ bool isReady() const noexcept {
CompilerPriorityQueue const priorityQueue = program.getPriorityQueue();
mCompilerThreadPool.queue(priorityQueue, token,
[this, name, device = mDevice, program = std::move(program), token]() {
MetalFunctionBundle compiledProgram = compileProgram(program, device);
token->set(compiledProgram);
mCallbackManager.put(token->handle);
@autoreleasepool {
MetalFunctionBundle compiledProgram = compileProgram(program, device);
token->set(compiledProgram);
mCallbackManager.put(token->handle);
}
});

break;
Expand Down
2 changes: 2 additions & 0 deletions filament/backend/src/opengl/OpenGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,13 @@ void OpenGLContext::initBugs(Bugs* bugs, Extensions const& exts,
// qualcomm seems to have no problem with this (which is good for us)
bugs->allow_read_only_ancillary_feedback_loop = true;

#ifndef __EMSCRIPTEN__
// Older Adreno devices that support ES3.0 only tend to be extremely buggy, so we
// fall back to ES2.0.
if (major == 3 && minor == 0) {
bugs->force_feature_level0 = true;
}
#endif
} else if (strstr(renderer, "Mali")) {
// ARM GPU
bugs->vao_doesnt_store_element_array_buffer_binding = true;
Expand Down
14 changes: 10 additions & 4 deletions filament/backend/src/opengl/platforms/PlatformOSMesa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ struct OSMesaAPI {
break;
}
}
FILAMENT_CHECK_PRECONDITION(mLib)
<< "Unable to dlopen libOSMesa to create a software GL context";
if (mLib) {
OSMesaGetProcAddress = (GetProcAddressFunc) dlsym(mLib, "OSMesaGetProcAddress");
} else {
OSMesaGetProcAddress = (GetProcAddressFunc) dlsym(RTLD_LOCAL, "OSMesaGetProcAddress");
}

OSMesaGetProcAddress = (GetProcAddressFunc) dlsym(mLib, "OSMesaGetProcAddress");
FILAMENT_CHECK_PRECONDITION(OSMesaGetProcAddress)
<< "Unable to against libOSMesa to create a software GL context";

OSMesaCreateContext = (CreateContextFunc) OSMesaGetProcAddress("OSMesaCreateContext");
OSMesaDestroyContext =
Expand All @@ -76,7 +80,9 @@ struct OSMesaAPI {
}

~OSMesaAPI() {
dlclose(mLib);
if (mLib) {
dlclose(mLib);
}
}
private:
void* mLib = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion filament/include/filament/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace filament {
* filament::Camera* myCamera = engine->createCamera(myCameraEntity);
* myCamera->setProjection(45, 16.0/9.0, 0.1, 1.0);
* myCamera->lookAt({0, 1.60, 1}, {0, 0, 0});
* engine->destroyCameraComponent(myCamera);
* engine->destroyCameraComponent(myCameraEntity);
* ~~~~~~~~~~~
*
*
Expand Down
53 changes: 38 additions & 15 deletions filament/src/RenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,21 +864,44 @@ backend::Viewport RenderPass::Executor::applyScissorViewport(
backend::Viewport const& scissorViewport, backend::Viewport const& scissor) noexcept {
// scissor is set, we need to apply the offset/clip
// clang vectorizes this!
constexpr int32_t maxvali = std::numeric_limits<int32_t>::max();
// compute new left/bottom, assume no overflow
int32_t const l = scissor.left + scissorViewport.left;
int32_t const b = scissor.bottom + scissorViewport.bottom;
// compute right/top without overflowing, scissor.width/height guaranteed
// to convert to int32
int32_t r = (l > maxvali - int32_t(scissor.width)) ? maxvali : l + int32_t(scissor.width);
int32_t t = (b > maxvali - int32_t(scissor.height)) ? maxvali : b + int32_t(scissor.height);
// clip to the viewport
assert_invariant(l == std::max(l, scissorViewport.left));
assert_invariant(b == std::max(b, scissorViewport.bottom));
r = std::min(r, scissorViewport.left + int32_t(scissorViewport.width));
t = std::min(t, scissorViewport.bottom + int32_t(scissorViewport.height));
assert_invariant(r >= l && t >= b);
return { l, b, uint32_t(r - l), uint32_t(t - b) };
constexpr int64_t maxvali = std::numeric_limits<int32_t>::max();

// we do all the offsetting/clipping math in 64 bits below to avoid overflows
struct {
int64_t l;
int64_t b;
int64_t r;
int64_t t;
} svp, s;

// convert scissorViewport to {left,bottom,right,top} format
svp.l = scissorViewport.left;
svp.b = scissorViewport.bottom;
svp.r = svp.l + scissorViewport.width;
svp.t = svp.b + scissorViewport.height;

// convert scissor to {left,bottom,right,top} format and offset by scissorViewport's left,bottom
s.l = svp.l + scissor.left;
s.b = svp.b + scissor.bottom;
s.r = s.l + scissor.width;
s.t = s.b + scissor.height;

// clip to the scissorViewport
s.l = std::max(s.l, svp.l);
s.b = std::max(s.b, svp.b);
s.r = std::min(s.r, svp.r);
s.t = std::min(s.t, svp.t);

// clip to positive int32_t
s.l = std::max(s.l, int64_t(0));
s.b = std::max(s.b, int64_t(0));
s.r = std::min(s.r, maxvali);
s.t = std::min(s.t, maxvali);

assert_invariant(s.r >= s.l && s.t >= s.b);

// convert back to Viewport format
return { int32_t(s.l), int32_t(s.b), uint32_t(s.r - s.l), uint32_t(s.t - s.b) };
}

UTILS_NOINLINE // no need to be inlined
Expand Down
7 changes: 6 additions & 1 deletion filament/src/details/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,13 @@ bool FEngine::destroy(const FMaterial* ptr) {
if (!ASSERT_PRECONDITION_NON_FATAL(pos->second.empty(),
"destroying material \"%s\" but %u instances still alive",
ptr->getName().c_str(), (*pos).second.size())) {
return false;
// We return true here, because the material has been destroyed. However, this
// leaks this material's ResourceList<FMaterialInstance> until the engine
// is shut down. Note that it's still possible for the MaterialInstances to be
// destroyed manually.
return true;
}
mMaterialInstances.erase(pos);
}
}
return success;
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,11 @@ void FRenderer::renderJob(RootArenaScope& rootArenaScope, FView& view) {
uint32_t(float(xvp.width ) * aoOptions.resolution),
uint32_t(float(xvp.height) * aoOptions.resolution)});

// this needs to reset the sampler that are only set in RendererUtils::colorPass(), because
// this descriptor-set is also used for ssr/picking/structure and these could be stale
// it would be better to use a separate desriptor-set for those two cases so that we don't
// have to do this
view.unbindSamplers(driver);
view.commitUniformsAndSamplers(driver);
});

Expand Down
4 changes: 4 additions & 0 deletions filament/src/details/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ void FView::commitUniformsAndSamplers(DriverApi& driver) const noexcept {
mColorPassDescriptorSet.commit(driver);
}

void FView::unbindSamplers(DriverApi& driver) noexcept {
mColorPassDescriptorSet.unbindSamplers(driver);
}

void FView::commitFroxels(DriverApi& driverApi) const noexcept {
if (mHasDynamicLighting) {
mFroxelizer.commit(driverApi);
Expand Down
1 change: 1 addition & 0 deletions filament/src/details/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class FView : public View {

void commitFroxels(backend::DriverApi& driverApi) const noexcept;
void commitUniformsAndSamplers(backend::DriverApi& driver) const noexcept;
void unbindSamplers(backend::DriverApi& driver) noexcept;

utils::JobSystem::Job* getFroxelizerSync() const noexcept { return mFroxelizerSync; }
void setFroxelizerSync(utils::JobSystem::Job* sync) noexcept { mFroxelizerSync = sync; }
Expand Down
11 changes: 11 additions & 0 deletions filament/src/ds/ColorPassDescriptorSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@ void ColorPassDescriptorSet::commit(backend::DriverApi& driver) noexcept {
}
}

void ColorPassDescriptorSet::unbindSamplers(DriverApi&) noexcept {
// this needs to reset the sampler that are only set in RendererUtils::colorPass(), because
// this descriptor-set is also used for ssr/picking/structure and these could be stale
// it would be better to use a separate descriptor-set for those two cases so that we don't
// have to do this
setSampler(+PerViewBindingPoints::STRUCTURE, {}, {});
setSampler(+PerViewBindingPoints::SHADOW_MAP, {}, {});
setSampler(+PerViewBindingPoints::SSAO, {}, {});
setSampler(+PerViewBindingPoints::SSR, {}, {});
}

void ColorPassDescriptorSet::setSampler(backend::descriptor_binding_t binding,
TextureHandle th, SamplerParams params) noexcept {
for (size_t i = 0; i < DESCRIPTOR_LAYOUT_COUNT; i++) {
Expand Down
2 changes: 2 additions & 0 deletions filament/src/ds/ColorPassDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class ColorPassDescriptorSet {
// update local data into GPU UBO
void commit(backend::DriverApi& driver) noexcept;

void unbindSamplers(backend::DriverApi& driver) noexcept;

// bind this UBO
void bind(backend::DriverApi& driver, uint8_t index) const noexcept {
mDescriptorSet[index].bind(driver, DescriptorSetBindingPoints::PER_VIEW);
Expand Down
4 changes: 2 additions & 2 deletions ios/CocoaPods/Filament.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |spec|
spec.name = "Filament"
spec.version = "1.56.3"
spec.version = "1.56.4"
spec.license = { :type => "Apache 2.0", :file => "LICENSE" }
spec.homepage = "https://google.github.io/filament"
spec.authors = "Google LLC."
spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL."
spec.platform = :ios, "11.0"
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.56.3/filament-v1.56.3-ios.tgz" }
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.56.4/filament-v1.56.4-ios.tgz" }

# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
spec.pod_target_xcconfig = {
Expand Down
13 changes: 8 additions & 5 deletions libs/bluegl/src/BlueGLLinuxOSMesa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ bool initBinder() {
}
}
if (!g_driver.library) {
return false;
// The library has been linked explicitly during compile.
g_driver.OSMesaGetProcAddress = (ProcAddressFunc) dlsym(RTLD_LOCAL, "OSMesaGetProcAddress");
} else {
g_driver.OSMesaGetProcAddress =
(ProcAddressFunc) dlsym(g_driver.library, "OSMesaGetProcAddress");
}

g_driver.OSMesaGetProcAddress = (ProcAddressFunc)
dlsym(g_driver.library, "OSMesaGetProcAddress");

return g_driver.OSMesaGetProcAddress;
}

Expand All @@ -52,7 +53,9 @@ void* loadFunction(const char* name) {
}

void shutdownBinder() {
dlclose(g_driver.library);
if (g_driver.library) {
dlclose(g_driver.library);
}
memset(&g_driver, 0, sizeof(g_driver));
}

Expand Down
2 changes: 1 addition & 1 deletion web/filament-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filament",
"version": "1.56.3",
"version": "1.56.4",
"description": "Real-time physically based rendering engine",
"main": "filament.js",
"module": "filament.js",
Expand Down

0 comments on commit 4695e93

Please sign in to comment.