diff --git a/README.md b/README.md index 9f4ffb12b23..66dfda78400 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.53.4' + implementation 'com.google.android.filament:filament-android:1.53.5' } ``` @@ -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.53.4' +pod 'Filament', '~> 1.53.5' ``` ### Snapshots diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 805b8f277c1..d8d83f372ff 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,11 @@ 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.53.5 + +- engine: Fix bug causing certain sampler parameters to not be applied correctly in GLES 2.0 and on + certain GLES 3.0 drivers. + ## v1.53.4 diff --git a/android/gradle.properties b/android/gradle.properties index 4b7e670a417..a9eb5d0046e 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.53.4 +VERSION_NAME=1.53.5 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/filament/backend/src/CommandBufferQueue.cpp b/filament/backend/src/CommandBufferQueue.cpp index e55bc104e05..39a81acffa6 100644 --- a/filament/backend/src/CommandBufferQueue.cpp +++ b/filament/backend/src/CommandBufferQueue.cpp @@ -101,9 +101,8 @@ void CommandBufferQueue::flush() noexcept { size_t const used = std::distance( static_cast(begin), static_cast(end)); + std::unique_lock lock(mLock); - mCommandBuffersToExecute.push_back({ begin, end }); - mCondition.notify_one(); // circular buffer is too small, we corrupted the stream FILAMENT_CHECK_POSTCONDITION(used <= mFreeSpace) << @@ -112,10 +111,12 @@ void CommandBufferQueue::flush() noexcept { "Space used at this time: " << used << " bytes, overflow: " << used - mFreeSpace << " bytes"; - // wait until there is enough space in the buffer mFreeSpace -= used; - if (UTILS_UNLIKELY(mFreeSpace < requiredSize)) { + mCommandBuffersToExecute.push_back({ begin, end }); + mCondition.notify_one(); + // wait until there is enough space in the buffer + if (UTILS_UNLIKELY(mFreeSpace < requiredSize)) { #ifndef NDEBUG size_t const totalUsed = circularBuffer.size() - mFreeSpace; @@ -153,8 +154,10 @@ std::vector CommandBufferQueue::waitForCommands() con } void CommandBufferQueue::releaseBuffer(CommandBufferQueue::Range const& buffer) { + size_t const used = std::distance( + static_cast(buffer.begin), static_cast(buffer.end)); std::lock_guard const lock(mLock); - mFreeSpace += uintptr_t(buffer.end) - uintptr_t(buffer.begin); + mFreeSpace += used; mCondition.notify_one(); } diff --git a/filament/backend/src/opengl/OpenGLDriver.cpp b/filament/backend/src/opengl/OpenGLDriver.cpp index 5b011ee6254..1aca903de1b 100644 --- a/filament/backend/src/opengl/OpenGLDriver.cpp +++ b/filament/backend/src/opengl/OpenGLDriver.cpp @@ -2341,6 +2341,15 @@ void OpenGLDriver::updateSamplerGroup(Handle sbh, GLTexture const* const t = handle_cast(th); assert_invariant(t); + if (UTILS_UNLIKELY(es2) +#if defined(GL_EXT_texture_filter_anisotropic) + || UTILS_UNLIKELY(anisotropyWorkaround) + #endif + ) { + // We must set texture parameters on the texture itself. + bindTexture(OpenGLContext::DUMMY_TEXTURE_BINDING, t); + } + SamplerParams params = pSamplers[i].s; if (UTILS_UNLIKELY(t->target == SamplerType::SAMPLER_EXTERNAL)) { // From OES_EGL_image_external spec: @@ -3881,6 +3890,7 @@ void OpenGLDriver::bindRenderPrimitive(Handle rph) { } void OpenGLDriver::draw2(uint32_t indexOffset, uint32_t indexCount, uint32_t instanceCount) { + DEBUG_MARKER() GLRenderPrimitive const* const rp = mBoundRenderPrimitive; if (UTILS_UNLIKELY(!rp || !mValidProgram)) { return; @@ -3902,6 +3912,7 @@ void OpenGLDriver::draw2(uint32_t indexOffset, uint32_t indexCount, uint32_t ins } void OpenGLDriver::draw2GLES2(uint32_t indexOffset, uint32_t indexCount, uint32_t instanceCount) { + DEBUG_MARKER() GLRenderPrimitive const* const rp = mBoundRenderPrimitive; if (UTILS_UNLIKELY(!rp || !mValidProgram)) { return; @@ -3922,6 +3933,7 @@ void OpenGLDriver::draw2GLES2(uint32_t indexOffset, uint32_t indexCount, uint32_ } void OpenGLDriver::scissor(Viewport scissor) { + DEBUG_MARKER() setScissor(scissor); } @@ -3941,6 +3953,7 @@ void OpenGLDriver::draw(PipelineState state, Handle rph, } void OpenGLDriver::dispatchCompute(Handle program, math::uint3 workGroupCount) { + DEBUG_MARKER() getShaderCompilerService().tick(); OpenGLProgram* const p = handle_cast(program); diff --git a/filament/src/Engine.cpp b/filament/src/Engine.cpp index 477a0871c84..3c21b8c2b6f 100644 --- a/filament/src/Engine.cpp +++ b/filament/src/Engine.cpp @@ -16,6 +16,8 @@ #include "details/Engine.h" +#include "ResourceAllocator.h" + #include "details/BufferObject.h" #include "details/Camera.h" #include "details/Fence.h" diff --git a/filament/src/Renderer.cpp b/filament/src/Renderer.cpp index 258fd5ed327..155a5877e83 100644 --- a/filament/src/Renderer.cpp +++ b/filament/src/Renderer.cpp @@ -16,9 +16,10 @@ #include -#include "details/Renderer.h" +#include "ResourceAllocator.h" #include "details/Engine.h" +#include "details/Renderer.h" #include "details/View.h" #include diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 49be1bc40a4..ad8c4c6add7 100644 --- a/ios/CocoaPods/Filament.podspec +++ b/ios/CocoaPods/Filament.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = "Filament" - spec.version = "1.53.4" + spec.version = "1.53.5" 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.53.4/filament-v1.53.4-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.53.5/filament-v1.53.5-ios.tgz" } # Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon. spec.pod_target_xcconfig = { diff --git a/libs/utils/include/utils/WorkStealingDequeue.h b/libs/utils/include/utils/WorkStealingDequeue.h index 9ac980b799d..d077e5a3b3f 100644 --- a/libs/utils/include/utils/WorkStealingDequeue.h +++ b/libs/utils/include/utils/WorkStealingDequeue.h @@ -93,9 +93,11 @@ void WorkStealingDequeue::push(TYPE item) noexcept { index_t bottom = mBottom.load(std::memory_order_relaxed); setItemAt(bottom, item); - // std::memory_order_release is used because we release the item we just pushed to other + // Here we need std::memory_order_release because we release, the item we just pushed, to other // threads which are calling steal(). - mBottom.store(bottom + 1, std::memory_order_release); + // However, generally seq_cst cannot be mixed with other memory orders. So we must use seq_cst. + // see: https://plv.mpi-sws.org/scfix/paper.pdf + mBottom.store(bottom + 1, std::memory_order_seq_cst); } /* @@ -155,9 +157,11 @@ TYPE WorkStealingDequeue::pop() noexcept { assert(top - bottom == 1); } - // std::memory_order_relaxed used because we're not publishing any data. + // Here, we only need std::memory_order_relaxed because we're not publishing any data. // No concurrent writes to mBottom possible, it's always safe to write mBottom. - mBottom.store(top, std::memory_order_relaxed); + // However, generally seq_cst cannot be mixed with other memory orders. So we must use seq_cst. + // see: https://plv.mpi-sws.org/scfix/paper.pdf + mBottom.store(top, std::memory_order_seq_cst); return item; } diff --git a/shaders/src/fog.fs b/shaders/src/fog.fs index 17029480ca1..fbd41720a46 100644 --- a/shaders/src/fog.fs +++ b/shaders/src/fog.fs @@ -7,6 +7,11 @@ vec4 fog(vec4 color, highp vec3 view) { // note: d can be +inf with the skybox highp float d = length(view); + // early exit for object "in front" of the fog + if (d < frameUniforms.fogStart) { + return color; + } + // fogCutOffDistance is set to +inf to disable the cutoff distance if (d > frameUniforms.fogCutOffDistance) { return color; diff --git a/web/filament-js/package.json b/web/filament-js/package.json index aef76f68202..1397ef32313 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.53.4", + "version": "1.53.5", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js",