-
Notifications
You must be signed in to change notification settings - Fork 441
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
Zero-copy importer plugin APIs #240
Draft
mosra
wants to merge
4
commits into
master
Choose a base branch
from
zerocopy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 tasks
mosra
force-pushed
the
meshdata
branch
7 times, most recently
from
January 23, 2020 16:30
98c057b
to
b4666a6
Compare
mosra
force-pushed
the
meshdata
branch
2 times, most recently
from
January 24, 2020 15:45
414347d
to
0e5385f
Compare
mosra
force-pushed
the
meshdata
branch
5 times, most recently
from
February 8, 2020 19:51
8c0503e
to
41d57f0
Compare
mosra
force-pushed
the
meshdata
branch
6 times, most recently
from
February 16, 2020 10:41
8889ee2
to
e09b741
Compare
mosra
force-pushed
the
meshdata
branch
6 times, most recently
from
March 11, 2020 13:39
6f62217
to
a4bf0e6
Compare
mosra
changed the title
[WIP] Zero-copy importer plugin APIs
Zero-copy importer plugin APIs
Oct 24, 2021
It's great to see how the design nicely fermented over the three and half (!!) years. This is a completely opt-in feature for all plugins involved, so if the plugin decides to not do anything about it, it doesn't have to. The actual enforcements will come later.
Because there's no format ever that would support zero-copy everything (except the upcoming Magnum blobs, hah!), it makes no sense to force zero-copy globally. Instead, zero-copy can be forced just for particular data of interest. For example a glTF can zero-copy-import mesh and animation data, but not always image data (except if it embeds an uncompressed KTX), and never scene or material data, which are stored in the textual JSON.
8 tasks
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #240 +/- ##
===========================================
+ Coverage 79.97% 97.12% +17.15%
===========================================
Files 511 237 -274
Lines 32354 14863 -17491
===========================================
- Hits 25875 14436 -11439
+ Misses 6479 427 -6052 ☔ View full report in Codecov by Sentry. |
Meant to be used from within plugin implementations to avoid copies in the delegated importers. TODO: the heck, why can't I call a protected function from a subclass but another instance? TODO: figure out a way to test this TODO: update docs and behavior for the ZeroCopy flag TODO: adapt AnySceneImporter also
1 task
Closed
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The end goal for this:
Utility::Directory::mapRead()
to memory-map a huge image / audio / scene fileAnimationData
,MeshData
,ImageData
... work directly on the memory-mapped dataThe progress, as of 2021-10-24:
TODO:
doOpenData()
to accept an r-value Array andDataFlags
describing whether it's temporary, owned by the importer, makeopenFile()
then pass over the allocated array ownership there -- 116d327openData()
with the same signature and the usual assertions from the publicopenData()
so proxy plugins such asAnyImageImporter
or opening images from within other plugins can make use of the memory ownership annotations as wellopenMemory()
as a zero-copy counterpart toopenData()
inTrade::AbstractImporter
+DataFlag::ExternallyOwned
, delegate to the above new `doOpenData() -- 27044a4DataFlag::Mutable
todoOpenData()
magnum-sceneconverter
-- 03aeb49magnum-sceneconverter
memory-map also referenced files via a callbackimplementthese interfaces will eventually get deprecated and merged intoopenMemory()
as a zero-copy counterpart toopenData()
inAudio::AbstractImporter
Trade::AbstractImporter
doOpenData()
andopenMemory()
equivalently inText::AbstractFont
as wellredesign-- done in Mesh Data rework #371 insteadTrade::MeshData2D
/Trade::MeshData3D
to eat an array (view) instead of vectorsadd an ability to put an array view to-- done in Mesh Data rework #371 insteadTrade::ImageData2D
/ ... (convert it to an array with a custom no-op deleter internally)implementdone differently in Mesh Data rework #371Trade::AbstractImporter::mesh2DMemory()
/ ... that's able to pass through the mapped data in case the file was opened viaopenMemory()
implementdone differently in Mesh Data rework #371Trade::AbstractImporter::image2DMemory()
/ ... that's able to pass through the mapped data in case the file was opened viaopenMemory()
implementthese interfaces will eventually get deprecated and merged intoAudio::Importer::data()
that's able to pass through the mapped data in case the file was opened viaopenMemory()
Trade::AbstractImporter
ImporterFlag::ZeroCopy
flag, which will enable importers to pass the input data fromopenMemory()
through toAnimationData
/MeshData
/ImageData
/ ... without copiesImporterFlag::ForceZeroCopyThing
for animations, images, mesh index/vertex buffers, ... that turns the above opt-in behavior to enforcedImporterFeature::ZeroCopyThing
with which the importer advertises ability to zero-copy certain data, which then gets assert for presence if the corresponding flag gets setImporterFeature::ZeroCopyScenes
andImporterFlag::ForceZeroCopyScenes
once SceneData rework #525 is inSkinData
needs to exposejointDataFlags()
&inverseBindMatrixDataFlags()
YUp
etc flags?), bump importer plugin interfaces for thatAnyImageImporter
etc. flag propagation now needs to handle the cases of the flag not being supported in the target and provide a runtime error instead of an assertImporterFlag::YUp
&ImageConverterFlag::YUp
to control whether images get Y-flipped on import and on conversion (otherwise it's not really possible to implement zero-copy import), similarly forZBackward
(andXLeft
?)ImageFlag::YUp
to annotate what orientation the image is in so this information doesn't get lost afterImporterFlag::YDown
/ImageConverterFlag::YDown
and a presence of neither meaning "keep it in whatever orientation it was" to make the zero-copy import not annoying to set uppixels()
behave -- they should probably return the view with X right, Y down, Z forward always to be consistent? That'll break existing code tho.WavAudioImporter
onceTrade::AbstractImporter
can do audio as wellFreeTypeFont
TgaImporter
once theYUp
flag is in (it also converts from ARGB or something, what to do ?)DdsImporter
once theYUp
flag is inKtxImporter
once theYUp
flag is inStanfordImporter
in progress,zerocopy
branch(impossible)TinyGltfImageImporter
CgltfImporter
ImageView::slice()
and then upload a slice to GPU memoryOpen questions / followup tasks: