mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 23:04:07 +00:00
vulkan: HDR ASTC formats support
This commit is contained in:
parent
373cc61084
commit
01628a1fad
@ -197,6 +197,7 @@ impl Surface {
|
||||
wgt::TextureFormat::Rgba8UnormSrgb,
|
||||
wgt::TextureFormat::Bgra8Unorm,
|
||||
wgt::TextureFormat::Rgba8Unorm,
|
||||
wgt::TextureFormat::Rgba16Float,
|
||||
];
|
||||
|
||||
let suf = A::get_surface(self);
|
||||
|
@ -25,6 +25,7 @@ pub struct PhysicalDeviceFeatures {
|
||||
robustness2: Option<vk::PhysicalDeviceRobustness2FeaturesEXT>,
|
||||
depth_clip_enable: Option<vk::PhysicalDeviceDepthClipEnableFeaturesEXT>,
|
||||
multiview: Option<vk::PhysicalDeviceMultiviewFeaturesKHR>,
|
||||
astc_hdr: Option<vk::PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT>,
|
||||
}
|
||||
|
||||
// This is safe because the structs have `p_next: *mut c_void`, which we null out/never read.
|
||||
@ -59,6 +60,9 @@ impl PhysicalDeviceFeatures {
|
||||
if let Some(ref mut feature) = self.depth_clip_enable {
|
||||
info = info.push_next(feature);
|
||||
}
|
||||
if let Some(ref mut feature) = self.astc_hdr {
|
||||
info = info.push_next(feature);
|
||||
}
|
||||
info
|
||||
}
|
||||
|
||||
@ -320,6 +324,15 @@ impl PhysicalDeviceFeatures {
|
||||
} else {
|
||||
None
|
||||
},
|
||||
astc_hdr: if enabled_extensions.contains(&vk::ExtTextureCompressionAstcHdrFn::name()) {
|
||||
Some(
|
||||
vk::PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT::builder()
|
||||
.texture_compression_astc_hdr(true)
|
||||
.build(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,6 +536,13 @@ impl PhysicalDeviceFeatures {
|
||||
is_format_16bit_norm_supported(caps),
|
||||
);
|
||||
|
||||
if let Some(ref astc_hdr) = self.astc_hdr {
|
||||
features.set(
|
||||
F::TEXTURE_COMPRESSION_ASTC_HDR,
|
||||
astc_hdr.texture_compression_astc_hdr != 0,
|
||||
);
|
||||
}
|
||||
|
||||
(features, dl_flags)
|
||||
}
|
||||
|
||||
@ -633,6 +653,10 @@ impl PhysicalDeviceCapabilities {
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
extensions.push(vk::KhrPortabilitySubsetFn::name());
|
||||
|
||||
if requested_features.contains(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR) {
|
||||
extensions.push(vk::ExtTextureCompressionAstcHdrFn::name())
|
||||
}
|
||||
|
||||
extensions
|
||||
}
|
||||
|
||||
@ -865,6 +889,12 @@ impl super::InstanceShared {
|
||||
.insert(vk::PhysicalDeviceDepthClipEnableFeaturesEXT::default());
|
||||
builder = builder.push_next(next);
|
||||
}
|
||||
if capabilities.supports_extension(vk::ExtTextureCompressionAstcHdrFn::name()) {
|
||||
let next = features
|
||||
.astc_hdr
|
||||
.insert(vk::PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT::default());
|
||||
builder = builder.push_next(next);
|
||||
}
|
||||
|
||||
let mut features2 = builder.build();
|
||||
unsafe {
|
||||
@ -1401,7 +1431,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
||||
if !self.private_caps.can_present {
|
||||
return None;
|
||||
}
|
||||
|
||||
let queue_family_index = 0; //TODO
|
||||
{
|
||||
profiling::scope!("vkGetPhysicalDeviceSurfaceSupportKHR");
|
||||
@ -1509,7 +1538,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
||||
.any(|sf| sf.format == vk_format || sf.format == vk::Format::UNDEFINED)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Some(crate::SurfaceCapabilities {
|
||||
formats,
|
||||
swap_chain_sizes: caps.min_image_count..=max_image_count,
|
||||
|
@ -121,7 +121,22 @@ impl super::PrivateCapabilities {
|
||||
AstcBlock::B12x10 => F::ASTC_12X10_SRGB_BLOCK,
|
||||
AstcBlock::B12x12 => F::ASTC_12X12_SRGB_BLOCK,
|
||||
},
|
||||
AstcChannel::Hdr => unimplemented!(),
|
||||
AstcChannel::Hdr => match block {
|
||||
AstcBlock::B4x4 => F::ASTC_4X4_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B5x4 => F::ASTC_5X4_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B5x5 => F::ASTC_5X5_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B6x5 => F::ASTC_6X5_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B6x6 => F::ASTC_6X6_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B8x5 => F::ASTC_8X5_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B8x6 => F::ASTC_8X6_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B8x8 => F::ASTC_8X8_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B10x5 => F::ASTC_10X5_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B10x6 => F::ASTC_10X6_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B10x8 => F::ASTC_10X8_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B10x10 => F::ASTC_10X10_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B12x10 => F::ASTC_12X10_SFLOAT_BLOCK_EXT,
|
||||
AstcBlock::B12x12 => F::ASTC_12X12_SFLOAT_BLOCK_EXT,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -517,12 +517,19 @@ impl super::Device {
|
||||
None => vk::SwapchainKHR::null(),
|
||||
};
|
||||
|
||||
let color_space = if config.format == wgt::TextureFormat::Rgba16Float {
|
||||
// Enable wide color gamut mode
|
||||
// Vulkan swapchain for Android only supports DISPLAY_P3_NONLINEAR_EXT and EXTENDED_SRGB_LINEAR_EXT
|
||||
vk::ColorSpaceKHR::EXTENDED_SRGB_LINEAR_EXT
|
||||
} else {
|
||||
vk::ColorSpaceKHR::SRGB_NONLINEAR
|
||||
};
|
||||
let info = vk::SwapchainCreateInfoKHR::builder()
|
||||
.flags(vk::SwapchainCreateFlagsKHR::empty())
|
||||
.surface(surface.raw)
|
||||
.min_image_count(config.swap_chain_size)
|
||||
.image_format(self.shared.private_caps.map_texture_format(config.format))
|
||||
.image_color_space(vk::ColorSpaceKHR::SRGB_NONLINEAR)
|
||||
.image_color_space(color_space)
|
||||
.image_extent(vk::Extent2D {
|
||||
width: config.extent.width,
|
||||
height: config.extent.height,
|
||||
|
@ -162,6 +162,9 @@ impl super::Instance {
|
||||
|
||||
extensions.push(vk::KhrGetPhysicalDeviceProperties2Fn::name());
|
||||
|
||||
// Provid wide color gamut
|
||||
extensions.push(vk::ExtSwapchainColorspaceFn::name());
|
||||
|
||||
// Only keep available extensions.
|
||||
extensions.retain(|&ext| {
|
||||
if instance_extensions
|
||||
|
Loading…
Reference in New Issue
Block a user