-
Notifications
You must be signed in to change notification settings - Fork 920
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
[core, hal, types] Clarify wgpu_hal
's bounds check promises.
#6201
Merged
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
jimblandy
force-pushed
the
fix-1813
branch
2 times, most recently
from
September 2, 2024 23:56
6616d2d
to
b7d4d93
Compare
In `Device::create_bind_group`, name the functions that convert resource ids to Arcs `resolve_foo`, not `map_foo`: - The types that hold Arcs are usually called `ResolvedBlah`. - The name `map_buffer` is misleading.
Change various functions that have no need to create an owning reference to the `Device` to accept `&self` instead of `&Arc<Self>`. Change `ParentDevice::same_device` to accept `&Device` as the point of comparison, not `&Arc<Device>`. Call sites will use Deref conversion, so no callers need to be changed.
Remove the `pub(crate)` visibility marking from various associated functions of `Device` that are defined in, and not used outside of, the `wgpu_core::device::resource` module.
Rather than passing `self.limits` to `Device::create_buffer_binding` as an argument, let it simply refer to `self.limits` itself.
In `wgpu_hal`: - Document that `wgpu_hal` guarantees that shaders will not access buffer contents beyond the bindgroups' bound regions, rounded up to some adapter-specific alignment. Introduce the term "accessible region" for the portion of the buffer that shaders can actually get at. - Document that all bets are off if you disable bounds checks with `ShaderModuleDescriptor::runtime_checks`. - Provide this alignment in `wgpu_hal::Alignments`. Update all backends appropriately. - In the Vulkan backend, use Naga to inject bounds checks on buffer accesses unless `robustBufferAccess2` is available; `robustBufferAccess` is not sufficient. Retrieve `VK_EXT_robustness2`'s properties, as needed to discover the alignment above. In `wgpu_core`: - Use buffer bindings' accessible regions to determine which parts of the buffer need to be initialized. In `wgpu_types`: - Document some of the possible effects of using `ShaderBoundsChecks::unchecked`. Fixes gfx-rs#1813.
nical
approved these changes
Sep 3, 2024
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.
Beautiful.
teoxoy
approved these changes
Sep 3, 2024
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.
Looks great!
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.
[core, hal, types] Clarify
wgpu_hal
's bounds check promises.In
wgpu_hal
:Document that
wgpu_hal
guarantees that shaders will not access buffercontents beyond the bindgroups' bound regions, rounded up to some
adapter-specific alignment. Introduce the term "accessible region" for
the portion of the buffer that shaders can actually get at.
Document that all bets are off if you disable bounds checks with
ShaderModuleDescriptor::runtime_checks
.Provide this alignment in
wgpu_hal::Alignments
. Update all backendsappropriately.
In the Vulkan backend, use Naga to inject bounds checks on buffer accesses
unless
robustBufferAccess2
is available;robustBufferAccess
is notsufficient. Retrieve
VK_EXT_robustness2
's properties, as needed to discoverthe alignment above.
In
wgpu_core
:need to be initialized.
In
wgpu_types
:ShaderBoundsChecks::unchecked
.[core]: Let
Device::create_buffer_binding
getlimits
fromself
.Rather than passing
self.limits
toDevice::create_buffer_binding
as an argument, let it simply refer to
self.limits
itself.[core] Remove unnecessary
pub(crate)
fromDevice
methods.Remove the
pub(crate)
visibility marking from various associatedfunctions of
Device
that are defined in, and not used outside of,the
wgpu_core::device::resource
module.[core] Simplify
self
types indevice::resource
.Change various functions that have no need to create an owning
reference to the
Device
to accept&self
instead of&Arc<Self>
.Change
ParentDevice::same_device
to accept&Device
as the point ofcomparison, not
&Arc<Device>
. Call sites will use Deref conversion,so no callers need to be changed.
[core] Rename
map_buffer
toresolve_buffer
, etc.In
Device::create_bind_group
, name the functions that convertresource ids to Arcs
resolve_foo
, notmap_foo
:The types that hold Arcs are usually called
ResolvedBlah
.The name
map_buffer
is misleading.Fixes #1813.
Checklist
cargo fmt
.cargo clippy
.cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.