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

Guard invalid device memory flushes. #2671

Merged
merged 1 commit into from
Mar 15, 2019
Merged
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions gapis/api/vulkan/api/memory.api
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ cmd VkResult vkFlushMappedMemoryRanges(
}
}

if !(flushRange.memory in DeviceMemories) { vkErrorInvalidDeviceMemory(flushRange.memory) }
if !(flushRange.memory in DeviceMemories) { vkErrorInvalidDeviceMemory(flushRange.memory) } else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for not bothering indenting this block of code?

Side comment: I don't like inline if statements, however I won't push new styles if it's the standard for these .api source files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the reason that we have been doing this is because we can't early-return in the API language.

We use this pattern so that we don't add incredible amounts of nesting.
What I REALLY want to say is

if !(flush.memory in DeviceMemories) { return; }

memoryObject := DeviceMemories[flushRange.memory]
mappedLocation := as!u8*(memoryObject.MappedLocation)
flushStart := flushRange.offset - memoryObject.MappedOffset
Expand All @@ -228,7 +228,7 @@ cmd VkResult vkFlushMappedMemoryRanges(
// copy() contains an implicit read observation
copy(memoryObject.Data[flushRange.offset:flushRange.offset + flushRange.size], (mappedLocation)[flushStart:flushStart + flushRange.size])
}
}
}}
}
return ?
}
Expand Down