Skip to content

Commit

Permalink
Fixing integration issues and merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
gents83 committed Sep 8, 2023
1 parent c235de4 commit 490b2b7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
return;
}


// Determine if we expect this test to fail, and if so, why.
let expected_failure_reason = parameters
.failures
Expand Down Expand Up @@ -482,7 +481,7 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te
}
}

fn initialize_adapter() -> (Adapter, Option<SurfaceGuard>) {
fn initialize_adapter() -> (Instance, Adapter, Option<SurfaceGuard>) {
let instance = initialize_instance();
let surface_guard: Option<SurfaceGuard>;
let compatible_surface;
Expand Down
6 changes: 4 additions & 2 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,12 +1936,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}

// Wait for all work to finish before configuring the surface.
if let Err(e) = device.maintain(hub, wgt::Maintain::Wait, &mut token) {
let fence = device.fence.read();
let fence = fence.as_ref().unwrap();
if let Err(e) = device.maintain(hub, fence, wgt::Maintain::Wait) {
break e.into();
}

// All textures must be destroyed before the surface can be re-configured.
if let Some(present) = surface.presentation.take() {
if let Some(present) = surface.presentation.lock().take() {
if present.acquired_texture.is_some() {
break E::PreviousOutputExists;
}
Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let texture = hub.textures.unregister(texture_id);
if let Some(texture) = texture {
if let Ok(mut texture) = Arc::try_unwrap(texture) {
texture.clear_mode.destroy_clear_views(device.raw());
texture.clear_mode.write().destroy_clear_views(device.raw());

let suf = A::get_surface(&surface);
match texture.inner.take().unwrap() {
Expand Down Expand Up @@ -396,15 +396,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
// and now we are moving it away.
log::debug!(
"Removing swapchain texture {:?} from the device tracker",
texture_id.value
texture_id
);
device.trackers.lock().textures.remove(texture_id);

let texture = hub.textures.unregister(texture_id);
if let Some(texture) = texture {
if let Ok(mut texture) = Arc::try_unwrap(texture) {
texture.clear_mode.destroy_clear_views(device.raw());
texture.clear_mode.write().destroy_clear_views(device.raw());

let suf = A::get_surface(&surface);
match texture.inner.take().unwrap() {
resource::TextureInner::Surface {
Expand Down
13 changes: 6 additions & 7 deletions wgpu-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,12 @@ pub enum TextureClearMode<A: HalApi> {
None,
}

impl<A: hal::Api> TextureClearMode<A> {
pub(crate) fn destroy_clear_views(self, device: &A::Device) {
if let TextureClearMode::RenderPass { clear_views, .. } = self {
for clear_view in clear_views {
unsafe {
hal::Device::destroy_texture_view(device, clear_view);
}
impl<A: HalApi> TextureClearMode<A> {
pub(crate) fn destroy_clear_views(&mut self, device: &A::Device) {
if let TextureClearMode::Surface { ref mut clear_view } = *self {
unsafe {
let view = clear_view.take().unwrap();
hal::Device::destroy_texture_view(device, view);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/examples/halmark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<A: hal::Api> Example<A> {
let exposed = adapters.swap_remove(0);
(exposed.adapter, exposed.capabilities)
};

let surface_caps = unsafe { adapter.surface_capabilities(&surface) }
.ok_or("failed to get surface capabilities")?;
log::info!("Surface caps: {:#?}", surface_caps);
Expand Down
3 changes: 1 addition & 2 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl crate::Instance<super::Api> for super::Instance {
let entry = unsafe { ash::Entry::load() }.map_err(|err| {
crate::InstanceError::with_source(String::from("missing Vulkan entry points"), err)
})?;

let driver_api_version = match entry.try_enumerate_instance_version() {
// Vulkan 1.1+
Ok(Some(version)) => version,
Expand Down Expand Up @@ -830,7 +830,6 @@ impl crate::Surface<super::Api> for super::Surface {
device: &super::Device,
config: &crate::SurfaceConfiguration,
) -> Result<(), crate::SurfaceError> {

// Safety: `configure`'s contract guarantees there are no resources derived from the swapchain in use.
let mut swap_chain = self.swapchain.write();
let old = swap_chain
Expand Down

0 comments on commit 490b2b7

Please sign in to comment.