Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Staged Tile Loading Pipeline #779

Open
wants to merge 220 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
220 commits
Select commit Hold shift + click to select a range
eee88eb
Baby steps - Flatten child / parent / raster work into one container
csciguy8 Nov 3, 2023
f6bf021
Move mapOverlaysToTile to parsing of work
csciguy8 Nov 3, 2023
8b34976
Move raster load throttling to Tileset
csciguy8 Nov 3, 2023
2c55d34
Fix variant query
csciguy8 Nov 4, 2023
28f0778
Let new ::getRequestWork get the request urls before doTileContentWor…
csciguy8 Nov 4, 2023
c411929
Rename TileLoadTask -> TileLoadRequest. Introduce RequestDispatcher
csciguy8 Nov 6, 2023
83c1f62
Remove unused members
csciguy8 Nov 6, 2023
480e065
Remove unused members
csciguy8 Nov 6, 2023
08e21b3
Dispatch TileLoadWork properly
csciguy8 Nov 6, 2023
217ec58
Put this back in
csciguy8 Nov 6, 2023
5327545
Misc fixups
csciguy8 Nov 6, 2023
34db4a4
Simplify RequestDispatcher creation and thread exit logic
csciguy8 Nov 6, 2023
d4eba7a
Fix RequestDispatcher shutdown issues (crash, freeze)
csciguy8 Nov 7, 2023
30896c1
Run the dispatcher logic in a worker thread
csciguy8 Nov 7, 2023
2d0f4da
Misc changes to support raster tile requests
csciguy8 Nov 7, 2023
90999f5
Support raster tile requests properly
csciguy8 Nov 8, 2023
c56f2f1
Fixup ::computeLoadProgress to take RequestDispatcher into account
csciguy8 Nov 8, 2023
51651fe
Add proper raster work throttling
csciguy8 Nov 8, 2023
b06d22c
Misc tweaks
csciguy8 Nov 9, 2023
555c044
Cleanup load stats a little more
csciguy8 Nov 10, 2023
3818f51
Add logging to request dispatcher
csciguy8 Nov 10, 2023
bf05e7a
Run format
csciguy8 Nov 28, 2023
3824edb
Remove tile kick hack in ::ComputeLoadProgress
csciguy8 Nov 28, 2023
1c89183
Fix CWT not loading in Melbourne test
csciguy8 Nov 30, 2023
2eeb071
Remove proposed solution for melbourne freeze (it was something else)
csciguy8 Nov 30, 2023
20f2b1b
Don't allow unlimited queueing of request work
csciguy8 Dec 5, 2023
ea7bc88
Change back to default 20
csciguy8 Dec 5, 2023
a6de2c6
WIP for removing asset accessor from processing code
csciguy8 Dec 7, 2023
b503c6d
Fix work ownership issues. Misc improvements
csciguy8 Dec 12, 2023
7655bdc
auto format
csciguy8 Dec 13, 2023
8fef19e
Fix bug where max requests wasn't being respected
csciguy8 Dec 13, 2023
c6b5dca
Chain request dispatch after one completes. Add between frame buffer
csciguy8 Dec 13, 2023
c4de038
Bump max tile loads to 24 by default
csciguy8 Dec 13, 2023
78ac6fe
Remove polling from request dispatcher
csciguy8 Dec 13, 2023
f6ce649
Add error handling for empty requests coming in
csciguy8 Dec 15, 2023
5f1ddfe
Handle upsample tiles and parents correctly
csciguy8 Dec 15, 2023
4e345ee
Fix hang in melbourne test
csciguy8 Dec 15, 2023
0b5c359
Rename request dispatcher to tile work manager
csciguy8 Dec 15, 2023
8865b84
Split out TileWorkManager into its own file
csciguy8 Dec 15, 2023
4067799
Misc function rename
csciguy8 Dec 15, 2023
f34ba2f
Put back in assertion on destruction
csciguy8 Dec 15, 2023
ec29956
Update comments
csciguy8 Dec 15, 2023
87e1ed0
Fixup TileLoadResult to report failed url
csciguy8 Dec 20, 2023
136e0dc
Set tile state to failed on unknown error
csciguy8 Dec 20, 2023
3af2ad0
Rework tile work discovery to output RequestData, not just a string url
csciguy8 Jan 8, 2024
813d856
Baby steps to allow loader to specify processing function when tile w…
csciguy8 Jan 9, 2024
a3f5801
Baby steps to allow raster processing to specify processing function
csciguy8 Jan 9, 2024
9cd6ab8
Reduce TileLoadWork copies with std::move, rename various members for…
csciguy8 Jan 9, 2024
164dc24
Refactor TileWorkManager to be contained by TilesetContentManager
csciguy8 Jan 9, 2024
8c1566f
Add ability for dispatched work to requeue a request
csciguy8 Jan 10, 2024
409e290
Cleanup processing callbacks logic to define using lambdas (cleaner)
csciguy8 Jan 10, 2024
1e11977
Much refactoring for raster tiles to follow same process->requeue pat…
csciguy8 Jan 12, 2024
ead87a8
Fix misc raster load issues
csciguy8 Jan 12, 2024
74df410
Add framework to let raster tiles complete work before parent tile
csciguy8 Jan 12, 2024
4726a0b
Baby step to get TileLoadWork child work executing properly
csciguy8 Jan 17, 2024
8e00898
Move bulk of add work logic to the TileWorkManager
csciguy8 Jan 17, 2024
e9ee0b1
Refactor TileWorkManager ownership of load work instances (and simplify)
csciguy8 Jan 23, 2024
7dd5c1c
Remove old function
csciguy8 Jan 23, 2024
28e563f
Move projections into tile processing data. Rename TileLoadWork (Work…
csciguy8 Jan 23, 2024
966b184
Fix sorting by ptr, instead of sorting by group / priority
csciguy8 Jan 23, 2024
9f09af8
Fix missed processing work (fixes Melbourne test hang)
csciguy8 Jan 24, 2024
8080041
Rename WorkRequest to TileWorkManager::Order
csciguy8 Jan 24, 2024
4a6c73d
Rename WorkInstance to TileWorkManager::Work
csciguy8 Jan 24, 2024
bec1b59
Fix some broken sorting calls due to refactoring
csciguy8 Jan 24, 2024
ff89e07
Rename tileSource to uniqueId
csciguy8 Jan 24, 2024
25fec77
Let Work struct retain original Order and not duplicate some members
csciguy8 Jan 24, 2024
e51a83e
Simplify priority bias logic
csciguy8 Jan 25, 2024
f153342
Add const to function params where possible
csciguy8 Jan 25, 2024
554e3c7
Fix completion results to include fading tiles
csciguy8 Jan 25, 2024
897d4ee
Rework to eliminate copy of IAssetResponse data (TileWorkManager::onR…
csciguy8 Jan 26, 2024
6cf742b
Add check if response if null
csciguy8 Jan 26, 2024
114bfe2
Fix assertion when performance test suddenly exits (or times out)
csciguy8 Jan 26, 2024
0e0e877
Simplify prepareLoadResultImage. Remove references to old LoadedRaste…
csciguy8 Jan 26, 2024
3d0753b
Keep tile content manager alive if processing tasks are still running
csciguy8 Jan 26, 2024
f910be6
Implement proper shutdown logic for TileWorkManager
csciguy8 Jan 29, 2024
77d4dc3
Fix hang bug introduced from last checkin
csciguy8 Jan 29, 2024
8e7dcea
Rework transitionQueuedWork to handle overlapped url requests better
csciguy8 Jan 30, 2024
42c8c67
Clean up shutdown logic
csciguy8 Jan 30, 2024
f294eb7
First pass at getting unit tests working (building only)
csciguy8 Jan 31, 2024
f7a8287
Fixups for failed unit tests
csciguy8 Jan 31, 2024
ecb5e14
Fixups to run unit tests without crashing
csciguy8 Jan 31, 2024
d1bb754
Fixup octree and quadtree loader tests
csciguy8 Jan 31, 2024
a6c1238
Fixup for linux builds
csciguy8 Jan 31, 2024
4fcf435
Fix initialization errors on Linux
csciguy8 Jan 31, 2024
acd6d8a
Remove unneeded 'this' capture (Clang error)
csciguy8 Jan 31, 2024
f2d79bb
Remove more unneeded "this" captures
csciguy8 Jan 31, 2024
f88babf
Fix missing parenthesis lost from refactoring
csciguy8 Jan 31, 2024
763b424
Add explicit std::move for rvalue ref (avoid copy)
csciguy8 Jan 31, 2024
0a0eb92
Misc warning fixes
csciguy8 Jan 31, 2024
689b9ba
Fix implicit cast to reference (from rvalue ref)
csciguy8 Jan 31, 2024
ca00822
Add more missing initializers
csciguy8 Jan 31, 2024
352309d
Put subtree status code checks back in (removed from rework)
csciguy8 Jan 31, 2024
fd4189d
Misc warning fixes
csciguy8 Jan 31, 2024
d74d007
Fixups for subtree loading (found from unit tests)
csciguy8 Jan 31, 2024
c3cc2f1
Fix missed initialization
csciguy8 Jan 31, 2024
277848d
Fix json loader unit tests
csciguy8 Jan 31, 2024
564b2d2
Fixup failed work logic (found from unit tests)
csciguy8 Jan 31, 2024
3af1227
Disable assertions about child state (temporarily)
csciguy8 Jan 31, 2024
5352dd5
Let work manager detect a 404 code for failed work (found from unit t…
csciguy8 Jan 31, 2024
24aebb1
Fix selection algorithm unit test
csciguy8 Jan 31, 2024
9e7c2f7
Turn off stat logging spam
csciguy8 Jan 31, 2024
de1e209
Add const to loadTileImage param
csciguy8 Jan 31, 2024
8767086
Add const to getLoadTileImageWork param
csciguy8 Jan 31, 2024
a23e081
Move RasterLoadState to RasterOverlayTile::LoadState
csciguy8 Jan 31, 2024
13dddcd
Let failed work logic specify the reason
csciguy8 Jan 31, 2024
10914c1
Fix formatting
csciguy8 Jan 31, 2024
be37ac1
Fix ownership issues when work fails
csciguy8 Feb 1, 2024
c4f70a5
Misc updates to comments
csciguy8 Feb 1, 2024
112176e
Add some debug prints
csciguy8 Feb 1, 2024
d7adb0b
Formatting
csciguy8 Feb 1, 2024
dab6daf
More code doc and renaming for clarity
csciguy8 Feb 1, 2024
32c04b9
Replace printf with spdlog calls
csciguy8 Feb 1, 2024
a1f4ef0
Misc formatting and reorg changes
csciguy8 Feb 1, 2024
88b52b0
More debug logging
csciguy8 Feb 1, 2024
7b5cef1
Remove unnecessary function declarations
csciguy8 Feb 1, 2024
bc70071
Add const to getLoadWork param
csciguy8 Feb 1, 2024
71c0888
Update debug logs
csciguy8 Feb 1, 2024
150d80e
Changes to make PR diff easier
csciguy8 Feb 1, 2024
e2be684
Refactor duplicate code into a helper function
csciguy8 Feb 1, 2024
79f0381
Fix potential iterator erase problem
csciguy8 Feb 1, 2024
58c8bba
Cleaner erase logic
csciguy8 Feb 1, 2024
8dd5663
Remove debug logging
csciguy8 Feb 1, 2024
2d30785
Remove unneeded testing code
csciguy8 Feb 2, 2024
f7d8737
Add some debug logging
csciguy8 Feb 2, 2024
53e6748
Use alternate method of detecting internal buffer move
csciguy8 Feb 2, 2024
d39374e
Create subtree in place, rather than copy
csciguy8 Feb 2, 2024
a4c79d4
Revert some debugging efforts
csciguy8 Feb 2, 2024
ed2fe23
Revert some debug changes
csciguy8 Feb 2, 2024
9adf2c4
Disable these assertions for now (will come back later)
csciguy8 Feb 2, 2024
8a6880f
Refactor some duplicate code
csciguy8 Feb 2, 2024
544ce0d
Disable these assertions for now (will come back later)
csciguy8 Feb 2, 2024
5f23064
Update documentation. Reformat for easier diffs
csciguy8 Feb 5, 2024
abc795f
Rearrange for easier diff
csciguy8 Feb 5, 2024
32ab5dd
Remove out of date "TODO"s
csciguy8 Feb 5, 2024
e6317d6
Formatting
csciguy8 Feb 5, 2024
76324bc
Put status code checking back in
csciguy8 Feb 5, 2024
5e366ca
First pass merge with main
csciguy8 Feb 5, 2024
45c2d62
Second pass merge with main
csciguy8 Feb 6, 2024
aa6e57f
Rough merge of subtree code
csciguy8 Feb 6, 2024
7ec3c0a
First compile success after merge
csciguy8 Feb 6, 2024
3c627d9
Fix compile for unit tests
csciguy8 Feb 6, 2024
dc277f6
Fixups for code merge (subtree avail)
csciguy8 Feb 7, 2024
0155e9e
Fixups for code merge (octree quadtree loaders)
csciguy8 Feb 7, 2024
75ba194
Fixups for code merge (json terrain loader)
csciguy8 Feb 7, 2024
1911d21
Fixups for code merge (json loader)
csciguy8 Feb 7, 2024
3d949fe
Add documentation
csciguy8 Feb 7, 2024
9278dab
Fixups for code merge (laodTileImageFromUrl + WebMapTileServiceRaster…
csciguy8 Feb 7, 2024
4355c31
Fix unit test crash
csciguy8 Feb 7, 2024
d68f6f3
Fix subtree avail unit test failure
csciguy8 Feb 7, 2024
26badfd
Put disabled tests back in
csciguy8 Feb 7, 2024
c80a1b0
Disable subtree tests (temporarily)
csciguy8 Feb 7, 2024
2e97a2a
Fix build warning. Remove unneeded code.
csciguy8 Feb 7, 2024
e3934b9
Remove unneeded lambda param (statusCode)
csciguy8 Feb 7, 2024
c04cb7b
Add missing url requests for subtree availability
csciguy8 Feb 8, 2024
3b43eb2
Simplify ion loader token logic
csciguy8 Feb 8, 2024
88738ce
Fix comparison typo
csciguy8 Feb 8, 2024
abf3503
Turn off pull request builds
csciguy8 Feb 12, 2024
722fb58
Add missing std::move
csciguy8 Feb 12, 2024
dddfba5
Put subtree tests back in
csciguy8 Feb 12, 2024
1e7bb9d
Misc fixups from self review
csciguy8 Feb 13, 2024
37a28d3
Remove TODO comment
csciguy8 Feb 13, 2024
0e7674a
Remove out of date TODO and retry logic
csciguy8 Feb 13, 2024
ee50b74
Add missing getLoadTileImageWork for less used providers
csciguy8 Feb 13, 2024
5ce37c1
Fix for loading maps with more than one overlay (RasterMappedTo3DTile)
csciguy8 Feb 14, 2024
9bd9f85
Fix unit test
csciguy8 Feb 14, 2024
82922a8
Refine assertions
csciguy8 Feb 14, 2024
9af8946
Allow work instances to have more than one content request pending
csciguy8 Feb 14, 2024
027b070
Add support for multiple queued requests from tile provider
csciguy8 Feb 14, 2024
982def8
Add missing assertion
csciguy8 Feb 15, 2024
81e686c
Modify quadtree tile provider to cache the loaded image, not the future
csciguy8 Feb 15, 2024
74ac3fe
Refactor SharedFutures to just be Futures (shared not needed)
csciguy8 Feb 15, 2024
710010a
Fix for release build warnings
csciguy8 Feb 15, 2024
07286d3
Fix build warnings
csciguy8 Feb 15, 2024
c46915e
More warning fixes
csciguy8 Feb 15, 2024
5743b85
Skip adding order work if order already exists
csciguy8 Feb 15, 2024
9838898
Move some assertions to #define code
csciguy8 Feb 15, 2024
8a68f1d
Throttle incoming processing work (this was missing)
csciguy8 Feb 19, 2024
e8365aa
Formatting
csciguy8 Feb 19, 2024
372c506
Add better logging
csciguy8 Feb 20, 2024
96ec82a
Turn off debug logging (oops)
csciguy8 Feb 20, 2024
8836863
Tweaks for getting work stats
csciguy8 Feb 20, 2024
e201cad
Renaming for clarity
csciguy8 Feb 20, 2024
45fdc9c
More renaming for clarity
csciguy8 Feb 20, 2024
c0be28e
Move processing work dispatch to work manager
csciguy8 Feb 20, 2024
2c25e00
Warning fixed
csciguy8 Feb 20, 2024
712a3ee
Put tiles kicked consideration back into ::computeLoadProgress
csciguy8 Feb 21, 2024
255c41f
Fix unit test warnings
csciguy8 Feb 21, 2024
9927c04
Merge branch 'request-gap-refactor' into move-dispatch-to-manager
csciguy8 Feb 21, 2024
356518b
Use ::thenImmediately to respond to completed work faster
csciguy8 Feb 21, 2024
af9c715
Merge from base branch
csciguy8 Feb 21, 2024
b0304d0
Rework tile manager creation into ::createWorkManager
csciguy8 Feb 22, 2024
0d71d62
Speed up raster loading by letting caller handle main thread continua…
csciguy8 Feb 22, 2024
1820aa8
Fix ::waitUntilIdle
csciguy8 Feb 22, 2024
71dca0c
Combine ::thenImmediate continuations
csciguy8 Feb 22, 2024
e86746b
Fix unit test build
csciguy8 Feb 22, 2024
2818454
Rename TileProcessingCallback to TileLoaderCallback
csciguy8 Feb 22, 2024
563762a
Rename struct member to be more descriptive
csciguy8 Feb 22, 2024
69cf3bf
Merge with main
csciguy8 Feb 26, 2024
f4695e3
Fix for shutdown crashes when interrupting a load
csciguy8 Feb 27, 2024
6a34c44
Fix shutdown assertion
csciguy8 Feb 27, 2024
e2fe816
Remove unneeded "parent waits for child" work logic
csciguy8 Feb 27, 2024
bd20876
Let processing get handled in queued order (first in first out)
csciguy8 Feb 28, 2024
9eba02e
Fix warning
csciguy8 Feb 28, 2024
19409f8
Separate SignalWorkComplete from dispatching new work
csciguy8 Feb 29, 2024
7eeb04b
Run immediate continuations for cases we know we're already in a work…
csciguy8 Feb 29, 2024
8237ffe
Fix bug where processing wasn't being handled in priority order
csciguy8 Mar 1, 2024
49fd429
Merge branch 'main' into request-gap-refactor
csciguy8 Mar 4, 2024
15ec811
Add chance to dispatch processing before we leave ::processLoadRequests
csciguy8 Mar 5, 2024
07a05e9
Add additional chance for tile to be set up for finalization (during …
csciguy8 Mar 6, 2024
14761c0
Fix warning (unused capture)
csciguy8 Mar 7, 2024
e5f686f
Fixes found from unit tests
csciguy8 Mar 7, 2024
1082b79
Fix up unit tests
csciguy8 Mar 7, 2024
36cf86d
Another warning fix
csciguy8 Mar 7, 2024
a31290c
Update stats logging to include main thread queue length
csciguy8 Mar 8, 2024
a16c3d5
Add tracking of total main thread loads
csciguy8 Mar 8, 2024
04c923a
Merge branch 'main' into request-gap-refactor
csciguy8 Apr 23, 2024
75146ce
Fixup new unit test from merge
csciguy8 May 7, 2024
e527425
Merge branch 'main' into request-gap-refactor
csciguy8 May 7, 2024
edc0979
Fix bug where tile work manager can hold on to a raster tile that's b…
csciguy8 May 13, 2024
70df413
Fix bug where upsampled tiles weren't creating any processing work
csciguy8 May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cesium-native
on: [push, pull_request]
on: [push]
jobs:
QuickChecks:
name: "Quick Checks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ class SubtreeAvailability {
* @return A future that resolves to a `SubtreeAvailability` instance for the
* subtree file, or std::nullopt if something goes wrong.
*/
static CesiumAsync::Future<std::optional<SubtreeAvailability>> loadSubtree(

using LoadResult =
std::pair<std::optional<SubtreeAvailability>, CesiumAsync::RequestData>;

static CesiumAsync::Future<LoadResult> loadSubtree(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree,
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<spdlog::logger>& pLogger,
const std::string& subtreeUrl,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders);
const std::string& baseUrl,
const CesiumAsync::IAssetResponse* baseResponse,
const CesiumAsync::UrlResponseDataMap& additionalResponse);

/**
* @brief An AvailibilityView that indicates that either all tiles are
Expand Down
40 changes: 26 additions & 14 deletions Cesium3DTilesContent/src/SubtreeAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,44 +137,56 @@ std::optional<SubtreeAvailability::AvailabilityView> parseAvailabilityView(
std::move(subtree));
}

/*static*/ CesiumAsync::Future<std::optional<SubtreeAvailability>>
/*static*/ CesiumAsync::Future<SubtreeAvailability::LoadResult>
SubtreeAvailability::loadSubtree(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree,
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<spdlog::logger>& pLogger,
const std::string& subtreeUrl,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders) {
const std::string& baseUrl,
const CesiumAsync::IAssetResponse* baseResponse,
const CesiumAsync::UrlResponseDataMap& additionalResponse) {
auto pReader = std::make_shared<SubtreeFileReader>();
return pReader->load(asyncSystem, pAssetAccessor, subtreeUrl, requestHeaders)
return pReader->load(asyncSystem, baseUrl, baseResponse, additionalResponse)
.thenInMainThread(
[pLogger, subtreeUrl, subdivisionScheme, levelsInSubtree, pReader](
[pLogger, baseUrl, subdivisionScheme, levelsInSubtree, pReader](
ReadJsonResult<Subtree>&& subtree)
-> std::optional<SubtreeAvailability> {
-> SubtreeAvailability::LoadResult {
if (!subtree.errors.empty()) {
SPDLOG_LOGGER_ERROR(
pLogger,
"Errors while loading subtree from {}:\n- {}",
subtreeUrl,
baseUrl,
CesiumUtility::joinToString(subtree.errors, "\n- "));
}
if (!subtree.warnings.empty()) {
SPDLOG_LOGGER_WARN(
pLogger,
"Warnings while loading subtree from {}:\n- {}",
subtreeUrl,
baseUrl,
CesiumUtility::joinToString(subtree.warnings, "\n- "));
}
if (!subtree.urlNeeded.empty()) {
return SubtreeAvailability::LoadResult{
std::nullopt,
CesiumAsync::RequestData{subtree.urlNeeded, {}}};
}

if (!subtree.value) {
return std::nullopt;
return SubtreeAvailability::LoadResult{
std::nullopt,
CesiumAsync::RequestData{}};
}

return SubtreeAvailability::fromSubtree(
subdivisionScheme,
levelsInSubtree,
std::move(*subtree.value));
std::optional<SubtreeAvailability> returnedSubtree =
SubtreeAvailability::fromSubtree(
subdivisionScheme,
levelsInSubtree,
std::move(*subtree.value));

return SubtreeAvailability::LoadResult{
std::move(returnedSubtree),
CesiumAsync::RequestData{}};
});
}

Expand Down
32 changes: 21 additions & 11 deletions Cesium3DTilesContent/test/TestSubtreeAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,30 @@ std::optional<SubtreeAvailability> mockLoadSubtreeJson(
auto pMockTaskProcessor = std::make_shared<ThreadTaskProcessor>();
CesiumAsync::AsyncSystem asyncSystem{pMockTaskProcessor};

auto testEntry = pMockAssetAccessor->mockCompletedRequests.find("test");
assert(testEntry != pMockAssetAccessor->mockCompletedRequests.end());
const CesiumAsync::IAssetResponse* testResponse =
testEntry->second->response();
assert(testResponse);

CesiumAsync::UrlResponseDataMap additionalResponses;
auto bufferEntry = pMockAssetAccessor->mockCompletedRequests.find("buffer");
additionalResponses.emplace(
bufferEntry->first,
CesiumAsync::ResponseData{
bufferEntry->second.get(),
bufferEntry->second->response()});

auto subtreeFuture = SubtreeAvailability::loadSubtree(
ImplicitTileSubdivisionScheme::Quadtree,
levelsInSubtree,
asyncSystem,
pMockAssetAccessor,
spdlog::default_logger(),
"test",
{});
testResponse,
additionalResponses);

return waitForFuture(asyncSystem, std::move(subtreeFuture));
return waitForFuture(asyncSystem, std::move(subtreeFuture)).first;
}
} // namespace

Expand Down Expand Up @@ -557,10 +571,6 @@ TEST_CASE("Test parsing subtree format") {
"test",
CesiumAsync::HttpHeaders{},
std::move(pMockResponse));
std::map<std::string, std::shared_ptr<SimpleAssetRequest>> mapUrlToRequest{
{"test", std::move(pMockRequest)}};
auto pMockAssetAccessor =
std::make_shared<SimpleAssetAccessor>(std::move(mapUrlToRequest));

// mock async system
auto pMockTaskProcessor = std::make_shared<SimpleTaskProcessor>();
Expand All @@ -570,13 +580,14 @@ TEST_CASE("Test parsing subtree format") {
ImplicitTileSubdivisionScheme::Quadtree,
maxSubtreeLevels,
asyncSystem,
pMockAssetAccessor,
spdlog::default_logger(),
"test",
{});
pMockRequest->response(),
CesiumAsync::UrlResponseDataMap{});

asyncSystem.dispatchMainThreadTasks();
auto parsedSubtree = subtreeFuture.wait();
SubtreeAvailability::LoadResult loadResult = subtreeFuture.wait();
std::optional<SubtreeAvailability>& parsedSubtree = loadResult.first;
REQUIRE(parsedSubtree != std::nullopt);

for (const auto& tileID : availableTileIDs) {
Expand All @@ -595,7 +606,6 @@ TEST_CASE("Test parsing subtree format") {
CHECK(parsedSubtree->isSubtreeAvailable(
libmorton::morton2D_64_encode(subtreeID.x, subtreeID.y)));
}

for (const auto& subtreeID : unavailableSubtreeIDs) {
CHECK(!parsedSubtree->isSubtreeAvailable(
libmorton::morton2D_64_encode(subtreeID.x, subtreeID.y)));
Expand Down
39 changes: 15 additions & 24 deletions Cesium3DTilesReader/include/Cesium3DTilesReader/SubtreeFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,47 +57,38 @@ class CESIUM3DTILESREADER_API SubtreeFileReader {
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
load(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& headers = {})
const std::string& baseUrl,
const CesiumAsync::IAssetResponse* baseResponse,
const CesiumAsync::UrlResponseDataMap& additionalResponses)
const noexcept;

CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
load(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<CesiumAsync::IAssetRequest>& pRequest)
const noexcept;

CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
load(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const std::string& baseUrl,
const CesiumAsync::UrlResponseDataMap& additionalResponses,
const gsl::span<const std::byte>& data) const noexcept;

private:
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
loadBinary(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const gsl::span<const std::byte>& data) const noexcept;
const std::string& baseUrl,
const gsl::span<const std::byte>& data,
const CesiumAsync::UrlResponseDataMap& additionalResponses)
const noexcept;
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
loadJson(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const gsl::span<const std::byte>& data) const noexcept;
const std::string& baseUrl,
const gsl::span<const std::byte>& data,
const CesiumAsync::UrlResponseDataMap& additionalResponses)
const noexcept;
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
postprocess(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const std::string& baseUrl,
const CesiumAsync::UrlResponseDataMap& additionalResponses,
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>&& loaded)
const noexcept;

Expand Down
Loading