mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[vk] add TextureView::raw_format
This commit is contained in:
parent
2d73eb3967
commit
f728a92366
@ -744,7 +744,6 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
attachments: ArrayVec::default(),
|
||||
extent: desc.extent,
|
||||
};
|
||||
let caps = &self.device.private_caps;
|
||||
|
||||
for cat in desc.color_attachments {
|
||||
if let Some(cat) = cat.as_ref() {
|
||||
@ -752,10 +751,11 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
color: unsafe { cat.make_vk_clear_color() },
|
||||
});
|
||||
let color = super::ColorAttachmentKey {
|
||||
base: cat.target.make_attachment_key(cat.ops, caps),
|
||||
resolve: cat.resolve_target.as_ref().map(|target| {
|
||||
target.make_attachment_key(crate::AttachmentOps::STORE, caps)
|
||||
}),
|
||||
base: cat.target.make_attachment_key(cat.ops),
|
||||
resolve: cat
|
||||
.resolve_target
|
||||
.as_ref()
|
||||
.map(|target| target.make_attachment_key(crate::AttachmentOps::STORE)),
|
||||
};
|
||||
|
||||
rp_key.colors.push(Some(color));
|
||||
@ -785,7 +785,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
},
|
||||
});
|
||||
rp_key.depth_stencil = Some(super::DepthStencilAttachmentKey {
|
||||
base: ds.target.make_attachment_key(ds.depth_ops, caps),
|
||||
base: ds.target.make_attachment_key(ds.depth_ops),
|
||||
stencil_ops: ds.stencil_ops,
|
||||
});
|
||||
fb_key.attachments.push(ds.target.view.raw);
|
||||
|
||||
@ -182,14 +182,10 @@ pub fn map_vk_surface_formats(sf: vk::SurfaceFormatKHR) -> Option<wgt::TextureFo
|
||||
}
|
||||
|
||||
impl crate::Attachment<'_, super::TextureView> {
|
||||
pub(super) fn make_attachment_key(
|
||||
&self,
|
||||
ops: crate::AttachmentOps,
|
||||
caps: &super::PrivateCapabilities,
|
||||
) -> super::AttachmentKey {
|
||||
pub(super) fn make_attachment_key(&self, ops: crate::AttachmentOps) -> super::AttachmentKey {
|
||||
super::AttachmentKey {
|
||||
format: caps.map_texture_format(self.view.view_format),
|
||||
layout: derive_image_layout(self.usage, self.view.view_format),
|
||||
format: self.view.raw_format,
|
||||
layout: derive_image_layout(self.usage, self.view.format),
|
||||
ops,
|
||||
}
|
||||
}
|
||||
@ -198,13 +194,7 @@ impl crate::Attachment<'_, super::TextureView> {
|
||||
impl crate::ColorAttachment<'_, super::TextureView> {
|
||||
pub(super) unsafe fn make_vk_clear_color(&self) -> vk::ClearColorValue {
|
||||
let cv = &self.clear_value;
|
||||
match self
|
||||
.target
|
||||
.view
|
||||
.view_format
|
||||
.sample_type(None, None)
|
||||
.unwrap()
|
||||
{
|
||||
match self.target.view.format.sample_type(None, None).unwrap() {
|
||||
wgt::TextureSampleType::Float { .. } => vk::ClearColorValue {
|
||||
float32: [cv.r as f32, cv.g as f32, cv.b as f32, cv.a as f32],
|
||||
},
|
||||
|
||||
@ -1260,11 +1260,12 @@ impl crate::Device for super::Device {
|
||||
desc: &crate::TextureViewDescriptor,
|
||||
) -> Result<super::TextureView, crate::DeviceError> {
|
||||
let subresource_range = conv::map_subresource_range(&desc.range, texture.format);
|
||||
let raw_format = self.shared.private_caps.map_texture_format(desc.format);
|
||||
let mut vk_info = vk::ImageViewCreateInfo::default()
|
||||
.flags(vk::ImageViewCreateFlags::empty())
|
||||
.image(texture.raw)
|
||||
.view_type(conv::map_view_dimension(desc.dimension))
|
||||
.format(self.shared.private_caps.map_texture_format(desc.format))
|
||||
.format(raw_format)
|
||||
.subresource_range(subresource_range);
|
||||
let layers =
|
||||
NonZeroU32::new(subresource_range.layer_count).expect("Unexpected zero layer count");
|
||||
@ -1288,7 +1289,8 @@ impl crate::Device for super::Device {
|
||||
Ok(super::TextureView {
|
||||
raw,
|
||||
layers,
|
||||
view_format: desc.format,
|
||||
format: desc.format,
|
||||
raw_format,
|
||||
})
|
||||
}
|
||||
unsafe fn destroy_texture_view(&self, view: super::TextureView) {
|
||||
@ -1727,10 +1729,8 @@ impl crate::Device for super::Device {
|
||||
(image_infos, local_image_infos) =
|
||||
image_infos.extend(desc.textures[start as usize..end as usize].iter().map(
|
||||
|binding| {
|
||||
let layout = conv::derive_image_layout(
|
||||
binding.usage,
|
||||
binding.view.view_format,
|
||||
);
|
||||
let layout =
|
||||
conv::derive_image_layout(binding.usage, binding.view.format);
|
||||
vk::DescriptorImageInfo::default()
|
||||
.image_view(binding.view.raw)
|
||||
.image_layout(layout)
|
||||
|
||||
@ -792,7 +792,8 @@ impl Texture {
|
||||
pub struct TextureView {
|
||||
raw: vk::ImageView,
|
||||
layers: NonZeroU32,
|
||||
view_format: wgt::TextureFormat,
|
||||
format: wgt::TextureFormat,
|
||||
raw_format: vk::Format,
|
||||
}
|
||||
|
||||
impl crate::DynTextureView for TextureView {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user