-
Notifications
You must be signed in to change notification settings - Fork 963
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
More as_hal() methods #3966
Closed
Closed
More as_hal() methods #3966
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
32311fe
WIP More hal exposures
JMS55 32ec118
Finish CommandEncoder::as_hal_mut()
JMS55 b3f2afb
Add raw_handle methods
JMS55 493db92
Add Adapter::texture_format_as_hal()
JMS55 f6bc72f
Add changelog
JMS55 84f5bd1
Type fixes
JMS55 d8ab000
Another type fix
JMS55 2ea6293
Fix unused warning on wasm
JMS55 101a392
Fixes
JMS55 f979162
Change hal command encoder
JMS55 d7dcc9b
Make public more things
JMS55 0548dfb
Fix command encoder as_hal_mut
JMS55 a937666
Expose raw
JMS55 c429170
Merge commit 'c5851275c59b1d5d949b142d6aa973d0bb638181'
JMS55 e3e895a
Ensure a command buffer is active
JMS55 e31b764
Setup hacky command_encoder_transition_textures
JMS55 28d6dac
Extremely hacky transition_textures
JMS55 eb19bfc
Misc
JMS55 e722de8
Merge commit '98ea3500fd2cfb4b51d5454c662d8eefd940156a'
JMS55 2fb314d
Merge remote-tracking branch 'wgpu/master'
JMS55 108d63c
Fix
JMS55 f4f6fca
Merge commit '9dc834a0ac694d576a584a89f72733a0bb2f4485'
JMS55 9b85135
Remove hacky transition textures
JMS55 765cb02
Misc cleanup
JMS55 e439a83
Misc
JMS55 894a161
Add back stuff
JMS55 020f343
Add back TextureView::raw_handle()
JMS55 5d98a86
Add back TextureView::raw_handle()
JMS55 c9444a0
Merge branch 'master' of https://github.com/JMS55/wgpu
JMS55 93ca2c2
Misc
JMS55 94730d4
Merge commit '54e4c8654d85eb28262db0a24d07e4c6db612b38'
JMS55 13ab6a8
Merge commit '7198d60f6820af15d12a3762de9ab0d484c4e827'
JMS55 4bf5751
Merge commit '2a77bbd80d23e14175c801d7cc3d109d9d47d8ca'
JMS55 63f127c
Add missing imports
JMS55 644306d
Misc fix
JMS55 88152f8
Fix
JMS55 e4c90ba
Mark fn as pub
JMS55 1b2a072
Mark import as pub
JMS55 1a38694
Merge commit '09b010b26af6876ce84991576a168a572172f08d'
JMS55 480ba76
Change naga version
JMS55 9d1e574
Misc
JMS55 7a326e8
Revert "Change naga version"
JMS55 1880d89
Merge commit '5b4c6b8ae4afa88358be6135b36e9d2b54808611'
JMS55 221d2cb
Misc
JMS55 a98eacb
Merge commit '359e39232239d2f5d0ac1dadde7c3d874d3cf29e'
JMS55 31c67e0
Merge commit '40cc2ee88a5c9bf281395547375e279ca30aedc0'
JMS55 04b7bdd
Merge branch 'trunk' into master
cwfitzgerald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ use crate::{ | |
global::Global, | ||
hal_api::HalApi, | ||
hub::Token, | ||
id::{AdapterId, DeviceId, SurfaceId, TextureId, Valid}, | ||
id::{AdapterId, CommandEncoderId, DeviceId, SurfaceId, TextureId, TextureViewId, Valid}, | ||
identity::GlobalIdentityHandlerFactory, | ||
init_tracker::{BufferInitTracker, TextureInitTracker}, | ||
track::TextureSelector, | ||
|
@@ -438,11 +438,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> { | |
/// # Safety | ||
/// | ||
/// - The raw texture handle must not be manually destroyed | ||
pub unsafe fn texture_as_hal<A: HalApi, F: FnOnce(Option<&A::Texture>)>( | ||
pub unsafe fn texture_as_hal<A: HalApi, F: FnOnce(Option<&A::Texture>) -> R, R>( | ||
&self, | ||
id: TextureId, | ||
hal_texture_callback: F, | ||
) { | ||
) -> R { | ||
profiling::scope!("Texture::as_hal"); | ||
|
||
let hub = A::hub(self); | ||
|
@@ -451,7 +451,26 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> { | |
let texture = guard.try_get(id).ok().flatten(); | ||
let hal_texture = texture.and_then(|tex| tex.inner.as_raw()); | ||
|
||
hal_texture_callback(hal_texture); | ||
hal_texture_callback(hal_texture) | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// - The raw texture view handle must not be manually destroyed | ||
pub unsafe fn texture_view_as_hal<A: HalApi, F: FnOnce(Option<&A::TextureView>) -> R, R>( | ||
&self, | ||
id: TextureViewId, | ||
hal_texture_view_callback: F, | ||
) -> R { | ||
profiling::scope!("TextureView::as_hal"); | ||
|
||
let hub = A::hub(self); | ||
let mut token = Token::root(); | ||
let (guard, _) = hub.texture_views.read(&mut token); | ||
let texture_view = guard.try_get(id).ok().flatten(); | ||
let hal_texture_view = texture_view.map(|tex| &tex.raw); | ||
|
||
hal_texture_view_callback(hal_texture_view) | ||
} | ||
|
||
/// # Safety | ||
|
@@ -474,6 +493,26 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> { | |
hal_adapter_callback(hal_adapter) | ||
} | ||
|
||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))] | ||
pub fn texture_format_as_hal<A: HalApi>( | ||
&self, | ||
adapter: AdapterId, | ||
texture_format: wgt::TextureFormat, | ||
) -> Option<A::TextureFormat> { | ||
use hal::Adapter; | ||
|
||
profiling::scope!("TextureFormat::as_hal"); | ||
|
||
let hub = A::hub(self); | ||
let mut token = Token::root(); | ||
|
||
let (guard, _) = hub.adapters.read(&mut token); | ||
let adapter = guard.try_get(adapter).ok().flatten(); | ||
let hal_adapter = adapter.map(|adapter| &adapter.raw.adapter); | ||
|
||
hal_adapter.map(|hal_adapter| hal_adapter.texture_format_as_hal(texture_format)) | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// - The raw device handle must not be manually destroyed | ||
|
@@ -511,6 +550,28 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> { | |
|
||
hal_surface_callback(hal_surface) | ||
} | ||
|
||
/// # Safety | ||
/// - The raw command encoder handle must not be manually destroyed | ||
pub unsafe fn command_encoder_as_hal_mut< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do I need to add the not wasm #cfg's here, and in a few other places? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should |
||
A: HalApi, | ||
F: FnOnce(Option<&mut A::CommandEncoder>) -> R, | ||
R, | ||
>( | ||
&self, | ||
id: CommandEncoderId, | ||
hal_command_encoder_callback: F, | ||
) -> R { | ||
profiling::scope!("CommandEncoder::as_hal_mut"); | ||
|
||
let hub = A::hub(self); | ||
let mut token = Token::root(); | ||
let (mut guard, _) = hub.command_buffers.write(&mut token); | ||
let command_encoder = guard.get_mut(id).ok(); | ||
let hal_command_encoder = command_encoder.map(|encoder| encoder.encoder.open()); | ||
|
||
hal_command_encoder_callback(hal_command_encoder) | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
|
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
Did I need to make this method public, and CommandBuffer.encoder pub(crate)? Not sure.