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

Sessioned reads and writes #13

Open
kvark opened this issue Nov 4, 2020 · 6 comments
Open

Sessioned reads and writes #13

kvark opened this issue Nov 4, 2020 · 6 comments

Comments

@kvark
Copy link
Contributor

kvark commented Nov 4, 2020

It would be very useful to do multiple reads/writes in a single mapping session. Currently, write_bytes and read_bytes are limited to exactly one request. Case in question: laying out texture data into the staging buffer, it needs to be done row by row to respect the alignment of the target API.

@zakarumych
Copy link
Owner

In this case you can use map and unmap functions.

@kvark
Copy link
Contributor Author

kvark commented Nov 4, 2020

Sure, this isn't a blocker. However, doing map/unmap manually also requires handling the flush/invalidation for non-coherent memory, which is tedious. A session-based reader/writer would strictly be better in this case.

@zakarumych
Copy link
Owner

How about function that takes a closure in which reads and/or writes are available?

@kvark
Copy link
Contributor Author

kvark commented Nov 4, 2020

That would be inferior to RAII. Are you concerned about safety guarantees when doing this, so that closure helps you to preserve them? I think there are no guarantees here for the most part, so no need to try restricting the users too much.

@zakarumych
Copy link
Owner

I try to guarantee that memory gets unmapped. To prevent attempts to map memory when it's already mapped.
Drop impls may not run, so with RAII approach it would be necessary to flip mapped field to true and then back to false in Drop impl for returned guard, along with actual unmapping. This would require &mut self function.
With closure I can almost certainly guarantee unmapping to happen unless process is aborted, so mapped will be only checked and it will be &self function.

@kvark
Copy link
Contributor Author

kvark commented Nov 4, 2020

Mapping is already &mut self, so I'm not sure why you are concerned about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants