Skip to content

Commit

Permalink
Merge branch 'rc/1.32.2' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Apr 5, 2023
2 parents 732628a + b8a3a7f commit 7685736
Show file tree
Hide file tree
Showing 27 changed files with 224 additions and 116 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,16 @@ if (LINUX)
add_definitions(-DFILAMENT_SUPPORTS_XCB)
endif()

# Default Swiftshader build does not enable the xlib extension
if (FILAMENT_SUPPORTS_XLIB AND FILAMENT_USE_SWIFTSHADER)
set(FILAMENT_SUPPORTS_XLIB OFF)
endif()

if (FILAMENT_SUPPORTS_XLIB)
add_definitions(-DFILAMENT_SUPPORTS_XLIB)
endif()

if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPORTS_XLIB)
if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPPORTS_XLIB)
add_definitions(-DFILAMENT_SUPPORTS_X11)
set(FILAMENT_SUPPORTS_X11 TRUE)
endif()
Expand Down
1 change: 1 addition & 0 deletions NEW_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ for next branch cut* header.
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).

## Release notes for next branch cut

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.32.1'
implementation 'com.google.android.filament:filament-android:1.32.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:

```
pod 'Filament', '~> 1.32.1'
pod 'Filament', '~> 1.32.2'
```

### Snapshots
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.32.2

- lighting: the sun disc was computed in low/medium quality instead of high quality. This will
provide performance improvements to mobile devices [⚠️ **Recompile Materials**]

## v1.32.1

## v1.32.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.32.1
VERSION_NAME=1.32.2

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

Expand Down
2 changes: 1 addition & 1 deletion docs/Filament.html
Original file line number Diff line number Diff line change
Expand Up @@ -5776,7 +5776,7 @@

$$\begin{align*}
C^0_l &= 2\pi \int_0^{\pi} \left< cos \theta \right> y^0_l(\theta) sin \theta d\theta \\
C^0_l &= 2\pi K^)_l \int_0^{\frac{\pi}{2}} P^0_l(cos \theta) cos \theta sin \theta d\theta \\
C^0_l &= 2\pi K^m_l \int_0^{\frac{\pi}{2}} P^0_l(cos \theta) cos \theta sin \theta d\theta \\
C^m_l &= 0, m != 0
\end{align*}$$

Expand Down
100 changes: 68 additions & 32 deletions docs/Materials.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Materials.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,7 @@
**getUserWorldFromWorldMatrix()** | float4x4 | Matrix that converts from world space to API-level (user) world space.
**getTime()** | float | Current time as a remainder of 1 second. Yields a value between 0 and 1
**getUserTime()** | float4 | Current time in seconds: `time`, `(double)time - time`, `0`, `0`
**getUserTimeMode(float m)** | float | Current time modulo m in seconds
**getUserTimeMod(float m)** | float | Current time modulo m in seconds
**getExposure()** | float | Photometric exposure of the camera
**getEV100()** | float | [Exposure value at ISO 100](https://en.wikipedia.org/wiki/Exposure_value) of the camera

Expand Down
29 changes: 11 additions & 18 deletions filament/test/filament_rendering_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <filament/Scene.h>
#include <filament/View.h>
#include <filament/Viewport.h>
#include <filament/ColorGrading.h>

#include <utils/EntityManager.h>

Expand All @@ -41,7 +40,6 @@ class RenderingTest : public testing::Test {
Scene* mScene = nullptr;
Camera* mCamera = nullptr;
utils::Entity mCameraEntity;
ColorGrading* mColorGrading = nullptr;

using closure_t = std::function<void(uint8_t const* rgba, uint32_t width, uint32_t height)>;

Expand All @@ -59,20 +57,13 @@ class RenderingTest : public testing::Test {
mView->setViewport({0, 0, 16, 16});
mView->setScene(mScene);
mView->setCamera(mCamera);

LinearToneMapper linearToneMapper;
mColorGrading = ColorGrading::Builder()
.toneMapper(&linearToneMapper)
.build(*mEngine);
mView->setColorGrading(mColorGrading);
mView->setPostProcessingEnabled(false);

mSkybox = Skybox::Builder().build(*mEngine);
mScene->setSkybox(mSkybox);
}

void TearDown() override {
mEngine->destroy(mColorGrading);

mEngine->destroyCameraComponent(mCameraEntity);
utils::EntityManager::get().destroy(mCameraEntity);

Expand Down Expand Up @@ -115,27 +106,29 @@ class RenderingTest : public testing::Test {
};

TEST_F(RenderingTest, ClearRed) {
// We need to clear red to >1 here to ensure a tonemapped value of 255 regardless of LUT
// precision.
mSkybox->setColor({ 2.0f, 0.0f, 0.0f, 1.0f });
mSkybox->setColor({ 1.0f, 0.0f, 0.0f, 1.0f });
mView->setDithering(View::Dithering::NONE);
runTest([this](uint8_t const* rgba, uint32_t width, uint32_t height) {
bool callbackCalled = false;
runTest([this, &callbackCalled](uint8_t const* rgba, uint32_t width, uint32_t height) {
EXPECT_EQ(rgba[0], 0xff);
EXPECT_EQ(rgba[1], 0);
EXPECT_EQ(rgba[2], 0);
EXPECT_EQ(rgba[3], 0xff);
callbackCalled = true;
});
EXPECT_TRUE(callbackCalled);
}

TEST_F(RenderingTest, ClearGreen) {
// We need to clear green to >1 here to ensure a tonemapped value of 255 regardless of LUT
// precision.
mSkybox->setColor({ 0.0f, 2.0f, 0.0f, 1.0f });
mSkybox->setColor({ 0.0f, 1.0f, 0.0f, 1.0f });
mView->setDithering(View::Dithering::NONE);
runTest([this](uint8_t const* rgba, uint32_t width, uint32_t height) {
bool callbackCalled = false;
runTest([this, &callbackCalled](uint8_t const* rgba, uint32_t width, uint32_t height) {
EXPECT_EQ(rgba[0], 0);
EXPECT_EQ(rgba[1], 0xff);
EXPECT_EQ(rgba[2], 0);
EXPECT_EQ(rgba[3], 0xff);
callbackCalled = true;
});
EXPECT_TRUE(callbackCalled);
}
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.32.1"
spec.version = "1.32.2"
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.32.1/filament-v1.32.1-ios.tgz" }
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.32.2/filament-v1.32.2-ios.tgz" }

# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
spec.pod_target_xcconfig = {
Expand Down
5 changes: 5 additions & 0 deletions libs/filaflat/include/filaflat/MaterialChunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <tsl/robin_map.h>

#include <utils/Invocable.h>

namespace filaflat {

class MaterialChunk {
Expand All @@ -43,6 +45,9 @@ class MaterialChunk {
bool getShader(ShaderContent& shaderContent, BlobDictionary const& dictionary,
uint8_t shaderModel, Variant variant, uint8_t stage);

void visitTextShaders(
utils::Invocable<void(uint8_t, Variant::type_t, uint8_t)>&& visitor) const;

// These methods are for debugging purposes only (matdbg)
// @{
static void decodeKey(uint32_t key, uint8_t* model, Variant::type_t* variant, uint8_t* stage);
Expand Down
29 changes: 29 additions & 0 deletions libs/filaflat/src/MaterialChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,34 @@ bool MaterialChunk::getShader(ShaderContent& shaderContent,
}
}

void MaterialChunk::visitTextShaders(
utils::Invocable<void(uint8_t, Variant::type_t, uint8_t)>&& visitor) const {
assert_invariant(mMaterialTag != filamat::ChunkType::MaterialSpirv);

Unflattener unflattener{ mUnflattener }; // make a copy

// read() calls below cannot fail by construction, because we've already run through them
// in the constructor.

// Read how many shaders we have in the chunk.
uint64_t numShaders;
unflattener.read(&numShaders);

// Read all index entries.
for (uint64_t i = 0; i < numShaders; i++) {
uint8_t shaderModelValue;
filament::Variant variant;
uint8_t pipelineStageValue;
uint32_t offsetValue;

unflattener.read(&shaderModelValue);
unflattener.read(&variant);
unflattener.read(&pipelineStageValue);
unflattener.read(&offsetValue);

visitor(shaderModelValue, variant.key, pipelineStageValue);
}
}

} // namespace filaflat

6 changes: 3 additions & 3 deletions libs/filamat/src/shaders/CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@ io::sstream& CodeGenerator::generateQualityDefine(io::sstream& out, ShaderQualit
switch (quality) {
case ShaderQuality::DEFAULT:
switch (mShaderModel) {
default: goto quality_normal;
case ShaderModel::DESKTOP: goto quality_high;
case ShaderModel::MOBILE: goto quality_low;
default: goto quality_normal;
case ShaderModel::DESKTOP: goto quality_high;
case ShaderModel::MOBILE: goto quality_low;
}
case ShaderQuality::LOW:
quality_low:
Expand Down
11 changes: 11 additions & 0 deletions libs/gltfio/src/Ktx2Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ void Ktx2Provider::cancelDecoding() {
// in-flight jobs. We should consider throttling the number of simultaneous decoder jobs, which
// would allow for actual cancellation.
waitForCompletion();

// For cancelled jobs, we need to set the QueueItemState to POPPED and free the decoded data
// stored in item->async.
for (auto& item : mQueueItems) {
if (item->state != QueueItemState::TRANSCODING) {
continue;
}
mKtxReader->asyncDestroy(&item->async);
item->async = nullptr;
item->state = QueueItemState::POPPED;
}
}

const char* Ktx2Provider::getPushMessage() const {
Expand Down
16 changes: 16 additions & 0 deletions libs/gltfio/src/StbProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ void StbProvider::cancelDecoding() {
// in-flight jobs. We should consider throttling the number of simultaneous decoder jobs, which
// would allow for actual cancellation.
waitForCompletion();

// For cancelled jobs, we need to set the TextureInfo to the popped state and free the decoded
// data.
for (auto& info : mTextures) {
if (info->state != TextureState::DECODING) {
continue;
}
// Deleting data here should be safe thread-wise as the only other place where
// decodedTexelsBaseMipmap is loaded is in the job threads, and we have waited them to
// completion above. We also expect the TextureProvider API calls to be made only from one
// thread.
if (intptr_t data = info->decodedTexelsBaseMipmap.load()) {
delete [] (uint8_t*) data;
}
info->state = TextureState::POPPED;
}
}

const char* StbProvider::getPushMessage() const {
Expand Down
2 changes: 1 addition & 1 deletion libs/ktxreader/include/ktxreader/Ktx2Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Ktx2Reader {

protected:
Async() noexcept = default;
~Async() = default;
virtual ~Async();

public:
Async(Async const&) = delete;
Expand Down
14 changes: 14 additions & 0 deletions libs/ktxreader/src/Ktx2Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ class FAsync : public Async {
Result doTranscoding();
void uploadImages();

protected:
~FAsync();

private:
using TranscoderResult = std::atomic<Texture::PixelBufferDescriptor*>;

Expand Down Expand Up @@ -260,6 +263,15 @@ Texture* Ktx2Reader::load(const void* data, size_t size, TransferFunction transf
return texture;
}

FAsync::~FAsync() {
for (TranscoderResult& level : mTranscoderResults) {
Texture::PixelBufferDescriptor* pbd = level.load();
if (pbd) {
delete pbd;
}
}
}

Result FAsync::doTranscoding() {
ktx2_transcoder_state basisThreadState;
basisThreadState.clear();
Expand Down Expand Up @@ -412,6 +424,8 @@ Texture* Ktx2Reader::createTexture(ktx2_transcoder* transcoder, const void* data
return texture;
}

Async::~Async() = default;

Texture* Async::getTexture() const noexcept {
return static_cast<FAsync const*>(this)->getTexture();
}
Expand Down
19 changes: 10 additions & 9 deletions libs/matdbg/src/ShaderReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,19 @@ ShaderIndex::ShaderIndex(ChunkType dictTag, ChunkType matTag, const filaflat::Ch
filaflat::MaterialChunk matChunk(cc);
matChunk.initialize(matTag);

const auto& offsets = matChunk.getOffsets();
mShaderRecords.reserve(offsets.size());
for (auto [key, offset] : offsets) {
TextEntry info;
filaflat::MaterialChunk::decodeKey(key, &info.shaderModel, &info.variantKey, &info.stage);
matChunk.visitTextShaders(
[this, &matChunk, &stringBlobs](uint8_t shaderModel, Variant::type_t variant,
uint8_t stage) {

ShaderContent content;
UTILS_UNUSED_IN_RELEASE bool success = matChunk.getShader(content,
stringBlobs, info.shaderModel, Variant(info.variantKey), info.stage);
info.shader = std::string(content.data(), content.data() + content.size() - 1);
stringBlobs, shaderModel, Variant(variant), stage);

std::string source{content.data(), content.data() + content.size() - 1u};
assert_invariant(success);
mShaderRecords.emplace_back(info);
}

mShaderRecords.push_back({ shaderModel, variant, stage, std::move(source) });
});
}

void ShaderIndex::writeChunks(ostream& stream) {
Expand Down
5 changes: 4 additions & 1 deletion libs/viewer/include/viewer/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ using LightManager = filament::LightManager;
void applySettings(Engine* engine, const ViewSettings& settings, View* dest);
void applySettings(Engine* engine, const MaterialSettings& settings, MaterialInstance* dest);
void applySettings(Engine* engine, const LightSettings& settings, IndirectLight* ibl, utils::Entity sunlight,
utils::Entity* sceneLights, size_t sceneLightCount, LightManager* lm, Scene* scene, View* view);
const utils::Entity* sceneLights, size_t sceneLightCount, LightManager* lm, Scene* scene, View* view);
void applySettings(Engine* engine, const ViewerOptions& settings, Camera* camera, Skybox* skybox,
Renderer* renderer);

Expand Down Expand Up @@ -204,6 +204,9 @@ struct LightSettings {
LightManager::ShadowOptions shadowOptions;
SoftShadowOptions softShadowOptions;
float sunlightIntensity = 100000.0f;
float sunlightHaloSize = 10.0f;
float sunlightHaloFalloff = 80.0f;
float sunlightAngularRadius = 1.9f;
math::float3 sunlightDirection = {0.6, -1.0, -0.8};
math::float3 sunlightColor = filament::Color::toLinear<filament::ACCURATE>({ 0.98, 0.92, 0.89});
float iblIntensity = 30000.0f;
Expand Down
2 changes: 0 additions & 2 deletions libs/viewer/include/viewer/ViewerGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ class UTILS_PUBLIC ViewerGui {
private:
using SceneMask = gltfio::NodeManager::SceneMask;

void updateIndirectLight();

bool isRemoteMode() const { return mAsset == nullptr; }

void sceneSelectionUI();
Expand Down
Loading

0 comments on commit 7685736

Please sign in to comment.