-
Notifications
You must be signed in to change notification settings - Fork 938
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
Degenerification part 1/3: wgpu-hal
DynDevice
& friends
#6098
Closed
Closed
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
7f4cf4f
introduce DynResource & DynBuffer as first user
Wumpf eddab98
Buffer bindings no longer depend on hal api struct, but directly on b…
Wumpf f9d47ec
BufferBarrier no longer depend on hal api struct, but directly on buf…
Wumpf 880e5a9
Introduce DynCommandEncoder, implement index & vertex buffer ops on it
Wumpf 6f8ef5c
DynCommandEncoder implement begin/end encoding, debug markers, variou…
Wumpf debe041
introduce DynQuerySet, associated DynCommandEncoder methods
Wumpf 233d2ba
Introduce DynPipelineLayout & DynBindGroup
Wumpf 6576838
Introduce DynComputePipeline & DynRenderPipeline
Wumpf 7548973
fold ComputePassTimestampWrites & RenderPassTimestampWrites and make …
Wumpf ff49edc
introduce DynTexture & DynTextureView
Wumpf 15748cb
render/compute pass descriptors work now with dyn types
Wumpf c19659b
implement begin/end render/computepass for dyncommandencoder
Wumpf 1ee9d4b
implement transition_textures for DynCommandEncoder
Wumpf 8bb009e
buffer / texture copy operations for DynCommandEncoder
Wumpf 5719e38
texture & buffer transitioning always uses DynCommandEncoder now
Wumpf 2502283
Introduce DynDevice
Wumpf 7b25389
add most remaining dyn type traits
Wumpf b662e71
impl DynShaderModule for all backends
Wumpf e9860f7
impl DynCommandBuffer
Wumpf 8595a1c
Device now has to implement DynResource
Wumpf e4744df
impl DynFence for all fences
Wumpf d94e465
impl DynSurfaceTexture for all surface textures
Wumpf 39b214a
introduce DynSurface
Wumpf 24bd6e0
introduce DynQueue
Wumpf d685660
DynDevice buffer operations
Wumpf 9dd24e0
DynDevice create/destroy for texture/textureview/sampler
Wumpf 3217d43
DynDevice create/destroy command encoder
Wumpf 38c9031
DynDevice create/destroy bind group layout
Wumpf ba06be2
DynDevice create/destroy pipeline layout
Wumpf f37a871
DynDevice create/destroy bind group
Wumpf 533def2
DynDevice create/destroy ShaderModule
Wumpf bf1bf41
DynDevice create/destroy compute/render pipeline
Wumpf 7d8f753
DynDevice pipeline cache
Wumpf af35846
DynDevice create/destroy query set
Wumpf 96914ea
DynDevice fence
Wumpf 3bf21ab
DynDevice wait/capture/pipeline_cache_get_data
Wumpf afd32e0
DynDevice acceleration structure handling
Wumpf 666d2fa
DynDevice exit, counters, report
Wumpf 4c30ef5
DynCommandencoder end_encoding, reset_all
Wumpf 7981855
DynCommandEncoder acceleration structure building
Wumpf 34fe670
remove unnecessary debug constraints from Api (handled by Dyn traits)
Wumpf 2eb9c73
introduce DynAdapter
Wumpf 75aaa13
introduce DynInstance
Wumpf 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use crate::{ | ||
DynDevice, DynFence, DynResource, DynSurfaceTexture, Surface, SurfaceConfiguration, | ||
SurfaceError, | ||
}; | ||
|
||
use super::DynResourceExt as _; | ||
|
||
#[derive(Debug)] | ||
pub struct DynAcquiredSurfaceTexture { | ||
pub texture: Box<dyn DynSurfaceTexture>, | ||
/// The presentation configuration no longer matches | ||
/// the surface properties exactly, but can still be used to present | ||
/// to the surface successfully. | ||
pub suboptimal: bool, | ||
} | ||
|
||
pub trait DynSurface: DynResource { | ||
unsafe fn configure( | ||
&self, | ||
device: &dyn DynDevice, | ||
config: &SurfaceConfiguration, | ||
) -> Result<(), SurfaceError>; | ||
|
||
unsafe fn unconfigure(&self, device: &dyn DynDevice); | ||
|
||
unsafe fn acquire_texture( | ||
&self, | ||
timeout: Option<std::time::Duration>, | ||
fence: &dyn DynFence, | ||
) -> Result<Option<DynAcquiredSurfaceTexture>, SurfaceError>; | ||
|
||
unsafe fn discard_texture(&self, texture: Box<dyn DynSurfaceTexture>); | ||
} | ||
|
||
impl<S: Surface + DynResource> DynSurface for S { | ||
unsafe fn configure( | ||
&self, | ||
device: &dyn DynDevice, | ||
config: &SurfaceConfiguration, | ||
) -> Result<(), SurfaceError> { | ||
let device = device.expect_downcast_ref(); | ||
unsafe { S::configure(self, device, config) } | ||
} | ||
|
||
unsafe fn unconfigure(&self, device: &dyn DynDevice) { | ||
let device = device.expect_downcast_ref(); | ||
unsafe { S::unconfigure(self, device) } | ||
} | ||
|
||
unsafe fn acquire_texture( | ||
&self, | ||
timeout: Option<std::time::Duration>, | ||
fence: &dyn DynFence, | ||
) -> Result<Option<DynAcquiredSurfaceTexture>, SurfaceError> { | ||
let fence = fence.expect_downcast_ref(); | ||
unsafe { S::acquire_texture(self, timeout, fence) }.map(|acquired| { | ||
acquired.map(|ast| { | ||
let texture = Box::new(ast.texture); | ||
let suboptimal = ast.suboptimal; | ||
DynAcquiredSurfaceTexture { | ||
texture, | ||
suboptimal, | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
unsafe fn discard_texture(&self, texture: Box<dyn DynSurfaceTexture>) { | ||
unsafe { S::discard_texture(self, texture.unbox()) } | ||
} | ||
} |
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
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.
issue: We don't document a safety contract or adherence thereto for these methods. We should do this.