Skip to content

Commit

Permalink
Merge branch 'rc/1.56.2' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
poweifeng committed Nov 25, 2024
2 parents 60ce48e + 7588189 commit 04b6296
Show file tree
Hide file tree
Showing 56 changed files with 1,030 additions and 1,471 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.1'
implementation 'com.google.android.filament:filament-android:1.56.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.56.1'
pod 'Filament', '~> 1.56.2'
```

## Documentation
Expand Down
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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.2

- vk: fix stage pool gc logic

## v1.56.1

## v1.56.0
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.56.1
VERSION_NAME=1.56.2

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

Expand Down
5 changes: 5 additions & 0 deletions filament/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ if (FILAMENT_ENABLE_MULTIVIEW)
add_definitions(-DFILAMENT_ENABLE_MULTIVIEW)
endif()

# Whether to force the profiling mode.
if (FILAMENT_FORCE_PROFILING_MODE)
add_definitions(-DFILAMENT_FORCE_PROFILING_MODE)
endif()

# ==================================================================================================
# Definitions
# ==================================================================================================
Expand Down
7 changes: 0 additions & 7 deletions filament/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ if (FILAMENT_SUPPORTS_VULKAN)
src/vulkan/VulkanSwapChain.h
src/vulkan/VulkanReadPixels.cpp
src/vulkan/VulkanReadPixels.h
src/vulkan/VulkanResourceAllocator.h
src/vulkan/VulkanResources.cpp
src/vulkan/VulkanResources.h
src/vulkan/VulkanTexture.cpp
src/vulkan/VulkanTexture.h
src/vulkan/VulkanUtility.cpp
Expand Down Expand Up @@ -378,10 +375,6 @@ set(LINUX_LINKER_OPTIMIZATION_FLAGS
if (LINUX AND FILAMENT_SUPPORTS_OSMESA)
set(OSMESA_COMPILE_FLAGS
-I${FILAMENT_OSMESA_PATH}/include/GL)
set(OSMESA_LINKER_FLAGS
-Wl,-L${FILAMENT_OSMESA_PATH}/lib/x86_64-linux-gnu/
-lOSMesa
)
endif()

if (MSVC)
Expand Down
3 changes: 2 additions & 1 deletion filament/backend/include/backend/platforms/PlatformOSMesa.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "bluegl/BlueGL.h"

#include "osmesa.h"
#include <osmesa.h>

#include <backend/platforms/OpenGLPlatform.h>
#include <backend/DriverEnums.h>
Expand Down Expand Up @@ -56,6 +56,7 @@ class PlatformOSMesa : public OpenGLPlatform {

private:
OSMesaContext mContext;
void* mOsMesaApi = nullptr;
};

} // namespace filament::backend
Expand Down
15 changes: 13 additions & 2 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,20 @@
}

void MetalDriver::destroyProgram(Handle<HwProgram> ph) {
if (ph) {
destruct_handle<MetalProgram>(ph);
if (UTILS_UNLIKELY(!ph)) {
return;
}
// Remove any cached pipeline states that refer to these programs.
auto* metalProgram = handle_cast<MetalProgram>(ph);
const auto& functions = metalProgram->getFunctionsIfPresent();
if (UTILS_LIKELY(functions.isRaster())) { // only raster pipelines are cached
const auto& raster = functions.getRasterFunctions();
mContext->pipelineStateCache.removeIf([&](const MetalPipelineState& state) {
const auto& [fragment, vertex] = raster;
return state.fragmentFunction == fragment || state.vertexFunction == vertex;
});
}
destruct_handle<MetalProgram>(ph);
}

void MetalDriver::destroyTexture(Handle<HwTexture> th) {
Expand Down
3 changes: 2 additions & 1 deletion filament/backend/src/metal/MetalHandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class MetalProgram : public HwProgram {
MetalProgram(MetalContext& context, Program&& program) noexcept;

const MetalShaderCompiler::MetalFunctionBundle& getFunctions();
const MetalShaderCompiler::MetalFunctionBundle& getFunctionsIfPresent() const;

private:
void initialize();
Expand Down Expand Up @@ -437,7 +438,7 @@ struct MetalTimerQuery : public HwTimerQuery {

struct Status {
std::atomic<bool> available {false};
uint64_t elapsed {0}; // only valid if available is true
std::atomic<uint64_t> elapsed {0}; // only valid if available is true
};

std::shared_ptr<Status> status;
Expand Down
4 changes: 4 additions & 0 deletions filament/backend/src/metal/MetalHandles.mm
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,10 @@ static void func(void* user) {
return mFunctionBundle;
}

const MetalShaderCompiler::MetalFunctionBundle& MetalProgram::getFunctionsIfPresent() const {
return mFunctionBundle;
}

void MetalProgram::initialize() {
if (!mToken) {
return;
Expand Down
4 changes: 4 additions & 0 deletions filament/backend/src/metal/MetalShaderCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class MetalShaderCompiler {
return std::get<Compute>(mPrograms);
}

bool isRaster() const { return std::holds_alternative<Raster>(mPrograms); }

bool isCompute() const { return std::holds_alternative<Compute>(mPrograms); }

static MetalFunctionBundle none() {
return MetalFunctionBundle(None{});
}
Expand Down
18 changes: 17 additions & 1 deletion filament/backend/src/metal/MetalState.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

#include <memory>
#include <tsl/robin_map.h>

#include <utils/Hash.h>
#include <utils/Invocable.h>

namespace filament {
namespace backend {
Expand Down Expand Up @@ -160,6 +162,8 @@ template<typename StateType,
typename HashFn = utils::hash::MurmurHashFn<StateType>>
class StateCache {

using MapType = tsl::robin_map<StateType, MetalType, HashFn>;

public:

StateCache() = default;
Expand All @@ -169,6 +173,18 @@ class StateCache {

void setDevice(id<MTLDevice> device) noexcept { mDevice = device; }

void removeIf(utils::Invocable<bool(const StateType&)> fn) noexcept {
typename MapType::const_iterator it = mStateCache.begin();
while (it != mStateCache.end()) {
const auto& [key, _] = *it;
if (UTILS_UNLIKELY(fn(key))) {
it = mStateCache.erase(it);
} else {
++it;
}
}
}

MetalType getOrCreateState(const StateType& state) noexcept {
assert_invariant(mDevice);

Expand Down Expand Up @@ -196,7 +212,7 @@ class StateCache {
StateCreator creator;
id<MTLDevice> mDevice = nil;

tsl::robin_map<StateType, MetalType, HashFn> mStateCache;
MapType mStateCache;

};

Expand Down
18 changes: 15 additions & 3 deletions filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,29 @@
// set to the desired debug level (for internal debugging [Default: None])
#define DEBUG_MARKER_LEVEL DEBUG_MARKER_NONE

// Override the debug markers if we are forcing profiling mode
#if defined(FILAMENT_FORCE_PROFILING_MODE)
# undef DEBUG_GROUP_MARKER_LEVEL
# undef DEBUG_MARKER_LEVEL

# define DEBUG_GROUP_MARKER_LEVEL DEBUG_GROUP_MARKER_NONE
# define DEBUG_MARKER_LEVEL DEBUG_MARKER_PROFILE
#endif

#if DEBUG_MARKER_LEVEL == DEBUG_MARKER_PROFILE
# define DEBUG_MARKER()
# define PROFILE_MARKER(marker) PROFILE_SCOPE(marker);
# if DEBUG_GROUP_MARKER_LEVEL != DEBUG_GROUP_MARKER_NONE
# error PROFILING is exclusive; group markers must be disabled.
# error PROFILING is exclusive; group markers must be disabled.
# endif
# ifndef NDEBUG
# error PROFILING is meaningless in DEBUG mode.
# endif
#elif DEBUG_MARKER_LEVEL > DEBUG_MARKER_NONE
# define DEBUG_MARKER() DebugMarker _debug_marker(*this, __func__);
# define PROFILE_MARKER(marker) DEBUG_MARKER()
# if DEBUG_MARKER_LEVEL & DEBUG_MARKER_PROFILE
# error PROFILING is exclusive; all other debug features must be disabled.
# error PROFILING is exclusive; all other debug features must be disabled.
# endif
#else
# define DEBUG_MARKER()
Expand Down Expand Up @@ -1670,7 +1682,7 @@ void OpenGLDriver::createSwapChainR(Handle<HwSwapChain> sch, void* nativeWindow,

// See if we need the emulated rec709 output conversion
if (UTILS_UNLIKELY(mContext.isES2())) {
sc->rec709 = (flags & SWAP_CHAIN_CONFIG_SRGB_COLORSPACE &&
sc->rec709 = ((flags & SWAP_CHAIN_CONFIG_SRGB_COLORSPACE) &&
!mPlatform.isSRGBSwapChainSupported());
}
}
Expand Down
61 changes: 55 additions & 6 deletions filament/backend/src/opengl/platforms/PlatformOSMesa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <utils/Log.h>
#include <utils/Panic.h>

#include <dlfcn.h>
#include <memory>

namespace filament::backend {
Expand All @@ -41,13 +42,56 @@ struct OSMesaSwapchain {
std::unique_ptr<uint8_t[]> buffer;
};

} // anonymous namespace
struct OSMesaAPI {
private:
using CreateContextFunc = OSMesaContext (*)(GLenum format, OSMesaContext);
using DestroyContextFunc = GLboolean (*)(OSMesaContext);
using MakeCurrentFunc = GLboolean (*)(OSMesaContext ctx, void* buffer, GLenum type,
GLsizei width, GLsizei height);
using GetProcAddressFunc = OSMESAproc (*)(const char* funcName);

public:
CreateContextFunc OSMesaCreateContext;
DestroyContextFunc OSMesaDestroyContext;
MakeCurrentFunc OSMesaMakeCurrent;
GetProcAddressFunc OSMesaGetProcAddress;

OSMesaAPI() {
constexpr char const* libraryNames[] = {"libOSMesa.so", "libosmesa.so"};
for (char const* libName: libraryNames) {
mLib = dlopen(libName, RTLD_GLOBAL | RTLD_NOW);
if (mLib) {
break;
}
}
FILAMENT_CHECK_PRECONDITION(mLib)
<< "Unable to dlopen libOSMesa to create a software GL context";

OSMesaGetProcAddress = (GetProcAddressFunc) dlsym(mLib, "OSMesaGetProcAddress");

OSMesaCreateContext = (CreateContextFunc) OSMesaGetProcAddress("OSMesaCreateContext");
OSMesaDestroyContext =
(DestroyContextFunc) OSMesaGetProcAddress("OSMesaDestroyContext");
OSMesaMakeCurrent = (MakeCurrentFunc) OSMesaGetProcAddress("OSMesaMakeCurrent");
}

~OSMesaAPI() {
dlclose(mLib);
}
private:
void* mLib = nullptr;
};

}// anonymous namespace

Driver* PlatformOSMesa::createDriver(void* const sharedGLContext,
const DriverConfig& driverConfig) noexcept {
OSMesaAPI* api = new OSMesaAPI();
mOsMesaApi = api;

FILAMENT_CHECK_PRECONDITION(sharedGLContext == nullptr)
<< "shared GL context is not supported with PlatformOSMesa";
mContext = OSMesaCreateContext(GL_RGBA, NULL);
mContext = api->OSMesaCreateContext(GL_RGBA, NULL);

// We need to do a no-op makecurrent here so that the context will be in a correct state before
// any GL calls.
Expand All @@ -62,7 +106,11 @@ Driver* PlatformOSMesa::createDriver(void* const sharedGLContext,
}

void PlatformOSMesa::terminate() noexcept {
OSMesaDestroyContext(mContext);
OSMesaAPI* api = (OSMesaAPI*) mOsMesaApi;
api->OSMesaDestroyContext(mContext);
delete api;
mOsMesaApi = nullptr;

bluegl::unbind();
}

Expand All @@ -84,11 +132,12 @@ void PlatformOSMesa::destroySwapChain(Platform::SwapChain* swapChain) noexcept {

bool PlatformOSMesa::makeCurrent(ContextType type, SwapChain* drawSwapChain,
SwapChain* readSwapChain) noexcept {
OSMesaAPI* api = (OSMesaAPI*) mOsMesaApi;
OSMesaSwapchain* impl = (OSMesaSwapchain*) drawSwapChain;

auto result = OSMesaMakeCurrent(mContext, (BackingType*) impl->buffer.get(), BACKING_GL_TYPE,
impl->width, impl->height);
FILAMENT_CHECK_POSTCONDITION(result) << "OSMesaMakeCurrent failed!";
auto result = api->OSMesaMakeCurrent(mContext, (BackingType*) impl->buffer.get(),
BACKING_GL_TYPE, impl->width, impl->height);
FILAMENT_CHECK_POSTCONDITION(result == GL_TRUE) << "OSMesaMakeCurrent failed!";

return true;
}
Expand Down
3 changes: 1 addition & 2 deletions filament/backend/src/vulkan/VulkanAsyncHandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
namespace filament::backend {

VulkanTimerQuery::VulkanTimerQuery(std::tuple<uint32_t, uint32_t> indices)
: VulkanThreadSafeResource(VulkanResourceType::TIMER_QUERY),
mStartingQueryIndex(std::get<0>(indices)),
: mStartingQueryIndex(std::get<0>(indices)),
mStoppingQueryIndex(std::get<1>(indices)) {}

void VulkanTimerQuery::setFence(std::shared_ptr<VulkanCmdFence> fence) noexcept {
Expand Down
13 changes: 4 additions & 9 deletions filament/backend/src/vulkan/VulkanAsyncHandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "DriverBase.h"

#include "VulkanResources.h"
#include "vulkan/memory/Resource.h"

#include <utils/Mutex.h>
#include <utils/Condition.h>
Expand All @@ -47,17 +47,12 @@ struct VulkanCmdFence {
std::atomic<VkResult> status;
};

struct VulkanFence : public HwFence, VulkanResource {
VulkanFence() : VulkanResource(VulkanResourceType::FENCE) {}

explicit VulkanFence(std::shared_ptr<VulkanCmdFence> fence)
: VulkanResource(VulkanResourceType::FENCE),
fence(fence) {}

struct VulkanFence : public HwFence, fvkmemory::ThreadSafeResource {
VulkanFence() {}
std::shared_ptr<VulkanCmdFence> fence;
};

struct VulkanTimerQuery : public HwTimerQuery, VulkanThreadSafeResource {
struct VulkanTimerQuery : public HwTimerQuery, fvkmemory::ThreadSafeResource {
explicit VulkanTimerQuery(std::tuple<uint32_t, uint32_t> indices);
~VulkanTimerQuery();

Expand Down
Loading

0 comments on commit 04b6296

Please sign in to comment.