-
Notifications
You must be signed in to change notification settings - Fork 192
Lazy loading large assets #1923
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
base: develop
Are you sure you want to change the base?
Changes from all commits
adb7ec9
571c319
c9f1e1d
1ecca81
956617f
95c48f5
89a0054
32f0f37
a33a92e
ced3589
2b4a5b9
3e0802a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,19 @@ struct Asset { | |||||||||||||||||||||
| const std::string key; | ||||||||||||||||||||||
| std::vector<std::uint8_t> data; | ||||||||||||||||||||||
| std::uint32_t alignment = 1; | ||||||||||||||||||||||
| std::vector<std::uint8_t>& getData(); | ||||||||||||||||||||||
| std::size_t getSize() const; | ||||||||||||||||||||||
| std::string getRelativeUri(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// Set the backing file and its expected size. | ||||||||||||||||||||||
| void setFile(std::filesystem::path path, std::size_t size); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private: | ||||||||||||||||||||||
| friend class AssetManager; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| std::filesystem::path path; | ||||||||||||||||||||||
| std::size_t size = 0; | ||||||||||||||||||||||
| bool dataLoaded = false; | ||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| class AssetsMutable : public Assets { | ||||||||||||||||||||||
|
|
@@ -127,6 +139,8 @@ class AssetManager /*: public Assets*/ { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// Serializes | ||||||||||||||||||||||
| void serialize(AssetsMutable& assets, std::vector<std::uint8_t>& assetStorage, std::string prefix = "") const; | ||||||||||||||||||||||
| /// Calculates the size of the serialized data | ||||||||||||||||||||||
| std::size_t getSerializedSize(std::size_t offset = 0) const; | ||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs docstring
Comment on lines
+142
to
+143
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value Document the The docstring answers the earlier request. It does not state what 📝 Proposed docstring- /// Calculates the size of the serialized data
+ /**
+ * Calculates the size of the serialized asset data.
+ *
+ * `@param` offset Starting offset in the aggregate asset storage
+ * `@returns` End offset after all assets, including alignment padding
+ * `@throws` std::runtime_error If an asset alignment is zero, or if the storage would exceed 4 GiB
+ */
std::size_t getSerializedSize(std::size_t offset = 0) const;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } // namespace dai | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was necessary as
std::vector<uint8_t>is declared as opaque so the previous version of the binding didn't work.