Skip to content

Commit

Permalink
Merge branch 'rc/1.51.5' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
z3moon committed Apr 22, 2024
2 parents 65f2df7 + 35fa79e commit 53af1fd
Show file tree
Hide file tree
Showing 62 changed files with 1,623 additions and 1,342 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ if (IS_HOST_PLATFORM)
add_subdirectory(${TOOLS}/glslminifier)
add_subdirectory(${TOOLS}/matc)
add_subdirectory(${TOOLS}/matinfo)
if (NOT WIN32) # matedit not yet supported on Windows
add_subdirectory(${TOOLS}/matedit)
endif()
add_subdirectory(${TOOLS}/mipgen)
add_subdirectory(${TOOLS}/normal-blending)
add_subdirectory(${TOOLS}/resgen)
Expand Down
2 changes: 2 additions & 0 deletions NEW_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ for next branch cut* header.
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).

## Release notes for next branch cut

- Add new matedit tool
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.51.4'
implementation 'com.google.android.filament:filament-android:1.51.5'
}
```

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.51.4'
pod 'Filament', '~> 1.51.5'
```

### 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.51.5


## v1.51.4


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.51.4
VERSION_NAME=1.51.5

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

Expand Down
11 changes: 6 additions & 5 deletions filament/backend/include/backend/DriverEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ static constexpr const char* backendToString(Backend backend) {
}

/**
* Defines the shader language. Similar to the above backend enum, but the OpenGL backend can select
* between two shader languages: ESSL 1.0 and ESSL 3.0.
* Defines the shader language. Similar to the above backend enum, with some differences:
* - The OpenGL backend can select between two shader languages: ESSL 1.0 and ESSL 3.0.
* - The Metal backend can prefer precompiled Metal libraries, while falling back to MSL.
*/
enum class ShaderLanguage {
ESSL1 = 0,
ESSL3 = 1,
SPIRV = 2,
MSL = 3,
METAL_LIBRARY = 4,
};

static constexpr const char* shaderLanguageToString(ShaderLanguage shaderLanguage) {
Expand All @@ -178,6 +180,8 @@ static constexpr const char* shaderLanguageToString(ShaderLanguage shaderLanguag
return "SPIR-V";
case ShaderLanguage::MSL:
return "MSL";
case ShaderLanguage::METAL_LIBRARY:
return "Metal precompiled library";
}
}

Expand Down Expand Up @@ -1237,9 +1241,6 @@ enum class Workaround : uint16_t {
DISABLE_BLIT_INTO_TEXTURE_ARRAY,
// Multiple workarounds needed for PowerVR GPUs
POWER_VR_SHADER_WORKAROUNDS,
// The driver has some threads pinned, and we can't easily know on which core, it can hurt
// performance more if we end-up pinned on the same one.
DISABLE_THREAD_AFFINITY
};

//! The type of technique for stereoscopic rendering
Expand Down
6 changes: 6 additions & 0 deletions filament/backend/include/backend/Program.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class Program {
// null terminating character.
Program& shader(ShaderStage shader, void const* data, size_t size);

// sets the language of the shader sources provided with shader() (defaults to ESSL3)
Program& shaderLanguage(ShaderLanguage shaderLanguage);

// Note: This is only needed for GLES3.0 backends, because the layout(binding=) syntax is
// not permitted in glsl. The backend needs a way to associate a uniform block
// to a binding point.
Expand Down Expand Up @@ -136,6 +139,8 @@ class Program {
utils::CString const& getName() const noexcept { return mName; }
utils::CString& getName() noexcept { return mName; }

auto const& getShaderLanguage() const { return mShaderLanguage; }

utils::FixedCapacityVector<SpecializationConstant> const& getSpecializationConstants() const noexcept {
return mSpecializationConstants;
}
Expand All @@ -155,6 +160,7 @@ class Program {
UniformBlockInfo mUniformBlocks = {};
SamplerGroupInfo mSamplerGroups = {};
ShaderSource mShadersSource;
ShaderLanguage mShaderLanguage = ShaderLanguage::ESSL3;
utils::CString mName;
uint64_t mCacheId{};
utils::Invocable<utils::io::ostream&(utils::io::ostream& out)> mLogger;
Expand Down
7 changes: 6 additions & 1 deletion filament/backend/src/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace filament::backend {
using namespace utils;

// We want these in the .cpp file, so they're not inlined (not worth it)
Program::Program() noexcept { // NOLINT(modernize-use-equals-default)
Program::Program() noexcept { // NOLINT(modernize-use-equals-default)
}

Program::Program(Program&& rhs) noexcept = default;
Expand All @@ -47,6 +47,11 @@ Program& Program::shader(ShaderStage shader, void const* data, size_t size) {
return *this;
}

Program& Program::shaderLanguage(ShaderLanguage shaderLanguage) {
mShaderLanguage = shaderLanguage;
return *this;
}

Program& Program::uniformBlockBindings(
FixedCapacityVector<std::pair<utils::CString, uint8_t>> const& uniformBlockBindings) noexcept {
for (auto const& item : uniformBlockBindings) {
Expand Down
53 changes: 34 additions & 19 deletions filament/backend/src/metal/MetalShaderCompiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,41 @@ bool isReady() const noexcept {
continue;
}

assert_invariant(source[source.size() - 1] == '\0');

// the shader string is null terminated and the length includes the null character
NSString* objcSource = [[NSString alloc] initWithBytes:source.data()
length:source.size() - 1
encoding:NSUTF8StringEncoding];

// By default, Metal uses the most recent language version.
MTLCompileOptions* options = [MTLCompileOptions new];

// Disable Fast Math optimizations.
// This ensures that operations adhere to IEEE standards for floating-point arithmetic,
// which is crucial for half precision floats in scenarios where fast math optimizations
// lead to inaccuracies, such as in handling special values like NaN or Infinity.
options.fastMathEnabled = NO;

NSError* error = nil;
id<MTLLibrary> library = [device newLibraryWithSource:objcSource
options:options
error:&error];
id<MTLLibrary> library = nil;
switch (program.getShaderLanguage()) {
case ShaderLanguage::MSL: {
// By default, Metal uses the most recent language version.
MTLCompileOptions* options = [MTLCompileOptions new];

// Disable Fast Math optimizations.
// This ensures that operations adhere to IEEE standards for floating-point
// arithmetic, which is crucial for half precision floats in scenarios where fast
// math optimizations lead to inaccuracies, such as in handling special values like
// NaN or Infinity.
options.fastMathEnabled = NO;

assert_invariant(source[source.size() - 1] == '\0');
// the shader string is null terminated and the length includes the null character
NSString* objcSource = [[NSString alloc] initWithBytes:source.data()
length:source.size() - 1
encoding:NSUTF8StringEncoding];
library = [device newLibraryWithSource:objcSource options:options error:&error];
break;
}
case ShaderLanguage::METAL_LIBRARY: {
dispatch_data_t data = dispatch_data_create(source.data(), source.size(),
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
DISPATCH_DATA_DESTRUCTOR_DEFAULT);
library = [device newLibraryWithData:data error:&error];
break;
}
case ShaderLanguage::ESSL1:
case ShaderLanguage::ESSL3:
case ShaderLanguage::SPIRV:
break;
}

if (library == nil) {
NSString* errorMessage = @"unknown error";
if (error) {
Expand Down
9 changes: 6 additions & 3 deletions filament/backend/src/opengl/OpenGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform) noexcept
}

OpenGLContext::~OpenGLContext() noexcept {
// note: this is called from the main thread. Can't do any GL calls.
delete mTimerQueryFactory;
}

void OpenGLContext::terminate() noexcept {
// note: this is called from the backend thread
#ifndef FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2
if (!isES2()) {
for (auto& item: mSamplerMap) {
Expand All @@ -262,7 +268,6 @@ OpenGLContext::~OpenGLContext() noexcept {
mSamplerMap.clear();
}
#endif
delete mTimerQueryFactory;
}

void OpenGLContext::destroyWithContext(
Expand Down Expand Up @@ -526,8 +531,6 @@ void OpenGLContext::initBugs(Bugs* bugs, Extensions const& exts,
bugs->delay_fbo_destruction = true;
// PowerVR seems to have no problem with this (which is good for us)
bugs->allow_read_only_ancillary_feedback_loop = true;
// PowerVR has a shader compiler thread pinned on the last core
bugs->disable_thread_affinity = true;
} else if (strstr(renderer, "Apple")) {
// Apple GPU
} else if (strstr(renderer, "Tegra") ||
Expand Down
10 changes: 3 additions & 7 deletions filament/backend/src/opengl/OpenGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ class OpenGLContext final : public TimerQueryFactoryInterface {
static bool queryOpenGLVersion(GLint* major, GLint* minor) noexcept;

explicit OpenGLContext(OpenGLPlatform& platform) noexcept;

~OpenGLContext() noexcept final;

void terminate() noexcept;

// TimerQueryInterface ------------------------------------------------------------------------

// note: OpenGLContext being final ensures (clang) these are not called through the vtable
Expand Down Expand Up @@ -308,10 +311,6 @@ class OpenGLContext final : public TimerQueryFactoryInterface {
// a glFinish. So we must delay the destruction until we know the GPU is finished.
bool delay_fbo_destruction;

// The driver has some threads pinned, and we can't easily know on which core, it can hurt
// performance more if we end-up pinned on the same one.
bool disable_thread_affinity;

// Force feature level 0. Typically used for low end ES3 devices with significant driver
// bugs or performance issues.
bool force_feature_level0;
Expand Down Expand Up @@ -552,9 +551,6 @@ class OpenGLContext final : public TimerQueryFactoryInterface {
{ bugs.delay_fbo_destruction,
"delay_fbo_destruction",
""},
{ bugs.disable_thread_affinity,
"disable_thread_affinity",
""},
{ bugs.force_feature_level0,
"force_feature_level0",
""},
Expand Down
5 changes: 3 additions & 2 deletions filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ OpenGLDriver::OpenGLDriver(OpenGLPlatform* platform, const Platform::DriverConfi
}

OpenGLDriver::~OpenGLDriver() noexcept { // NOLINT(modernize-use-equals-default)
// this is called from the main thread. Can't call GL.
}

Dispatcher OpenGLDriver::getDispatcher() const noexcept {
Expand Down Expand Up @@ -264,6 +265,8 @@ void OpenGLDriver::terminate() {
assert_invariant(mGpuCommandCompleteOps.empty());
#endif

mContext.terminate();

mPlatform.terminate();
}

Expand Down Expand Up @@ -2056,8 +2059,6 @@ bool OpenGLDriver::isWorkaroundNeeded(Workaround workaround) {
return mContext.bugs.disable_blit_into_texture_array;
case Workaround::POWER_VR_SHADER_WORKAROUNDS:
return mContext.bugs.powervr_shader_workarounds;
case Workaround::DISABLE_THREAD_AFFINITY:
return mContext.bugs.disable_thread_affinity;
default:
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion filament/backend/src/vulkan/VulkanCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ VulkanCmdFence::VulkanCmdFence(VkFence ifence)

VulkanCommandBuffer::VulkanCommandBuffer(VulkanResourceAllocator* allocator, VkDevice device,
VkCommandPool pool)
: mResourceManager(allocator) {
: mResourceManager(allocator),
mPipeline(VK_NULL_HANDLE) {
// Create the low-level command buffer.
const VkCommandBufferAllocateInfo allocateInfo{
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
Expand Down
10 changes: 10 additions & 0 deletions filament/backend/src/vulkan/VulkanCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ struct VulkanCommandBuffer {
inline void reset() {
fence.reset();
mResourceManager.clear();
mPipeline = VK_NULL_HANDLE;
}

inline void setPipeline(VkPipeline pipeline) {
mPipeline = pipeline;
}

inline VkPipeline pipeline() const {
return mPipeline;
}

inline VkCommandBuffer buffer() const {
Expand All @@ -103,6 +112,7 @@ struct VulkanCommandBuffer {
private:
VulkanAcquireOnlyResourceManager mResourceManager;
VkCommandBuffer mBuffer;
VkPipeline mPipeline;
};

// Allows classes to be notified after a new command buffer has been activated.
Expand Down
Loading

0 comments on commit 53af1fd

Please sign in to comment.