-
Notifications
You must be signed in to change notification settings - Fork 22
Consider using com-rs #14
Comments
An alternative could be the new
These bindings are generated from the Win32 API metadata at build time and should be trivial (for It picks up API functionality not yet in |
@tangmi your suggestion is probably the reason the most impressive wrapper: https://github.com/LNSEAB/dxplr is now unmaintained. DXPLR is way better wrapper than this d3d12. Newer code from that same LNSEAB uses Windows-Rs. Thing is Windows-Rs is so ergonomic it doesn't need wrappers, because it already bakes in the ComPtr etc. (which btw might be the reason not to use it as GFX assumes manual dropping). However Windows-Rs has lot's of problems, the build time is a long one because the bindings need to be built, rust-analyzer auto complete is spotty, rust-analyzer go to definition stops working, rust-analyzers auto import does not work very well. |
FWIW, I've found the I think the main difference between If gfx is the only consumer of |
@tangmi yes, that's basically what I advocated in #32, because this d3d12-rs library is not particularily useful, it would be good idea to dump this, and use winapi or windows-rs directly. However I wrote same example in winapi and windows-rs: https://github.com/Ciantic/dx12-scratch/blob/master/windows-rs/src/main.rs I have a lot of questions about windows-rs:
Currently as is, the windows-rs is not yet ready to replace winapi crate. |
I'm not sure I understand why gfx needs to not have "smart" com pointers... I think ephemeral objects created as part of the implementation of the dx12 gfx backend should either be explicitly owned by gfx objects or cleaned up on drop (I don't remember if dx12's implementation is allowed to call Luckily, the remaining questions (and the outstanding github issues) about windows-rs seem likely to improve over time. |
@tangmi it's just to lower the overhead of copying the pointers around within gfx-rs itself. I suppose you are right that we can wrap a smart pointer into a dump pointer on gfx-rs side, it doesn't have to be that pervasive. But that at least requires that all the spots of the low-level d3d12 access would work with |
It looks like
|
They made a lot of changes, and I managed to compile triangle with windows-rs version that is in the Microsoft's git repository as of today. Further I'm in this swamp, I have come to conclusion that some helper libraries might still be in order even if we got rid of the overall approach in this D3D12-rs crate and use windows-rs "directly". For instance many of the Microsoft's examples etc. refer to source only packages such as these functions beginning I don't know how useful that d3dx12.h would be for gfx, but I've started to translate parts of it to rust with windows-rs here: https://github.com/Ciantic/dx12-learning/blob/master/common/src/lib.rs |
@Ciantic I think a level of indirection is still warranted, especially with how some of the constants surface from windows-rs, for example the DXGI_USAGE_ ones, which could definitely benefit from being made into enums, something that winapi does for us at the moment. Being built from windows-rs would be good, as it allows us to expose functionality as it arrives (raytracing features etc.) |
Gave it a little go, it's been okay so far, not currently 100% with a modified WGPU, and the error handling is... garbage atm. But I think windows-rs gives a cleaner interface to COM objects, anything derived from or encapsulating an IUnknown releases on drop which is cool, I don't think WeakPtr would be necessary anymore. https://github.com/hwoodiwiss/d3d12-rs/tree/switch-to-windows-rs |
Look at this new thing from MS: https://github.com/microsoft/com-rs/
The text was updated successfully, but these errors were encountered: