Skip to content

Commit

Permalink
Merge branch 'rc/1.9.23' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed May 3, 2021
2 parents debcbb8 + 71a185d commit 4388e81
Show file tree
Hide file tree
Showing 70 changed files with 2,024 additions and 263 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ add_subdirectory(${LIBRARIES}/filameshio)
add_subdirectory(${LIBRARIES}/geometry)
add_subdirectory(${LIBRARIES}/gltfio)
add_subdirectory(${LIBRARIES}/ibl)
add_subdirectory(${LIBRARIES}/iblprefilter)
add_subdirectory(${LIBRARIES}/image)
add_subdirectory(${LIBRARIES}/math)
add_subdirectory(${LIBRARIES}/mathio)
Expand Down
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.9.22'
implementation 'com.google.android.filament:filament-android:1.9.23'
}
```

Expand Down Expand Up @@ -63,7 +63,7 @@ A much smaller alternative to `filamat-android` that can only generate OpenGL sh
iOS projects can use CocoaPods to install the latest release:

```
pod 'Filament', '~> 1.9.22'
pod 'Filament', '~> 1.9.23'
```

### Snapshots
Expand Down
13 changes: 12 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ A new header is inserted each time a *tag* is created.

## Next release (main branch)

- engine: Add new `Renderer::renderStandaloneView()` API.
## v1.9.23

- Vulkan: various fixes.
- android: fix crash seen using VSM with MSAA on Adreno devices.
- engine: Add `Engine::getEntityManager()`.
- engine: Fix desktop crash seen with some GPU drivers.
- engine: improve importance sampling.
- gltfio: robustness improvements for Draco meshes.
- libs: Add new Transcoder API for C++ clients (part of `libgeometry`).
- libs: New `iblprefilter` library to compute IBL pre-integration on the GPU using filament.
- materials: Fix documentation for `getNormalizedViewportCoord`.
- samples: fix rendertarget sample crash on launch.

## v1.9.22

Expand Down
5 changes: 4 additions & 1 deletion android/filament-android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ target_link_libraries(filament-jni
PRIVATE backend
PRIVATE filaflat
PRIVATE filabridge
PRIVATE geometry
PRIVATE ibl-lite
PRIVATE log
PRIVATE GLESv3
PRIVATE EGL
PRIVATE android
PRIVATE jnigraphics
PRIVATE utils

# libgeometry is PUBLIC because gltfio uses it.
PUBLIC geometry

$<$<STREQUAL:${FILAMENT_ENABLE_MATDBG},ON>:matdbg>
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:bluevk>
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:vkshaders>
Expand Down
6 changes: 6 additions & 0 deletions android/filament-android/src/main/cpp/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,9 @@ Java_com_google_android_filament_Engine_nGetJobSystem(JNIEnv*, jclass, jlong nat
Engine* engine = (Engine*) nativeEngine;
return (jlong) &engine->getJobSystem();
}

extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Engine_nGetEntityManager(JNIEnv*, jclass, jlong nativeEngine) {
Engine* engine = (Engine*) nativeEngine;
return (jlong) &engine->getEntityManager();
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class Engine {
@NonNull private final TransformManager mTransformManager;
@NonNull private final LightManager mLightManager;
@NonNull private final RenderableManager mRenderableManager;
@NonNull private final EntityManager mEntityManager;

/**
* Denotes a backend
Expand Down Expand Up @@ -142,6 +143,7 @@ private Engine(long nativeEngine) {
mTransformManager = new TransformManager(nGetTransformManager(nativeEngine));
mLightManager = new LightManager(nGetLightManager(nativeEngine));
mRenderableManager = new RenderableManager(nGetRenderableManager(nativeEngine));
mEntityManager = new EntityManager(nGetEntityManager(nativeEngine));
}

/**
Expand Down Expand Up @@ -707,4 +709,5 @@ private static void assertDestroy(boolean success) {
private static native long nGetLightManager(long nativeEngine);
private static native long nGetRenderableManager(long nativeEngine);
private static native long nGetJobSystem(long nativeEngine);
private static native long nGetEntityManager(long nativeEngine);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ private static class Holder {
private EntityManager() {
}

EntityManager(long nativeEntityManager) {
mNativeObject = nativeEntityManager;
}

@NonNull
public static EntityManager get() {
return Holder.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public long getNativeObject() {
*/
public enum AttachmentPoint {
COLOR,
DEPTH,
COLOR1,
COLOR2,
COLOR3
COLOR3,
DEPTH
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ public Builder showSun(boolean show) {
}

/**
* Sets the <code>Skybox</code> intensity when no {@link IndirectLight} is set
* Sets the <code>Skybox</code> intensity when no {@link IndirectLight} is set on the
* {@link Scene}.
*
* <p>This call is ignored when an {@link IndirectLight} is set, otherwise it is used in
* its place.</p>
* <p>This call is ignored when an {@link IndirectLight} is set on the {@link Scene}, and
* the intensity of the {@link IndirectLight} is used instead.</p>
*
* @param envIntensity Scale factor applied to the skybox texel values such that
* the result is in <i>lux</i>, or <i>lumen/m^2</i> (default = 30000)
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.9.22
VERSION_NAME=1.9.23

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

Expand Down
2 changes: 1 addition & 1 deletion docs/Materials.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@
**getWorldNormalVector()** | float3 | Normalized normal in world space, after bump mapping (must be used after `prepareMaterial()`)
**getWorldGeometricNormalVector()** | float3 | Normalized normal in world space, before bump mapping (can be used before `prepareMaterial()`)
**getWorldReflectedVector()** | float3 | Reflection of the view vector about the normal (must be used after `prepareMaterial()`)
**getNormalizedViewportCoord()** | float2 | Normalized viewport position (i.e. clip-space position normalized to [0, 1], can be used before `prepareMaterial()`)
**getNormalizedViewportCoord()** | float3 | Normalized viewport position (i.e. NDC coordinates normalized to [0, 1], can be used before `prepareMaterial()`)
**getNdotV()** | float | The result of `dot(normal, view)`, always strictly greater than 0 (must be used after `prepareMaterial()`)
**getColor()** | float4 | Interpolated color of the fragment, if the color attribute is required
**getUV0()** | float2 | First interpolated set of UV coordinates, only available if the uv0 attribute is required
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/include/backend/TargetBufferInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class TargetBufferInfo {

class MRT {
public:
static constexpr int TARGET_COUNT = 4;
static constexpr int MAX_SUPPORTED_RENDER_TARGET_COUNT = 4;

private:
TargetBufferInfo mInfos[TARGET_COUNT];
TargetBufferInfo mInfos[MAX_SUPPORTED_RENDER_TARGET_COUNT];

public:
TargetBufferInfo const& operator[](size_t i) const noexcept {
Expand Down
16 changes: 9 additions & 7 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@
mContext->bufferPool->gc();

// If we acquired a drawable for this frame, ensure that we release it here.
mContext->currentDrawSwapChain->releaseDrawable();
if (mContext->currentDrawSwapChain) {
mContext->currentDrawSwapChain->releaseDrawable();
}

CVMetalTextureCacheFlush(mContext->textureCache, 0);

Expand Down Expand Up @@ -270,12 +272,12 @@
uint8_t samples, backend::MRT color,
TargetBufferInfo depth, TargetBufferInfo stencil) {

MetalRenderTarget::Attachment colorAttachments[4] = {{ 0 }};
for (size_t i = 0; i < 4; i++) {
MetalRenderTarget::Attachment colorAttachments[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT] = {{ nil }};
for (size_t i = 0; i < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT; i++) {
const auto& buffer = color[i];
if (!buffer.handle) {
ASSERT_POSTCONDITION(none(targetBufferFlags & getMRTColorFlag(i)),
"The COLOR%d flag was specified, but no color texture provided.", i);
"The COLOR%u flag was specified, but no color texture provided.", i);
continue;
}

Expand All @@ -288,7 +290,7 @@
colorAttachments[i].layer = color[i].layer;
}

MetalRenderTarget::Attachment depthAttachment = { 0 };
MetalRenderTarget::Attachment depthAttachment = { nil };
if (depth.handle) {
auto depthTexture = handle_cast<MetalTexture>(mHandleMap, depth.handle);
ASSERT_PRECONDITION(depthTexture->texture,
Expand Down Expand Up @@ -1155,8 +1157,8 @@
ASSERT_PRECONDITION(program->isValid, "Attempting to draw with an invalid Metal program.");

// Pipeline state
MTLPixelFormat colorPixelFormat[4] = { MTLPixelFormatInvalid };
for (size_t i = 0; i < 4; i++) {
MTLPixelFormat colorPixelFormat[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT] = { MTLPixelFormatInvalid };
for (size_t i = 0; i < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT; i++) {
const auto& attachment = mContext->currentRenderTarget->getDrawColorAttachment(i);
if (!attachment) {
continue;
Expand Down
6 changes: 3 additions & 3 deletions filament/backend/src/metal/MetalHandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class MetalRenderTarget : public HwRenderTarget {
};

MetalRenderTarget(MetalContext* context, uint32_t width, uint32_t height, uint8_t samples,
Attachment colorAttachments[MRT::TARGET_COUNT], Attachment depthAttachment);
Attachment colorAttachments[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT], Attachment depthAttachment);
explicit MetalRenderTarget(MetalContext* context)
: HwRenderTarget(0, 0), context(context), defaultRenderTarget(true) {}

Expand All @@ -248,11 +248,11 @@ class MetalRenderTarget : public HwRenderTarget {
bool defaultRenderTarget = false;
uint8_t samples = 1;

Attachment color[MRT::TARGET_COUNT] = {};
Attachment color[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT] = {};
Attachment depth = {};

// "Sidecar" textures used to implement automatic MSAA resolve.
id<MTLTexture> multisampledColor[MRT::TARGET_COUNT] = { 0 };
id<MTLTexture> multisampledColor[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT] = { 0 };
id<MTLTexture> multisampledDepth = nil;
};

Expand Down
10 changes: 5 additions & 5 deletions filament/backend/src/metal/MetalHandles.mm
Original file line number Diff line number Diff line change
Expand Up @@ -701,13 +701,13 @@ static MTLPixelFormat decidePixelFormat(id<MTLDevice> device, TextureFormat form
}

MetalRenderTarget::MetalRenderTarget(MetalContext* context, uint32_t width, uint32_t height,
uint8_t samples, Attachment colorAttachments[MRT::TARGET_COUNT], Attachment depthAttachment) :
uint8_t samples, Attachment colorAttachments[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT], Attachment depthAttachment) :
HwRenderTarget(width, height), context(context), samples(samples) {
// If we were given a single-sampled texture but the samples parameter is > 1, we create
// multisampled sidecar textures and do a resolve automatically.
const bool msaaResolve = samples > 1;

for (size_t i = 0; i < MRT::TARGET_COUNT; i++) {
for (size_t i = 0; i < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT; i++) {
if (!colorAttachments[i]) {
continue;
}
Expand Down Expand Up @@ -748,7 +748,7 @@ static MTLPixelFormat decidePixelFormat(id<MTLDevice> device, TextureFormat form

const auto discardFlags = params.flags.discardEnd;

for (size_t i = 0; i < MRT::TARGET_COUNT; i++) {
for (size_t i = 0; i < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT; i++) {
Attachment attachment = getDrawColorAttachment(i);
if (!attachment) {
continue;
Expand Down Expand Up @@ -807,7 +807,7 @@ static MTLPixelFormat decidePixelFormat(id<MTLDevice> device, TextureFormat form
}

MetalRenderTarget::Attachment MetalRenderTarget::getDrawColorAttachment(size_t index) {
assert_invariant(index < MRT::TARGET_COUNT);
assert_invariant(index < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT);
Attachment result = color[index];
if (index == 0 && defaultRenderTarget) {
assert_invariant(context->currentDrawSwapChain);
Expand All @@ -817,7 +817,7 @@ static MTLPixelFormat decidePixelFormat(id<MTLDevice> device, TextureFormat form
}

MetalRenderTarget::Attachment MetalRenderTarget::getReadColorAttachment(size_t index) {
assert_invariant(index < MRT::TARGET_COUNT);
assert_invariant(index < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT);
Attachment result = color[index];
if (index == 0 && defaultRenderTarget) {
assert_invariant(context->currentReadSwapChain);
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/src/metal/MetalState.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ struct PipelineState {
id<MTLFunction> vertexFunction = nil; // 8 bytes
id<MTLFunction> fragmentFunction = nil; // 8 bytes
VertexDescription vertexDescription; // 528 bytes
MTLPixelFormat colorAttachmentPixelFormat[4] = { MTLPixelFormatInvalid }; // 32 bytes
MTLPixelFormat colorAttachmentPixelFormat[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT] = { MTLPixelFormatInvalid }; // 32 bytes
MTLPixelFormat depthAttachmentPixelFormat = MTLPixelFormatInvalid; // 8 bytes
NSUInteger sampleCount = 1; // 8 bytes
BlendState blendState; // 56 bytes
Expand All @@ -228,7 +228,7 @@ struct PipelineState {
this->vertexFunction == rhs.vertexFunction &&
this->fragmentFunction == rhs.fragmentFunction &&
this->vertexDescription == rhs.vertexDescription &&
std::equal(this->colorAttachmentPixelFormat, this->colorAttachmentPixelFormat + 4,
std::equal(this->colorAttachmentPixelFormat, this->colorAttachmentPixelFormat + MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT,
rhs.colorAttachmentPixelFormat) &&
this->depthAttachmentPixelFormat == rhs.depthAttachmentPixelFormat &&
this->sampleCount == rhs.sampleCount &&
Expand Down
1 change: 1 addition & 0 deletions filament/backend/src/opengl/OpenGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ OpenGLContext::OpenGLContext() noexcept {
// On Adreno (As of 3/20) timer query seem to return the CPU time, not the
// GPU time.
bugs.dont_use_timer_query = true;
bugs.disable_sidecar_blit_into_texture_array = true;
} else if (strstr(renderer, "Mali")) {
bugs.vao_doesnt_store_element_array_buffer_binding = true;
if (strstr(renderer, "Mali-T")) {
Expand Down
4 changes: 4 additions & 0 deletions filament/backend/src/opengl/OpenGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class OpenGLContext {

// Some drivers don't implement timer queries correctly
bool dont_use_timer_query = false;

// Some drivers can't blit from a sidecar renderbuffer into a layer of a texture array.
// This technique is used for VSM with MSAA turned on.
bool disable_sidecar_blit_into_texture_array = false;
} bugs;

// state getters -- as needed.
Expand Down
17 changes: 13 additions & 4 deletions filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,17 @@ void OpenGLDriver::framebufferTexture(backend::TargetBufferInfo const& binfo,
attachmentTypeNotSupportedByMSRTT = true;
}

// There's a bug with certain drivers preventing us from emulating
// EXT_multisampled_render_to_texture when the texture is a TEXTURE_2D_ARRAY, so we'll simply
// fall back to non-MSAA rendering.
const bool disableMultisampling =
gl.bugs.disable_sidecar_blit_into_texture_array &&
rt->gl.samples > 1 && t->samples <= 1 &&
target == GL_TEXTURE_2D_ARRAY;

if (rt->gl.samples <= 1 ||
(rt->gl.samples > 1 && t->samples > 1 && gl.features.multisample_texture)) {
(rt->gl.samples > 1 && t->samples > 1 && gl.features.multisample_texture) ||
disableMultisampling) {
// on GL3.2 / GLES3.1 and above multisample is handled when creating the texture.
// If multisampled textures are not supported and we end-up here, things should
// still work, albeit without MSAA.
Expand Down Expand Up @@ -1170,16 +1179,16 @@ void OpenGLDriver::createRenderTargetR(Handle<HwRenderTarget> rth,
rt->targets = targets;

if (any(targets & TargetBufferFlags::COLOR_ALL)) {
GLenum bufs[4] = { GL_NONE };
for (size_t i = 0; i < 4; i++) {
GLenum bufs[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT] = { GL_NONE };
for (size_t i = 0; i < MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT; i++) {
if (any(targets & getMRTColorFlag(i))) {
rt->gl.color[i].texture = handle_cast<GLTexture*>(color[i].handle);
rt->gl.color[i].level = color[i].level;
framebufferTexture(color[i], rt, GL_COLOR_ATTACHMENT0 + i);
bufs[i] = GL_COLOR_ATTACHMENT0 + i;
}
}
glDrawBuffers(4, bufs);
glDrawBuffers(MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT, bufs);
CHECK_GL_ERROR(utils::slog.e)
}

Expand Down
4 changes: 2 additions & 2 deletions filament/backend/src/vulkan/VulkanBinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class VulkanBinder {
public:
static constexpr uint32_t UBUFFER_BINDING_COUNT = Program::UNIFORM_BINDING_COUNT;
static constexpr uint32_t SAMPLER_BINDING_COUNT = backend::MAX_SAMPLER_COUNT;
static constexpr uint32_t TARGET_BINDING_COUNT = MRT::TARGET_COUNT;
static constexpr uint32_t TARGET_BINDING_COUNT = MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT;
static constexpr uint32_t SHADER_MODULE_COUNT = 2;
static constexpr uint32_t VERTEX_ATTRIBUTE_COUNT = backend::MAX_VERTEX_ATTRIBUTE_COUNT;

Expand Down Expand Up @@ -234,7 +234,7 @@ class VulkanBinder {
VkDescriptorImageInfo mDescriptorInputAttachments[TARGET_BINDING_COUNT];
VkWriteDescriptorSet mDescriptorWrites[
UBUFFER_BINDING_COUNT + SAMPLER_BINDING_COUNT + TARGET_BINDING_COUNT];
VkPipelineColorBlendAttachmentState mColorBlendAttachments[MRT::TARGET_COUNT];
VkPipelineColorBlendAttachmentState mColorBlendAttachments[MRT::MAX_SUPPORTED_RENDER_TARGET_COUNT];

// Current bindings are divided into two "keys" which are composed of a mix of actual values
// (e.g., blending is OFF) and weak references to Vulkan objects (e.g., shader programs and
Expand Down
Loading

0 comments on commit 4388e81

Please sign in to comment.