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

Some Win32 interfaces should be marked with an agile attribute #740

Closed
damyanp opened this issue Nov 10, 2021 · 8 comments
Closed

Some Win32 interfaces should be marked with an agile attribute #740

damyanp opened this issue Nov 10, 2021 · 8 comments
Assignees
Labels
usability Touch-up to improve the user experience for a language projection

Comments

@damyanp
Copy link
Member

damyanp commented Nov 10, 2021

For example, the various DirectX interfaces (the "nano-COM" ones) should all be marked as agile. This would allow the rust projection to mark them as implementing the Send and Sync traits.

@mikebattista mikebattista added the usability Touch-up to improve the user experience for a language projection label Nov 16, 2021
@sotteson1
Copy link
Contributor

How can I tell which interfaces should be marked agile? Also, is there an attribute I can use to indicate it's agile, or would I need to make one?

@damyanp
Copy link
Member Author

damyanp commented Jan 18, 2022

I think we'll need to mark them manually. Maybe something like "everything in d3d12.h should be agile"?

@kennykerr
Copy link
Contributor

Any progress on this? We have more customer interest to resolve this here: microsoft/windows-rs#1519

@sotteson1
Copy link
Contributor

I think we'll need to mark them manually. Maybe something like "everything in d3d12.h should be agile"?

Are we safe making that assumption, that all interfaces in d3d12.h are agile? What about the other d3d headers? Can we make the same assumption for those?

@damyanp
Copy link
Member Author

damyanp commented Feb 28, 2022

Any d3d* header is definitely agile - these are all Nano-COM interfaces.

@sotteson1 sotteson1 reopened this May 6, 2022
MarijnS95 added a commit to Traverse-Research/gpu-allocator that referenced this issue Jan 16, 2023
…on` and `MemoryBlock`

Thanks to windows-rs implementing these unsafe markers for COM objects
because they are [declared `agile`] (and wrapping the raw pointers in
the first place, which are not marked `Send`/`Sync` by the Rust
language) we can now let the compiler auto-implement the marker traits.
This'll benefit safety (the traits require `unsafe` for a reason) in
case we add fields to these structs that aren't `Send`/`Sync` in the
future.

The same should be done for Vulkan at some point, by manually defining
`Send`+`Sync` wrapper types around affected fields.

Also clear out `MemoryType`'s `Debug` implementation which is already
implemented by windows-rs.

[declared `agile`]: microsoft/win32metadata#740
MarijnS95 added a commit to Traverse-Research/gpu-allocator that referenced this issue Jan 16, 2023
…on` and `MemoryBlock` (#152)

Thanks to windows-rs implementing these unsafe markers for COM objects
because they are [declared `agile`] (and wrapping the raw pointers in
the first place, which are not marked `Send`/`Sync` by the Rust
language) we can now let the compiler auto-implement the marker traits.
This'll benefit safety (the traits require `unsafe` for a reason) in
case we add fields to these structs that aren't `Send`/`Sync` in the
future.

The same should be done for Vulkan at some point, by manually defining
`Send`+`Sync` wrapper types around affected fields.

Also clear out `MemoryType`'s `Debug` implementation which is already
implemented by windows-rs.

[declared `agile`]: microsoft/win32metadata#740
MarijnS95 added a commit to MarijnS95/win32metadata that referenced this issue Jun 14, 2023
Fixes microsoft#1588

Just like microsoft#740/microsoft#861 the `IDXGI*` interface classes should be marked as
`Agile` so that `windows-rs` implements `Sync` and `Send` marker
`trait`s for these `struct`s in Rust, allowing these types to be
fearlessly shared across threads, and accessed from multiple threads at
once: their implementations [are thread-safe].

[are thread-safe]: microsoft#1588 (comment)
mikebattista added a commit that referenced this issue Jun 29, 2023
* Mark `IDXGI*` interfaces as `[Agile]`

Fixes #1588

Just like #740/#861 the `IDXGI*` interface classes should be marked as
`Agile` so that `windows-rs` implements `Sync` and `Send` marker
`trait`s for these `struct`s in Rust, allowing these types to be
fearlessly shared across threads, and accessed from multiple threads at
once: their implementations [are thread-safe].

[are thread-safe]: #1588 (comment)

* Updated the baseline.

---------

Co-authored-by: Mike Battista <[email protected]>
@marler8997
Copy link
Contributor

I'm having a hard time finding information on what this Agile attribute means exactly. Is anyone able to help me understand?

@riverar
Copy link
Collaborator

riverar commented Aug 14, 2023

@marler8997 In this case, it denotes the backing Direct3D 12 objects can be used from any apartment/thread. You're not limited to the apartment/thread that created the object. This information is used by projections, such as Rust, to light up async capabilities.

Does that help at all?

@marler8997
Copy link
Contributor

Yeah thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usability Touch-up to improve the user experience for a language projection
Projects
None yet
Development

No branches or pull requests

6 participants