Skip to content

Commit

Permalink
Merge branch 'main' into batch-defer
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSylvester committed Dec 6, 2024
2 parents 11d930f + 112edb6 commit fc85192
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: actionlint
additional_dependencies: [shellcheck-py]
- repo: https://github.com/nicklockwood/SwiftFormat
rev: "0.55.2"
rev: "0.55.3"
hooks:
- id: swiftformat
args: [--swiftversion, "5.8"]
Expand Down
3 changes: 2 additions & 1 deletion include/mbgl/vulkan/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Context final : public gfx::Context {
void enqueueDeletion(std::function<void(Context&)>&& function);
void submitOneTimeCommand(const std::function<void(const vk::UniqueCommandBuffer&)>& function) const;

void requestSurfaceUpdate() { surfaceUpdateRequested = true; }
void requestSurfaceUpdate(bool useDelay = true);

private:
struct FrameResources {
Expand Down Expand Up @@ -197,6 +197,7 @@ class Context final : public gfx::Context {
uint8_t frameResourceIndex = 0;
std::vector<FrameResources> frameResources;
bool surfaceUpdateRequested{false};
int32_t surfaceUpdateLatency{0};
int32_t currentFrameCount{0};

struct {
Expand Down
8 changes: 8 additions & 0 deletions platform/android/android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ target_include_directories(
${PROJECT_SOURCE_DIR}/src
)

# this is needed because Android is not officially supported
# https://discourse.cmake.org/t/error-when-crosscompiling-with-whole-archive-target-link/9394
# https://cmake.org/cmake/help/latest/release/3.24.html#generator-expressions
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE
"-Wl,--whole-archive <LIBRARY> -Wl,--no-whole-archive"
)
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED True)

find_package(curl CONFIG)

target_link_libraries(
Expand Down
4 changes: 2 additions & 2 deletions platform/android/buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object Versions {
const val ndkVersion ="27.0.12077973"
const val cmakeVersion = "3.18.1+"
const val ndkVersion = "27.0.12077973"
const val cmakeVersion = "3.24.0+"
}
2 changes: 2 additions & 0 deletions platform/ios/src/MLNCompassButton.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ - (void)showCompass:(BOOL)animated {

- (void)hideCompass:(BOOL)animated {
animated ? [self animateToAlpha:0] : [self setAlpha:0];
self.isAccessibilityElement = NO;
self.accessibilityElementsHidden = YES;
}

- (void)animateToAlpha:(CGFloat)alpha {
Expand Down
4 changes: 3 additions & 1 deletion src/mbgl/gl/upload_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
return;
}

overrideAttr->setDirty(false);
if (overrideAttr) {
overrideAttr->setDirty(false);
}

bindings[index] = {
/*.attribute = */ {defaultAttr.getDataType(), offset},
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/gl/vertex_attribute_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const std::vector<std::uint8_t>& VertexAttributeGL::getRaw(gfx::VertexAttribute&
for (std::size_t i = 0; i < count; ++i) {
if (!get(attr.get(i), type, outPtr)) {
// missing type conversion
assert(false);
std::fill(outPtr, outPtr + stride_, 0);
}
outPtr += stride_;
}
Expand Down
22 changes: 17 additions & 5 deletions src/mbgl/vulkan/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ void Context::submitOneTimeCommand(const std::function<void(const vk::UniqueComm
}
}

void Context::requestSurfaceUpdate(bool useDelay) {
if (surfaceUpdateRequested) {
if (!useDelay) {
surfaceUpdateLatency = 0;
}

return;
}

surfaceUpdateRequested = true;
surfaceUpdateLatency = useDelay ? backend.getMaxFrames() * 3 : 0;
}

void Context::waitFrame() const {
MLN_TRACE_FUNC();
const auto& device = backend.getDevice();
Expand Down Expand Up @@ -203,7 +216,7 @@ void Context::beginFrame() {
}
}

if (platformSurface && surfaceUpdateRequested) {
if (platformSurface && surfaceUpdateRequested && --surfaceUpdateLatency <= 0) {
renderableResource.recreateSwapchain();

// we wait for an idle device to recreate the swapchain
Expand Down Expand Up @@ -243,14 +256,13 @@ void Context::beginFrame() {
if (acquireImageResult.result == vk::Result::eSuccess) {
renderableResource.setAcquiredImageIndex(acquireImageResult.value);
} else if (acquireImageResult.result == vk::Result::eSuboptimalKHR) {
renderableResource.setAcquiredImageIndex(acquireImageResult.value);
requestSurfaceUpdate();
beginFrame();
return;
}

} catch (const vk::OutOfDateKHRError& e) {
// request an update and restart frame
requestSurfaceUpdate();
requestSurfaceUpdate(false);
beginFrame();
return;
}
Expand Down Expand Up @@ -310,7 +322,7 @@ void Context::submitFrame() {
requestSurfaceUpdate();
}
} catch (const vk::OutOfDateKHRError& e) {
requestSurfaceUpdate();
requestSurfaceUpdate(false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ android {

externalNativeBuild {
cmake {
version = "3.18.1+"
version = "3.24.0+"
path = file("../../../CMakeLists.txt")
}
}
Expand Down

0 comments on commit fc85192

Please sign in to comment.