Skip to content

Commit

Permalink
Merge branch 'rc/1.9.12' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Feb 16, 2021
2 parents f222f1b + 62b50eb commit b96bc30
Show file tree
Hide file tree
Showing 47 changed files with 608 additions and 225 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.9.11'
implementation 'com.google.android.filament:filament-android:1.9.12'
}
```

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.11'
pod 'Filament', '~> 1.9.12'
```

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

## Next release (main branch)

## v1.9.12

- engine: Fixed GL errors seen with MSAA on WebGL.
Warning: this can affect multisampling behavior on devices that do not support OpenGL ES 3.1
- materials: Added new `getVertexIndex()` API for vertex shaders.
- samples: RenderTarget demo now disables post-processing in offscreen view and creates depth attachment.
- gltfio: Fix, animation jolt when time delta is very small.

## v1.9.11

- Added support for Apple silicon Macs. build.sh can now be used to build on either Apple silicon or
Expand Down Expand Up @@ -55,12 +63,12 @@ A new header is inserted each time a *tag* is created.

## v1.9.9

- Vulkan: internal robustness improvements
- Metal: Support CVPixelBuffer SwapChains
- Metal: Support copyFrame
- Vulkan: internal robustness improvements.
- Metal: Support CVPixelBuffer SwapChains.
- Metal: Support copyFrame.
- Fix clear behavior with RenderTarget API.
- Fix GetRefractionMode JNI binding
- Additional fixes for Fence bug
- Fix GetRefractionMode JNI binding.
- Additional fixes for Fence bug.

## v1.9.8

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ buildscript {
'minSdk': 19,
'targetSdk': 30,
'compileSdk': 30,
'kotlin': '1.4.21',
'kotlin': '1.4.30',
'buildTools': '30.0.3',
'ndk': '22.0.7026061'
]
Expand Down
5 changes: 5 additions & 0 deletions android/filament-android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ add_library(bluevk STATIC IMPORTED)
set_target_properties(bluevk PROPERTIES IMPORTED_LOCATION
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbluevk.a)

add_library(vkshaders STATIC IMPORTED)
set_target_properties(vkshaders PROPERTIES IMPORTED_LOCATION
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libvkshaders.a)

add_library(smol-v STATIC IMPORTED)
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
Expand Down Expand Up @@ -101,6 +105,7 @@ target_link_libraries(filament-jni
PRIVATE utils
$<$<STREQUAL:${FILAMENT_ENABLE_MATDBG},ON>:matdbg>
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:bluevk>
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:vkshaders>
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:smol-v>
)

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.11
VERSION_NAME=1.9.12

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

Expand Down
5 changes: 5 additions & 0 deletions build/android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ elif [[ "$LC_UNAME" == "darwin" ]]; then
fi
source `dirname $0`/../common/build-common.sh

# For continuous builds, do not exclude Vulkan.
if [[ "$TARGET" == "continuous" ]]; then
EXCLUDE_VULKAN=
fi

# Only update and install the NDK if necessary, as this can be slow
ndk_side_by_side="${ANDROID_HOME}/ndk/"
if [[ -d $ndk_side_by_side ]]; then
Expand Down
1 change: 1 addition & 0 deletions docs/Materials.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@
**getCustom0()** to **getCustom7()** | float4 | Custom vertex attribute
**getWorldFromModelMatrix()** | float4x4 | Matrix that converts from model (object) space to world space
**getWorldFromModelNormalMatrix()** | float3x3 | Matrix that converts normals from model (object) space to world space
**getVertexIndex()** | int | Index of the current vertex

### Fragment only

Expand Down
45 changes: 44 additions & 1 deletion filament/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ if (FILAMENT_SUPPORTS_VULKAN)
list(APPEND SRCS
src/vulkan/VulkanBinder.cpp
src/vulkan/VulkanBinder.h
src/vulkan/VulkanBlitter.cpp
src/vulkan/VulkanBlitter.h
src/vulkan/VulkanBuffer.cpp
src/vulkan/VulkanBuffer.h
src/vulkan/VulkanContext.cpp
Expand Down Expand Up @@ -176,6 +178,7 @@ add_definitions(-DSYSTRACE_TAG=2 )
# specify where our headers are
include_directories(${PUBLIC_HDR_DIR})
include_directories(src)
include_directories(${GENERATION_ROOT})

# we're building a library
add_library(${TARGET} STATIC ${PRIVATE_HDRS} ${PUBLIC_HDRS} ${SRCS})
Expand All @@ -190,6 +193,45 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
add_library(${TARGET}_headers INTERFACE)
target_include_directories(${TARGET}_headers INTERFACE ${PUBLIC_HDR_DIR})

# ==================================================================================================
# Build SPIRV snippets used by the Vulkan backend.
# ==================================================================================================

set(VKSHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/vkshaders")

file(MAKE_DIRECTORY ${VKSHADERS_DIR})

get_resgen_vars(${VKSHADERS_DIR} vkshaders)

set(VKSHADER_BINS)
function(build_vkshader SOURCE TARGET_PATH)
set(SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan/${SOURCE}")
set(VKSHADER_BINS ${VKSHADER_BINS} ${TARGET_PATH} PARENT_SCOPE)
add_custom_command(
OUTPUT ${TARGET_PATH}
COMMAND matc --raw -o ${TARGET_PATH} ${SOURCE_PATH}
MAIN_DEPENDENCY ${SOURCE_PATH}
DEPENDS matc ${SOURCE_PATH}
COMMENT "Building SPIR-V")
endfunction()
build_vkshader("BlitColor.vs" "BlitColorVs.spv")
build_vkshader("BlitColor.fs" "BlitColorFs.spv")

add_custom_command(
OUTPUT ${RESGEN_OUTPUTS}
COMMAND resgen ${RESGEN_FLAGS} ${VKSHADER_BINS}
DEPENDS resgen ${VKSHADER_BINS}
COMMENT "Aggregating compiled VK shaders")

if (DEFINED RESGEN_SOURCE_FLAGS)
set_source_files_properties(${RESGEN_SOURCE} PROPERTIES COMPILE_FLAGS ${RESGEN_SOURCE_FLAGS})
endif()

set(DUMMY_SRC "${VKSHADERS_DIR}/dummy.c")
add_custom_command(OUTPUT ${DUMMY_SRC} COMMAND echo "//" > ${DUMMY_SRC})

add_library(vkshaders STATIC ${DUMMY_SRC} ${RESGEN_SOURCE})

# ==================================================================================================
# Dependencies
# ==================================================================================================
Expand All @@ -215,7 +257,7 @@ if(NOT IOS AND NOT ANDROID AND NOT WEBGL)
endif()

if (FILAMENT_SUPPORTS_VULKAN)
target_link_libraries(${TARGET} PUBLIC bluevk vkmemalloc)
target_link_libraries(${TARGET} PUBLIC bluevk vkmemalloc vkshaders)
endif()

if (FILAMENT_SUPPORTS_METAL)
Expand Down Expand Up @@ -284,6 +326,7 @@ target_link_libraries(${TARGET} PRIVATE
# ==================================================================================================
set(INSTALL_TYPE ARCHIVE)
install(TARGETS ${TARGET} ${INSTALL_TYPE} DESTINATION lib/${DIST_DIR})
install(TARGETS vkshaders ${INSTALL_TYPE} DESTINATION lib/${DIST_DIR})
install(DIRECTORY ${PUBLIC_HDR_DIR}/backend DESTINATION include)

# ==================================================================================================
Expand Down
5 changes: 5 additions & 0 deletions filament/backend/include/private/backend/DriverAPI.inc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ DECL_DRIVER_API_N(update2DImage,
uint32_t, height,
backend::PixelBufferDescriptor&&, data)

DECL_DRIVER_API_N(setMinMaxLevels,
backend::TextureHandle, th,
uint32_t, minLevel,
uint32_t, maxLevel)

DECL_DRIVER_API_N(update3DImage,
backend::TextureHandle, th,
uint32_t, level,
Expand Down
3 changes: 3 additions & 0 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@
scheduleDestroy(std::move(data));
}

void MetalDriver::setMinMaxLevels(Handle<HwTexture> th, uint32_t minLevel, uint32_t maxLevel) {
}

void MetalDriver::update3DImage(Handle<HwTexture> th, uint32_t level,
uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
uint32_t width, uint32_t height, uint32_t depth,
Expand Down
3 changes: 3 additions & 0 deletions filament/backend/src/noop/NoopDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ void NoopDriver::update2DImage(Handle<HwTexture> th,
scheduleDestroy(std::move(data));
}

void NoopDriver::setMinMaxLevels(Handle<HwTexture> th, uint32_t minLevel, uint32_t maxLevel) {
}

void NoopDriver::update3DImage(Handle<HwTexture> th,
uint32_t level, uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
uint32_t width, uint32_t height, uint32_t depth,
Expand Down
7 changes: 0 additions & 7 deletions filament/backend/src/opengl/OpenGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ OpenGLContext::OpenGLContext() noexcept {
}
} else if (strstr(renderer, "Intel")) {
bugs.vao_doesnt_store_element_array_buffer_binding = true;

// We have observed bloom flashing artifacts (as well as failure in test_FeedbackLoop) on a
// MacBook Air with an Intel GPU, as well as an Intel NUC Windows PC. For now we're assuming
// that all Intel GPU's cannot handle feedback loops properly.
// TODO: match a more specific string pattern after Intel discrete GPU's arrive.
bugs.disable_feedback_loops = true;

} else if (strstr(renderer, "PowerVR") || strstr(renderer, "Apple")) {
} else if (strstr(renderer, "Tegra") || strstr(renderer, "GeForce") || strstr(renderer, "NV")) {
} else if (strstr(renderer, "Vivante")) {
Expand Down
73 changes: 59 additions & 14 deletions filament/backend/src/opengl/OpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,35 +773,38 @@ void OpenGLDriver::framebufferTexture(backend::TargetBufferInfo const& binfo,
assert(rt->width <= valueForLevel(binfo.level, t->width) &&
rt->height <= valueForLevel(binfo.level, t->height));

// Declare a small mask of bits that will later be OR'd into the texture's resolve mask.
TargetBufferFlags resolveFlags = {};

GLRenderTarget::GL::RenderBuffer const* pRenderBuffer = nullptr;
switch (attachment) {
case GL_COLOR_ATTACHMENT0:
rt->gl.resolve |= TargetBufferFlags::COLOR0;
resolveFlags = TargetBufferFlags::COLOR0;
pRenderBuffer = &rt->gl.color[0];
break;
case GL_COLOR_ATTACHMENT1:
rt->gl.resolve |= TargetBufferFlags::COLOR1;
resolveFlags = TargetBufferFlags::COLOR1;
pRenderBuffer = &rt->gl.color[1];
break;
case GL_COLOR_ATTACHMENT2:
rt->gl.resolve |= TargetBufferFlags::COLOR2;
resolveFlags = TargetBufferFlags::COLOR2;
pRenderBuffer = &rt->gl.color[2];
break;
case GL_COLOR_ATTACHMENT3:
rt->gl.resolve |= TargetBufferFlags::COLOR3;
resolveFlags = TargetBufferFlags::COLOR3;
pRenderBuffer = &rt->gl.color[3];
break;
case GL_DEPTH_ATTACHMENT:
rt->gl.resolve |= TargetBufferFlags::DEPTH;
resolveFlags = TargetBufferFlags::DEPTH;
pRenderBuffer = &rt->gl.depth;
break;
case GL_STENCIL_ATTACHMENT:
rt->gl.resolve |= TargetBufferFlags::STENCIL;
resolveFlags = TargetBufferFlags::STENCIL;
pRenderBuffer = &rt->gl.stencil;
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
rt->gl.resolve |= TargetBufferFlags::DEPTH;
rt->gl.resolve |= TargetBufferFlags::STENCIL;
resolveFlags = TargetBufferFlags::DEPTH;
resolveFlags |= TargetBufferFlags::STENCIL;
pRenderBuffer = &rt->gl.depth;
break;
default:
Expand Down Expand Up @@ -899,21 +902,41 @@ void OpenGLDriver::framebufferTexture(backend::TargetBufferInfo const& binfo,
}
} else
#endif
{ // here we emulate ext.EXT_multisampled_render_to_texture
if (!any(t->usage & TextureUsage::SAMPLEABLE) && t->samples > 1) {
assert(rt->gl.samples > 1);
assert(glIsRenderbuffer(t->gl.id));

// Create a sidecar multi-sampled renderbuffer,
// which is where drawing will actually take place, make that our attachment.
// Since this attachment is not sampleable, there is no need for a sidecar or explicit
// resolve. We can simply render directly into the renderbuffer that was allocated in
// createTexture.
gl.bindFramebuffer(GL_FRAMEBUFFER, rt->gl.fbo);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, t->gl.id);

// Clear the resolve bit for this particular attachment. Note that other attachment(s)
// might be sampleable, so this does not necessarily prevent the resolve from occuring.
resolveFlags = TargetBufferFlags::NONE;

} else {
assert(rt->gl.samples > 1);
assert(pRenderBuffer->rb == 0);

// Here we emulate EXT_multisampled_render_to_texture.
//
// This attachment needs to be explicitly resolved in endRenderPass().
// The first step is to create a sidecar multi-sampled renderbuffer, which is where drawing
// will actually take place, and use that in lieu of the requested attachment.
// The sidecar will be destroyed when the render target handle is destroyed.
gl.bindFramebuffer(GL_FRAMEBUFFER, rt->gl.fbo);
glGenRenderbuffers(1, &pRenderBuffer->rb);
renderBufferStorage(pRenderBuffer->rb,
t->gl.internalFormat, rt->width, rt->height, rt->gl.samples);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, pRenderBuffer->rb);

// We also need a "read" sidecar fbo, used later for the resolve, which takes place in
// endRenderPass().
// Here we lazily create a "read" sidecar FBO, used later as the resolve target. Note that
// at least one of the render target's attachments needs to be both MSAA and sampleable in
// order for fbo_read to be created. If we never bother to create it, then endRenderPass()
// will skip doing an explicit resolve.
if (!rt->gl.fbo_read) {
glGenFramebuffers(1, &rt->gl.fbo_read);
}
Expand Down Expand Up @@ -947,10 +970,13 @@ void OpenGLDriver::framebufferTexture(backend::TargetBufferInfo const& binfo,
CHECK_GL_ERROR(utils::slog.e)
}

rt->gl.resolve |= resolveFlags;

if (any(t->usage & TextureUsage::SAMPLEABLE)) {
// In a sense, drawing to a texture level is similar to calling setTextureData on it; in
// both cases, we update the base/max LOD to give shaders access to levels as they become
// available.
// available. Note that this can only expand the LOD range (never shrink it), and that
// users can override this range by calling setMinMaxLevels().
updateTextureLodRange(t, binfo.level);
}

Expand Down Expand Up @@ -1717,6 +1743,24 @@ void OpenGLDriver::update2DImage(Handle<HwTexture> th,
}
}

void OpenGLDriver::setMinMaxLevels(Handle<HwTexture> th, uint32_t minLevel, uint32_t maxLevel) {
DEBUG_MARKER()
auto& gl = mContext;

GLTexture* t = handle_cast<GLTexture *>(th);
bindTexture(OpenGLContext::MAX_TEXTURE_UNIT_COUNT - 1, t);
gl.activeTexture(OpenGLContext::MAX_TEXTURE_UNIT_COUNT - 1);

// Must fit within int8_t.
assert(minLevel <= 0x7f && maxLevel <= 0x7f);

t->gl.baseLevel = minLevel;
glTexParameteri(t->gl.target, GL_TEXTURE_BASE_LEVEL, t->gl.baseLevel);

t->gl.maxLevel = maxLevel; // NOTE: according to the GL spec, the default value of this 1000
glTexParameteri(t->gl.target, GL_TEXTURE_MAX_LEVEL, t->gl.maxLevel);
}

void OpenGLDriver::update3DImage(Handle<HwTexture> th,
uint32_t level, uint32_t xoffset, uint32_t yoffset, uint32_t zoffset,
uint32_t width, uint32_t height, uint32_t depth,
Expand Down Expand Up @@ -2675,6 +2719,7 @@ GLuint OpenGLDriver::getSamplerSlow(SamplerParams params) const noexcept {
glSamplerParameteri(s, GL_TEXTURE_WRAP_R, getWrapMode(params.wrapR));
glSamplerParameteri(s, GL_TEXTURE_COMPARE_MODE, getTextureCompareMode(params.compareMode));
glSamplerParameteri(s, GL_TEXTURE_COMPARE_FUNC, getTextureCompareFunc(params.compareFunc));

// TODO: Why does this fail with WebGL 2.0? The run-time check should suffice.
#if defined(GL_EXT_texture_filter_anisotropic) && !defined(__EMSCRIPTEN__)
auto& gl = mContext;
Expand Down
14 changes: 14 additions & 0 deletions filament/backend/src/vulkan/BlitColor.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 320 es
precision mediump float;

layout(set = 0, binding = 0, std140) uniform ParamsBlock {
float level;
} params;

uniform sampler2D tex;

layout(location = 0) out highp vec4 color;

void main() {
color = texelFetch(tex, ivec2(gl_FragCoord.xy), int(params.level));
}
Loading

0 comments on commit b96bc30

Please sign in to comment.