-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
dx12: Adopt BAL approch #2266
dx12: Adopt BAL approch #2266
Conversation
dx12: Update formatting
Hmm, I'm not sure it's worth it for us to split the backends into HAL/BAL sections. It would introduce longer dependency chains for us and clients. Couldn't the backend crates just provide both? Assuming HAL implementation is mostly just wrapping around BAL primitives. |
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.
Safety concerns.
src/bal/dx12/src/copy.rs
Outdated
} | ||
|
||
#[derive(Clone)] | ||
pub struct Copy { |
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.
Naming conflict with std::prelude::Copy
is undesirable.
src/bal/dx12/src/native/com.rs
Outdated
} | ||
|
||
impl<T: Interface> WeakPtr<T> { | ||
pub fn as_unknown(&self) -> &IUnknown { |
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.
This function must be marked unsafe
.
Otherwise this "safe" expression WeakPtr::from_raw(1usize as *mut u32).as_unknown()
will trigger UB.
src/bal/dx12/src/native/com.rs
Outdated
} | ||
|
||
// Cast creates a new WeakPtr requiring explicit destroy call. | ||
pub fn cast<U>(&self) -> D3DResult<WeakPtr<U>> |
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.
unsafe
function
src/bal/dx12/src/native/com.rs
Outdated
|
||
// Destroying one instance of the WeakPtr will invalidate all | ||
// copies and clones. | ||
pub fn destroy(&self) { |
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.
unsafe
function
impl<T> Deref for WeakPtr<T> { | ||
type Target = T; | ||
fn deref(&self) -> &T { | ||
debug_assert!(!self.is_null()); |
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.
This type is pub
so debug_assert
doesn't seem enough.
The Moving out common pieces like blitting will done in a separate PR. |
PoC for switching towards the BAL concept suggested in #2249
/src
structure:backend/dx12
moved tohal/dx12
hal/dx12
has a new dependency onbal/dx12
Source code from HAL will be gradually refactored into the corresponding BAL backend in order to slim down the HAL implementation and move 'unsafe' portions into BAL (ie zero cost wrappers over d3d12 structs)
Upcoming PR should be a rustfmt as the backend code doesnt seem to be formatted at all (?)