Skip to content

Commit

Permalink
rewrite loadinglayer completely to be blazingly fast
Browse files Browse the repository at this point in the history
  • Loading branch information
dankmeme01 committed Aug 6, 2024
1 parent 31c9fd5 commit 45b6caf
Show file tree
Hide file tree
Showing 12 changed files with 587 additions and 344 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE src/)
# make spng use miniz instead of zlib
target_compile_definitions(${PROJECT_NAME} PRIVATE SPNG_USE_MINIZ=1 SPNG_STATIC=1)

if (BLAZE_DEBUG)
target_compile_definitions(${PROJECT_NAME} PRIVATE BLAZE_DEBUG=1)
endif()

CPMAddPackage("gh:dankmeme01/asp2#7024af9")
CPMAddPackage("gh:dankmeme01/asp2#8e25afa")
CPMAddPackage(
NAME Boost
VERSION 1.84.0
Expand All @@ -54,6 +50,12 @@ CPMAddPackage(
OPTIONS "LIBDEFLATE_BUILD_SHARED_LIB OFF" "LIBDEFLATE_BUILD_GZIP OFF"
)

if (BLAZE_DEBUG)
target_compile_definitions(${PROJECT_NAME} PRIVATE BLAZE_DEBUG=1)
target_compile_definitions(asp PRIVATE _HAS_ITERATOR_DEBUGGING=0)
target_compile_definitions(simdutf PRIVATE _HAS_ITERATOR_DEBUGGING=0)
endif()

# Suppress some warnings
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(boost_container PRIVATE "-Wno-incompatible-pointer-types")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Note: all those numbers are on Windows. On other operating systems, the performa

## Credit

* [matcool](https://github.com/matcool) for [Fast Format](https://github.com/matcool/geode-mods/blob/main/fast-format/main.cpp)
* [cgytrus](https://github.com/cgytrus) for [Algebra Dash](https://github.com/cgytrus/AlgebraDash)
* [matcool](https://github.com/matcool) for [Fast Format](https://github.com/matcool/geode-mods/blob/main/fast-format/main.cpp) (i took the entire mod)
* [cgytrus](https://github.com/cgytrus) for [Algebra Dash](https://github.com/cgytrus/AlgebraDash) (Tracy integration taken from it, the rest of the optimizations were implemented by myself, even if the ideas are similar to ones in Config's mod)
2 changes: 1 addition & 1 deletion src/algo/compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace blaze {
}

Result<OwnedMemoryChunk> Decompressor::decompressToChunk(const void* input, size_t size) {
OwnedMemoryChunk chunk(size * 2);
OwnedMemoryChunk chunk(size * 3);

size_t writtenSize;

Expand Down
14 changes: 9 additions & 5 deletions src/ccimageext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ void CCImageExt::initWithDecodedImage(DecodedImage& img) {
}
}

Result<> CCImageExt::initWithSPNG(void* data, size_t size) {
GEODE_UNWRAP_INTO(auto img, blaze::decodeSPNG(static_cast<uint8_t*>(data), size));
Result<> CCImageExt::initWithSPNG(const void* data, size_t size) {
GEODE_UNWRAP_INTO(auto img, blaze::decodeSPNG(static_cast<const uint8_t*>(data), size));

this->initWithDecodedImage(img);

return Ok();
}

Result<> CCImageExt::initWithFPNG(void* data, size_t size) {
GEODE_UNWRAP_INTO(auto img, blaze::decodeFPNG(static_cast<uint8_t*>(data), size));
Result<> CCImageExt::initWithFPNG(const void* data, size_t size) {
GEODE_UNWRAP_INTO(auto img, blaze::decodeFPNG(static_cast<const uint8_t*>(data), size));

this->initWithDecodedImage(img);

return Ok();
}

Result<> CCImageExt::initWithSPNGOrCache(uint8_t* buffer, size_t size, const char* imgPath) {
Result<> CCImageExt::initWithSPNGOrCache(const uint8_t* buffer, size_t size, const char* imgPath) {
ZoneScoped;

// check if we have cached it already
Expand Down Expand Up @@ -106,4 +106,8 @@ Result<> CCImageExt::initWithSPNGOrCache(uint8_t* buffer, size_t size, const cha
return this->initWithSPNG(buffer, size);
}

Result<> CCImageExt::initWithSPNGOrCache(const blaze::OwnedMemoryChunk& chunk, const char* imgPath) {
return this->initWithSPNGOrCache(chunk.data, chunk.size, imgPath);
}

}
8 changes: 5 additions & 3 deletions src/ccimageext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Geode/utils/Result.hpp>

#include <formats.hpp>
#include <util.hpp>

namespace blaze {

Expand All @@ -14,9 +15,10 @@ class CCImageExt : public cocos2d::CCImage {

void setImageProperties(uint32_t width, uint32_t height, uint32_t bitDepth, bool hasAlpha, bool hasPreMulti);

geode::Result<> initWithSPNG(void* data, size_t size);
geode::Result<> initWithFPNG(void* data, size_t size);
geode::Result<> initWithSPNGOrCache(uint8_t* data, size_t size, const char* imgPath);
geode::Result<> initWithSPNG(const void* data, size_t size);
geode::Result<> initWithFPNG(const void* data, size_t size);
geode::Result<> initWithSPNGOrCache(const uint8_t* data, size_t size, const char* imgPath);
geode::Result<> initWithSPNGOrCache(const blaze::OwnedMemoryChunk& chunk, const char* imgPath);

private:
void initWithDecodedImage(DecodedImage&);
Expand Down
Loading

0 comments on commit 45b6caf

Please sign in to comment.