Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 committed Nov 28, 2023
1 parent eb712be commit 688ba31
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
47 changes: 29 additions & 18 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,24 +804,35 @@ impl<A: HalApi> Device<A> {
let mut clear_views = SmallVec::new();
for mip_level in 0..desc.mip_level_count {
for array_layer in 0..desc.size.depth_or_array_layers {
let desc = hal::TextureViewDescriptor {
label: clear_label,
format: desc.format,
dimension,
usage,
range: wgt::ImageSubresourceRange {
aspect: wgt::TextureAspect::All,
base_mip_level: mip_level,
mip_level_count: Some(1),
base_array_layer: array_layer,
array_layer_count: Some(1),
},
plane: None,
};
clear_views.push(Some(
unsafe { self.raw().create_texture_view(&raw_texture, &desc) }
.map_err(DeviceError::from)?,
));
macro_rules! push_clear_view {
($format:expr, $plane:expr) => {
let desc = hal::TextureViewDescriptor {
label: clear_label,
format: $format,
dimension,
usage,
range: wgt::ImageSubresourceRange {
aspect: wgt::TextureAspect::All,
base_mip_level: mip_level,
mip_level_count: Some(1),
base_array_layer: array_layer,
array_layer_count: Some(1),
},
plane: $plane,
};
clear_views.push(Some(
unsafe { self.raw().create_texture_view(&raw_texture, &desc) }
.map_err(DeviceError::from)?,
));
};
}

if desc.format == wgt::TextureFormat::NV12 {
push_clear_view!(wgt::TextureFormat::R8Unorm, Some(0));
push_clear_view!(wgt::TextureFormat::Rg8Unorm, Some(1));
} else {
push_clear_view!(desc.format, None);
}
}
}
resource::TextureClearMode::RenderPass {
Expand Down
6 changes: 5 additions & 1 deletion wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ impl crate::Device<super::Api> for super::Device {
aspects: view_desc.aspects,
target_base: (
texture.resource.clone(),
texture.calc_subresource(desc.range.base_mip_level, desc.range.base_array_layer, 0),
texture.calc_subresource(
desc.range.base_mip_level,
desc.range.base_array_layer,
desc.plane.unwrap_or(0),
),
),
handle_srv: if desc.usage.intersects(crate::TextureUses::RESOURCE) {
let raw_desc = unsafe { view_desc.to_srv() };
Expand Down
8 changes: 4 additions & 4 deletions wgpu-hal/src/dx12/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl ViewDescriptor {
unsafe {
*desc.u.Texture2D_mut() = d3d12_ty::D3D12_TEX2D_UAV {
MipSlice: self.mip_level_base,
PlaneSlice: 0,
PlaneSlice: self.plane,
}
}
}
Expand All @@ -192,7 +192,7 @@ impl ViewDescriptor {
MipSlice: self.mip_level_base,
FirstArraySlice: self.array_layer_base,
ArraySize: self.array_layer_count,
PlaneSlice: 0,
PlaneSlice: self.plane,
}
}
}
Expand Down Expand Up @@ -252,7 +252,7 @@ impl ViewDescriptor {
unsafe {
*desc.u.Texture2D_mut() = d3d12_ty::D3D12_TEX2D_RTV {
MipSlice: self.mip_level_base,
PlaneSlice: 0,
PlaneSlice: self.plane,
}
}
}
Expand All @@ -274,7 +274,7 @@ impl ViewDescriptor {
MipSlice: self.mip_level_base,
FirstArraySlice: self.array_layer_base,
ArraySize: self.array_layer_count,
PlaneSlice: 0,
PlaneSlice: self.plane,
}
}
}
Expand Down

0 comments on commit 688ba31

Please sign in to comment.