Skip to content

Commit

Permalink
Merge branch 'rc/1.36.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed May 15, 2023
2 parents 36c69dd + dfdf0db commit 56bf841
Show file tree
Hide file tree
Showing 92 changed files with 2,942 additions and 666 deletions.
1 change: 0 additions & 1 deletion NEW_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ 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.35.0'
implementation 'com.google.android.filament:filament-android:1.36.0'
}
```

Expand All @@ -50,7 +50,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.35.0'
pod 'Filament', '~> 1.36.0'
```

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

- engine: a local transform can now be supplied for each GPU instance [⚠️ **Recompile materials**]
- everything: Add limited support for OpenGL ES 2.0 devices. [⚠️ **Recompile Materials**]
- platform: New virtual on `OpenGLPlatform` to preserve ancillary buffers

## v1.35.0

- materials: Materials can now access up to 4 global `vec4` visible by all materials [⚠️ **Recompile Materials**]
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.35.0
VERSION_NAME=1.36.0

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ class MainActivity : Activity() {
private fun setupView() {
scene.skybox = Skybox.Builder().color(0.035f, 0.035f, 0.035f, 1.0f).build(engine)

// NOTE: Try to disable post-processing (tone-mapping, etc.) to see the difference
// view.isPostProcessingEnabled = false
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
// post-processing is not supported at feature level 0
view.isPostProcessingEnabled = false
} else {
// NOTE: Try to disable post-processing (tone-mapping, etc.) to see the difference
// view.isPostProcessingEnabled = false
}

// Tell the view which camera we want to use
view.camera = camera
Expand Down Expand Up @@ -155,7 +160,11 @@ class MainActivity : Activity() {
}

private fun loadMaterial() {
readUncompressedAsset("materials/baked_color.filamat").let {
var name = "materials/baked_color.filamat"
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
name = "materials/baked_color_es2.filamat"
}
readUncompressedAsset(name).let {
material = Material.Builder().payload(it, it.remaining()).build(engine)
}
}
Expand Down Expand Up @@ -305,7 +314,17 @@ class MainActivity : Activity() {
inner class SurfaceCallback : UiHelper.RendererCallback {
override fun onNativeWindowChanged(surface: Surface) {
swapChain?.let { engine.destroySwapChain(it) }
swapChain = engine.createSwapChain(surface, uiHelper.swapChainFlags)

// at feature level 0, we don't have post-processing, so we need to set
// the colorspace to sRGB (FIXME: it's not supported everywhere!)
var flags = uiHelper.swapChainFlags
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
if (SwapChain.isSRGBSwapChainSupported(engine)) {
flags = flags or SwapChain.CONFIG_SRGB_COLORSPACE
}
}

swapChain = engine.createSwapChain(surface, flags)
displayHelper.attach(renderer, surfaceView.display);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ material {
],

// This material disables all lighting
shadingModel : unlit,
shadingModel : unlit
}

fragment {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Simple unlit material that uses the colors associated with each vertex.
//
// This source material must be compiled to a binary material using the matc tool.
// The command used to compile this material is:
// matc -p mobile -a opengl -o app/src/main/assets/baked_color.filamat app/src/materials/baked_color.mat
//
// See build.gradle for an example of how to compile materials automatically
// Please refer to the documentation for more information about matc and the materials system.

material {
name : baked_color,

// Lists the required vertex attributes
// Here we only need a color (RGBA)
requires : [
color
],

// This material disables all lighting
shadingModel : unlit,
featureLevel : 0
}

fragment {
void material(inout MaterialInputs material) {
// You must always call the prepareMaterial() function
prepareMaterial(material);

// We set the material's color to the color interpolated from
// the model's vertices
material.baseColor = getColor();
}
}
26 changes: 26 additions & 0 deletions filament/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(PUBLIC_HDRS
include/filament/Frustum.h
include/filament/IndexBuffer.h
include/filament/IndirectLight.h
include/filament/InstanceBuffer.h
include/filament/LightManager.h
include/filament/Material.h
include/filament/MaterialInstance.h
Expand Down Expand Up @@ -67,6 +68,7 @@ set(SRCS
src/HwRenderPrimitiveFactory.cpp
src/IndexBuffer.cpp
src/IndirectLight.cpp
src/InstanceBuffer.cpp
src/LightManager.cpp
src/Material.cpp
src/MaterialInstance.cpp
Expand Down Expand Up @@ -108,6 +110,7 @@ set(SRCS
src/details/Fence.cpp
src/details/IndexBuffer.cpp
src/details/IndirectLight.cpp
src/details/InstanceBuffer.cpp
src/details/Material.cpp
src/details/MaterialInstance.cpp
src/details/MorphTargetBuffer.cpp
Expand Down Expand Up @@ -171,6 +174,7 @@ set(PRIVATE_HDRS
src/details/Fence.h
src/details/IndexBuffer.h
src/details/IndirectLight.h
src/details/InstanceBuffer.h
src/details/Material.h
src/details/MaterialInstance.h
src/details/MorphTargetBuffer.h
Expand Down Expand Up @@ -246,6 +250,11 @@ set(MATERIAL_SRCS
src/materials/vsmMipmap.mat
)

set(MATERIAL_ES2_SRCS
src/materials/defaultMaterial0.mat
src/materials/skybox0.mat
)

# Embed the binary resource blob for materials.
get_resgen_vars(${RESOURCE_DIR} materials)
list(APPEND PRIVATE_HDRS ${RESGEN_HEADER})
Expand Down Expand Up @@ -311,6 +320,23 @@ foreach (mat_src ${MATERIAL_SRCS})
list(APPEND MATERIAL_BINS ${output_path})
endforeach()

if (IS_MOBILE_TARGET AND FILAMENT_SUPPORTS_OPENGL)
foreach (mat_src ${MATERIAL_ES2_SRCS})
get_filename_component(localname "${mat_src}" NAME_WE)
get_filename_component(fullname "${mat_src}" ABSOLUTE)
set(output_path "${MATERIAL_DIR}/${localname}.filamat")

add_custom_command(
OUTPUT ${output_path}
COMMAND matc -a opengl -p ${MATC_TARGET} ${MATC_OPT_FLAGS} -o ${output_path} ${fullname}
MAIN_DEPENDENCY ${fullname}
DEPENDS matc
COMMENT "Compiling material ${mat_src} to ${output_path}"
)
list(APPEND MATERIAL_BINS ${output_path})
endforeach ()
endif ()

# Additional dependencies on included files for materials

add_custom_command(
Expand Down
3 changes: 2 additions & 1 deletion filament/backend/include/backend/DriverEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ static constexpr size_t CONFIG_SAMPLER_BINDING_COUNT = 4; // This is guarantee
* Defines the backend's feature levels.
*/
enum class FeatureLevel : uint8_t {
FEATURE_LEVEL_1 = 1, //!< OpenGL ES 3.0 features (default)
FEATURE_LEVEL_0 = 0, //!< OpenGL ES 2.0 features
FEATURE_LEVEL_1, //!< OpenGL ES 3.0 features (default)
FEATURE_LEVEL_2, //!< OpenGL ES 3.1 features + 16 textures units + cubemap arrays
FEATURE_LEVEL_3 //!< OpenGL ES 3.1 features + 31 textures units + cubemap arrays
};
Expand Down
24 changes: 24 additions & 0 deletions filament/backend/include/backend/Program.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ class Program {
ShaderStageFlags stageFlags = ShaderStageFlags::ALL_SHADER_STAGE_FLAGS;
};

struct Uniform {
utils::CString name; // full qualified name of the uniform field
uint16_t offset; // offset in 'uint32_t' into the uniform buffer
uint8_t size; // >1 for arrays
UniformType type; // uniform type
};

using UniformBlockInfo = std::array<utils::CString, UNIFORM_BINDING_COUNT>;
using UniformInfo = utils::FixedCapacityVector<Uniform>;
using SamplerGroupInfo = std::array<SamplerGroupData, SAMPLER_BINDING_COUNT>;
using ShaderBlob = utils::FixedCapacityVector<uint8_t>;
using ShaderSource = std::array<ShaderBlob, SHADER_TYPE_COUNT>;
Expand Down Expand Up @@ -78,6 +86,14 @@ class Program {
Program& uniformBlockBindings(
utils::FixedCapacityVector<std::pair<utils::CString, uint8_t>> const& uniformBlockBindings) noexcept;

// Note: This is only needed for GLES2.0, this is used to emulate UBO. This function tells
// the program everything it needs to know about the uniforms at a given binding
Program& uniforms(uint32_t index, UniformInfo const& uniforms) noexcept;

// Note: This is only needed for GLES2.0.
Program& attributes(
utils::FixedCapacityVector<std::pair<utils::CString, uint8_t>> attributes) noexcept;

// sets the 'bindingPoint' sampler group descriptor for this program.
// 'samplers' can be destroyed after this call.
// This effectively associates a set of (BindingPoints, index) to a texture unit in the shader.
Expand All @@ -103,6 +119,12 @@ class Program {
SamplerGroupInfo const& getSamplerGroupInfo() const { return mSamplerGroups; }
SamplerGroupInfo& getSamplerGroupInfo() { return mSamplerGroups; }

auto const& getBindingUniformInfo() const { return mBindingUniformInfo; }
auto& getBindingUniformInfo() { return mBindingUniformInfo; }

auto const& getAttributes() const { return mAttributes; }
auto& getAttributes() { return mAttributes; }

utils::CString const& getName() const noexcept { return mName; }
utils::CString& getName() noexcept { return mName; }

Expand All @@ -122,6 +144,8 @@ class Program {
utils::CString mName;
utils::Invocable<utils::io::ostream&(utils::io::ostream& out)> mLogger;
utils::FixedCapacityVector<SpecializationConstant> mSpecializationConstants;
utils::FixedCapacityVector<std::pair<utils::CString, uint8_t>> mAttributes;
std::array<UniformInfo, Program::UNIFORM_BINDING_COUNT> mBindingUniformInfo;
};

} // namespace filament::backend
Expand Down
13 changes: 13 additions & 0 deletions filament/backend/include/backend/platforms/OpenGLPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ class OpenGLPlatform : public Platform {
*/
virtual void destroySwapChain(SwapChain* swapChain) noexcept = 0;

/**
* Returns the set of buffers that must be preserved up to the call to commit().
* The default value is TargetBufferFlags::NONE.
* The color buffer is always preserved, however ancillary buffers, such as the depth buffer
* are generally discarded. The preserve flags can be used to make sure those ancillary
* buffers are preserved until the call to commit.
*
* @param swapChain
* @return buffer that must be preserved
* @see commit()
*/
virtual TargetBufferFlags getPreservedFlags(SwapChain* swapChain) noexcept;

/**
* Called by the driver to establish the default FBO. The default implementation returns 0.
* @return a GLuint casted to a uint32_t that is an OpenGL framebuffer object.
Expand Down
4 changes: 3 additions & 1 deletion filament/backend/include/backend/platforms/PlatformEGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ class PlatformEGL : public OpenGLPlatform {
bool OES_EGL_image_external_essl3 = false;
} gl;
struct {
bool KHR_no_config_context = false;
bool ANDROID_recordable = false;
bool KHR_create_context = false;
bool KHR_gl_colorspace = false;
bool KHR_no_config_context = false;
} egl;
} ext;

Expand Down
15 changes: 15 additions & 0 deletions filament/backend/src/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Program& Program::operator=(Program&& rhs) noexcept {
mShadersSource.operator=(std::move(rhs.mShadersSource));
mName.operator=(std::move(rhs.mName));
mLogger.operator=(std::move(rhs.mLogger));
mSpecializationConstants.operator=(std::move(rhs.mSpecializationConstants));
mBindingUniformInfo.operator=(std::move(rhs.mBindingUniformInfo));
return *this;
}

Expand Down Expand Up @@ -60,6 +62,19 @@ Program& Program::uniformBlockBindings(
return *this;
}

Program& Program::uniforms(uint32_t index, UniformInfo const& uniforms) noexcept {
assert_invariant(index < UNIFORM_BINDING_COUNT);
mBindingUniformInfo[index] = uniforms;
return *this;
}


Program& Program::attributes(
utils::FixedCapacityVector<std::pair<utils::CString, uint8_t>> attributes) noexcept {
mAttributes = std::move(attributes);
return *this;
}

Program& Program::setSamplerGroup(size_t bindingPoint, ShaderStageFlags stageFlags,
const Program::Sampler* samplers, size_t count) noexcept {
auto& groupData = mSamplerGroups[bindingPoint];
Expand Down
8 changes: 5 additions & 3 deletions filament/backend/src/opengl/GLUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ const char* getFramebufferStatus(GLenum status) noexcept {
case GL_FRAMEBUFFER_COMPLETE:
string = "GL_FRAMEBUFFER_COMPLETE";
break;
case GL_FRAMEBUFFER_UNDEFINED:
string = "GL_FRAMEBUFFER_UNDEFINED";
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
string = "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
break;
Expand All @@ -93,9 +90,14 @@ const char* getFramebufferStatus(GLenum status) noexcept {
case GL_FRAMEBUFFER_UNSUPPORTED:
string = "GL_FRAMEBUFFER_UNSUPPORTED";
break;
#ifndef FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2
case GL_FRAMEBUFFER_UNDEFINED:
string = "GL_FRAMEBUFFER_UNDEFINED";
break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
string = "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE";
break;
#endif
default:
break;
}
Expand Down
Loading

0 comments on commit 56bf841

Please sign in to comment.