Skip to content

Commit

Permalink
Merge pull request #547 from CesiumGS/update-native
Browse files Browse the repository at this point in the history
Update cesium-native, don't derive CesiumImpl from ReferenceCountedThreadSafe
  • Loading branch information
kring authored Jan 31, 2025
2 parents 8f09d36 + 9e24045 commit 852ebae
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Build~/Build~.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>Build</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
45 changes: 41 additions & 4 deletions native~/Shared/src/CesiumImpl.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
#pragma once

#include <CesiumUtility/ReferenceCounted.h>
#include <CesiumUtility/Assert.h>

#include <atomic>
#include <cstdint>
#include <type_traits>

namespace CesiumForUnityNative {

template <typename TDerived>
class CesiumImpl : public CesiumUtility::ReferenceCountedThreadSafe<TDerived> {
template <typename TDerived> class CesiumImpl {
public:
CesiumImpl() = default;
/**
* @brief Adds a counted reference to this object. Use
* {@link CesiumUtility::IntrusivePointer} instead of calling this method
* directly.
*/
void addReference() const /*noexcept*/ { ++this->_referenceCount; }

/**
* @brief Removes a counted reference from this object. When the last
* reference is removed, this method will delete this instance. Use
* {@link CesiumUtility::IntrusivePointer} instead of calling this method
* directly.
*/
void releaseReference() const /*noexcept*/ {
CESIUM_ASSERT(this->_referenceCount > 0);
const int32_t references = --this->_referenceCount;
if (references == 0) {
delete static_cast<const TDerived*>(this);
}
}

/**
* @brief Returns the current reference count of this instance.
*/
std::int32_t getReferenceCount() const noexcept {
return this->_referenceCount;
}

// Prevent copying of impl classes
CesiumImpl(CesiumImpl&&) = delete;
CesiumImpl(const CesiumImpl&) = delete;
CesiumImpl& operator=(CesiumImpl&&) = delete;
CesiumImpl& operator=(const CesiumImpl&) = delete;

private:
CesiumImpl() noexcept = default;
~CesiumImpl() noexcept { CESIUM_ASSERT(this->_referenceCount == 0); }

friend TDerived;

mutable std::atomic<std::int32_t> _referenceCount{0};
};

} // namespace CesiumForUnityNative
2 changes: 1 addition & 1 deletion native~/extern/cesium-native
Submodule cesium-native updated 515 files
6 changes: 3 additions & 3 deletions native~/vcpkg/ports/ktx/0005-no-vendored-libs.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d7ca937..ffcbe95 100644
index e99fb143..0f69adf7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1059,10 +1059,10 @@ endif()
# except for building the ktx library.
@@ -1071,10 +1071,10 @@ endif()
if((KTX_FEATURE_TOOLS OR KTX_FEATURE_TESTS) AND NOT TARGET fmt::fmt)
set(FMT_INSTALL OFF)
set(FMT_SYSTEM_HEADERS ON)
- add_subdirectory(other_projects/fmt)
+ find_package(fmt CONFIG REQUIRED)
Expand Down
22 changes: 22 additions & 0 deletions native~/vcpkg/ports/ktx/0006-fix-ios-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e99fb143..072ea889 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -489,7 +489,7 @@ macro(common_libktx_settings target enable_write library_type)
CXX_STANDARD_REQUIRED YES

)
- if(IOS)
+ if(0)
set_target_properties(${target} PROPERTIES
FRAMEWORK TRUE
)
@@ -1145,7 +1145,7 @@ endif()
# Use of this to install KHR/khr_df.h is due to CMake's failure to
# preserve the include source folder hierarchy.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/16739.
-if (IOS)
+if (0)
set_source_files_properties(
include/KHR/khr_df.h
PROPERTIES MACOSX_PACKAGE_LOCATION Headers/KHR
17 changes: 0 additions & 17 deletions native~/vcpkg/ports/ktx/CESIUM-0002-not-a-framework.patch

This file was deleted.

30 changes: 0 additions & 30 deletions native~/vcpkg/ports/ktx/CESIUM-0003-ios-normal-header-path.patch

This file was deleted.

15 changes: 6 additions & 9 deletions native~/vcpkg/ports/ktx/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
vcpkg_from_github(
vcpkg_from_git(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/KTX-Software
REF "v${VERSION}"
SHA512 5a89f8986464705ec36ac1becaddd0ff335e4c3c235468aaef0e963fcfeda4c0d669a086b91e61c16a3ae9e1fa5bf456dccf12cc65720e1a22e7cc0f30552541
HEAD_REF master
URL "https://github.com/KhronosGroup/KTX-Software.git"
REF 91ace88675ac59a97e55d0378a6602a9ae6b98bd
FETCH_REF "v${VERSION}"
HEAD_REF main
PATCHES
0001-Use-vcpkg-zstd.patch
0002-Fix-versioning.patch
0003-mkversion.patch
0004-quirks.patch
0005-no-vendored-libs.patch
0006-fix-ios-install.patch
CESIUM-0001-do-not-define-_DEBUG.patch
CESIUM-0002-not-a-framework.patch
CESIUM-0003-ios-normal-header-path.patch
)
file(REMOVE "${SOURCE_PATH}/other_include/zstd_errors.h")

Expand Down Expand Up @@ -50,8 +49,6 @@ vcpkg_cmake_configure(
-DKTX_FEATURE_STATIC_LIBRARY=${ENABLE_STATIC}
${FEATURE_OPTIONS}
${OPTIONS}
# Do not regenerate headers (needs more dependencies)
-DCMAKE_DISABLE_FIND_PACKAGE_Vulkan=1
DISABLE_PARALLEL_CONFIGURE
)

Expand Down
5 changes: 2 additions & 3 deletions native~/vcpkg/ports/ktx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "ktx",
"version-semver": "4.3.0-beta1",
"port-version": 1,
"version-semver": "4.3.2",
"description": [
"The Khronos KTX library and tools.",
"Functions for writing and reading KTX files, and instantiating OpenGL®, OpenGL ES™️ and Vulkan® textures from them."
Expand All @@ -23,7 +22,7 @@
"features": {
"tools": {
"description": "Build tools",
"supports": "!android",
"supports": "!android & !uwp",
"dependencies": [
"cxxopts",
"fmt"
Expand Down

0 comments on commit 852ebae

Please sign in to comment.