Skip to content

Commit

Permalink
Merge branch 'rc/1.9.9' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Nov 16, 2020
2 parents 06d9183 + 419d68d commit cc9e05e
Show file tree
Hide file tree
Showing 48 changed files with 15,549 additions and 10,635 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.8'
implementation 'com.google.android.filament:filament-android:1.9.9'
}
```

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.8'
pod 'Filament', '~> 1.9.9'
```

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

## Next release (main branch)

## v1.9.9

- 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

## v1.9.8

- Fix a few Fence-related bugs
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ buildscript {
// Our minSdkVersion is 19.
ext.versions = [
'minSdk': 19,
'targetSdk': 29,
'compileSdk': 29,
'targetSdk': 30,
'compileSdk': 30,
'kotlin': '1.4.10',
'buildTools': '30.0.1',
'buildTools': '30.0.2',
'ndk': '21.3.6528147'
]

Expand All @@ -78,7 +78,7 @@ buildscript {
]

dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
}

Expand Down
2 changes: 1 addition & 1 deletion android/filament-android/src/main/cpp/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Java_com_google_android_filament_Material_nGetBlendingMode(JNIEnv*, jclass,

extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetRefraction(JNIEnv*, jclass,
Java_com_google_android_filament_Material_nGetRefractionMode(JNIEnv*, jclass,
jlong nativeMaterial) {
Material* material = (Material*) nativeMaterial;
return (jint)material->getRefractionMode();
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.8
VERSION_NAME=1.9.9

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

Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jan 10 16:04:09 PST 2020
#Thu Nov 05 09:33:02 PST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
1 change: 1 addition & 0 deletions filament/backend/include/backend/DriverEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace backend {
static constexpr uint64_t SWAP_CHAIN_CONFIG_TRANSPARENT = 0x1;
static constexpr uint64_t SWAP_CHAIN_CONFIG_READABLE = 0x2;
static constexpr uint64_t SWAP_CHAIN_CONFIG_ENABLE_XCB = 0x4;
static constexpr uint64_t SWAP_CHAIN_CONFIG_APPLE_CVPIXELBUFFER = 0x8;

static constexpr size_t MAX_VERTEX_ATTRIBUTE_COUNT = 16; // This is guaranteed by OpenGL ES.
static constexpr size_t MAX_SAMPLER_COUNT = 16; // Matches the Adreno Vulkan driver.
Expand Down
3 changes: 2 additions & 1 deletion filament/backend/include/private/backend/Program.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Program {

struct Sampler {
utils::CString name = {}; // name of the sampler in the shader
size_t binding = 0; // binding point of the sampler in the shader
uint16_t binding = 0; // binding point of the sampler in the shader
bool strict = false; // if true, this sampler must always have a bound texture
};

using SamplerGroupInfo = std::array<std::vector<Sampler>, SAMPLER_BINDING_COUNT>;
Expand Down
24 changes: 2 additions & 22 deletions filament/backend/src/metal/MetalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ struct MetalContext {
id<MTLCommandBuffer> pendingCommandBuffer = nullptr;
id<MTLRenderCommandEncoder> currentRenderPassEncoder = nullptr;

// These two fields store a callback and user data to notify the client that a frame is ready
// for presentation.
// If frameFinishedCallback is nullptr, then the Metal backend automatically calls
// presentDrawable when the frame is commited.
// Otherwise, the Metal backend will not automatically present the frame. Instead, clients bear
// the responsibility of presenting the frame by calling the PresentCallable object.
backend::FrameFinishedCallback frameFinishedCallback = nullptr;
void* frameFinishedUserData = nullptr;

// Tracks resources used by command buffers.
MetalResourceTracker resourceTracker;

Expand All @@ -75,11 +66,8 @@ struct MetalContext {

MetalBufferPool* bufferPool;

// Surface-related properties.
MetalSwapChain* currentSurface = nullptr;
id<CAMetalDrawable> currentDrawable = nil;
id<MTLTexture> currentDepthTexture = nil;
id<MTLTexture> headlessDrawable = nil;
MetalSwapChain* currentDrawSwapChain = nil;
MetalSwapChain* currentReadSwapChain = nil;

// External textures.
CVMetalTextureCacheRef textureCache = nullptr;
Expand All @@ -98,14 +86,6 @@ struct MetalContext {
TimerQueryInterface* timerQueryImpl;
};

// Acquire the current surface's CAMetalDrawable for the current frame if it has not already been
// acquired. This method stores it in the context's currentDrawable field and returns the
// drawable's texture.
// For headless swapchains a new texture is created.
id<MTLTexture> acquireDrawable(MetalContext* context);

id<MTLTexture> acquireDepthTexture(MetalContext* context);

id<MTLCommandBuffer> getPendingCommandBuffer(MetalContext* context);

void submitPendingCommands(MetalContext* context);
Expand Down
88 changes: 0 additions & 88 deletions filament/backend/src/metal/MetalContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,94 +24,6 @@
namespace backend {
namespace metal {

void presentDrawable(bool presentFrame, void* user) {
// CFBridgingRelease here is used to balance the CFBridgingRetain inside of acquireDrawable.
id<CAMetalDrawable> drawable = (id<CAMetalDrawable>) CFBridgingRelease(user);
if (presentFrame) {
[drawable present];
}
// The drawable will be released here when the "drawable" variable goes out of scope.
}

id<MTLTexture> acquireDrawable(MetalContext* context) {
if (context->currentDrawable) {
return context->currentDrawable.texture;
}
if (context->currentSurface->isHeadless()) {
if (context->headlessDrawable) {
return context->headlessDrawable;
}
// For headless surfaces we construct a "fake" drawable, which is simply a renderable
// texture.
MTLTextureDescriptor* textureDescriptor = [MTLTextureDescriptor new];
textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
textureDescriptor.width = context->currentSurface->getSurfaceWidth();
textureDescriptor.height = context->currentSurface->getSurfaceHeight();
// Specify MTLTextureUsageShaderRead so the headless surface can be blitted from.
textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
#if defined(IOS)
textureDescriptor.storageMode = MTLStorageModeShared;
#else
textureDescriptor.storageMode = MTLStorageModeManaged;
#endif
context->headlessDrawable = [context->device newTextureWithDescriptor:textureDescriptor];
return context->headlessDrawable;
}

context->currentDrawable = [context->currentSurface->getLayer() nextDrawable];

if (context->frameFinishedCallback) {
id<CAMetalDrawable> drawable = context->currentDrawable;
backend::FrameFinishedCallback callback = context->frameFinishedCallback;
void* userData = context->frameFinishedUserData;
// This block strongly captures drawable to keep it alive until the handler executes.
[getPendingCommandBuffer(context) addScheduledHandler:^(id<MTLCommandBuffer> cb) {
// CFBridgingRetain is used here to give the drawable a +1 retain count before
// casting it to a void*.
PresentCallable callable(presentDrawable, (void*) CFBridgingRetain(drawable));
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
callback(callable, userData);
});
}];
}
ASSERT_POSTCONDITION(context->currentDrawable != nil, "Could not obtain drawable.");
return context->currentDrawable.texture;
}

id<MTLTexture> acquireDepthTexture(MetalContext* context) {
if (context->currentDepthTexture) {
// If the surface size has changed, we'll need to allocate a new depth texture.
if (context->currentDepthTexture.width != context->currentSurface->getSurfaceWidth() ||
context->currentDepthTexture.height != context->currentSurface->getSurfaceHeight()) {
context->currentDepthTexture = nil;
} else {
return context->currentDepthTexture;
}
}

const MTLPixelFormat depthFormat =
#if defined(IOS)
MTLPixelFormatDepth32Float;
#else
context->device.depth24Stencil8PixelFormatSupported ?
MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float;
#endif

const NSUInteger width = context->currentSurface->getSurfaceWidth();
const NSUInteger height = context->currentSurface->getSurfaceHeight();
MTLTextureDescriptor* descriptor =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:depthFormat
width:width
height:height
mipmapped:NO];
descriptor.usage = MTLTextureUsageRenderTarget;
descriptor.resourceOptions = MTLResourceStorageModePrivate;

context->currentDepthTexture = [context->device newTextureWithDescriptor:descriptor];

return context->currentDepthTexture;
}

id<MTLCommandBuffer> getPendingCommandBuffer(MetalContext* context) {
if (context->pendingCommandBuffer) {
return context->pendingCommandBuffer;
Expand Down
Loading

0 comments on commit cc9e05e

Please sign in to comment.