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

Metal revised memory types #2076

Merged
merged 4 commits into from
May 29, 2018
Merged

Metal revised memory types #2076

merged 4 commits into from
May 29, 2018

Conversation

kvark
Copy link
Member

@kvark kvark commented May 28, 2018

Fixes #2069
Includes #2070 (please only review the last 2 commits)

The PR effectively removes all the complicated memory allocation tracking from the Metal backend, instead relying on mapping the available storage types (with CPU caching policy) more accurately to what can be represented in Vulkan API.

With this in, we slice through the whole memory section without crashes. The only issue I failed to fix/workaround is filed as #2077

PR checklist:

  • make succeeds (on *nix)
  • make reftests succeeds
  • tested examples with the following backends: metal

@kvark kvark force-pushed the mtl-memory branch 2 times, most recently from 4fdbb23 to 76903c0 Compare May 28, 2018 20:47
@kvark kvark requested a review from grovesNL May 28, 2018 20:58
@@ -65,6 +66,7 @@ impl Shared {
pub(crate) fn new(device: metal::Device) -> Self {
Shared {
queue_pool: Mutex::new(command::QueuePool::default()),
aux_queue: Mutex::new(device.new_command_queue()),
Copy link
Contributor

@grovesNL grovesNL May 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we exceed 64 temporary command buffers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a problem, since we commit those command buffers right after acquiring them. So in the worst case there is going to be a bit of a delay for GPU to finish.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it depends on how many active deferred commands buffers we actually expect in real use cases, i.e. if it becomes hundreds in practice it would be unfortunate to hit that delay often IMO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Theoretically, it can become an issue, but it's too early to worry about this right now

@@ -1103,7 +1103,7 @@ impl CommandBuffer {
while data.len() < offset + constants.len() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anything responsible for shrinking oversized data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's getting shrunk in clear_resources, unless you mean the allocation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I didn't notice the clear in reset_resources

@kvark
Copy link
Member Author

kvark commented May 29, 2018

Thanks for taking a look! There appear to be no major concerns.
bors r=grovesNL

bors bot added a commit that referenced this pull request May 29, 2018
2076: Metal revised memory types r=grovesNL a=kvark

Fixes #2069
~~Includes #2070 (please only review the last 2 commits)~~

The PR effectively removes all the complicated memory allocation tracking from the Metal backend, instead relying on mapping the available storage types (with CPU caching policy) more accurately to what can be represented in Vulkan API.

With this in, we slice through the whole `memory` section without crashes. The only issue I failed to fix/workaround is filed as #2077

PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends: metal


Co-authored-by: Dzmitry Malyshau <[email protected]>
.lock()
.unwrap()
.wait_idle(&self.shared.device);
debug!("waiting for idle");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to share the wait_idle implementation across device and command?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be shared, yes

@bors
Copy link
Contributor

bors bot commented May 29, 2018

@bors bors bot merged commit 51bbea9 into gfx-rs:master May 29, 2018
@kvark kvark deleted the mtl-memory branch May 29, 2018 03:14
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

Successfully merging this pull request may close these issues.

Coherent memory on Metal
2 participants