vulkan: add support for blend buffers
This commit is contained in:
parent
1220539a41
commit
cb9da22ec2
20 changed files with 638 additions and 78 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
format::{FORMATS, Format},
|
||||
format::{ABGR16161616F, FORMATS, Format},
|
||||
gfx_apis::vulkan::{VulkanError, instance::VulkanInstance},
|
||||
video::{LINEAR_MODIFIER, Modifier},
|
||||
},
|
||||
|
|
@ -38,18 +38,24 @@ pub struct VulkanModifier {
|
|||
pub render_needs_bridge: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct VulkanModifierLimits {
|
||||
pub max_width: u32,
|
||||
pub max_height: u32,
|
||||
pub exportable: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct VulkanInternalFormat {
|
||||
pub limits: VulkanModifierLimits,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct VulkanBlendBufferLimits {
|
||||
pub max_width: u32,
|
||||
pub max_height: u32,
|
||||
}
|
||||
|
||||
const FRAMEBUFFER_FEATURES: FormatFeatureFlags = FormatFeatureFlags::from_raw(
|
||||
0 | FormatFeatureFlags::COLOR_ATTACHMENT.as_raw()
|
||||
| FormatFeatureFlags::COLOR_ATTACHMENT_BLEND.as_raw(),
|
||||
|
|
@ -79,6 +85,16 @@ const TRANSFER_USAGE: ImageUsageFlags = ImageUsageFlags::from_raw(
|
|||
const SHM_USAGE: ImageUsageFlags =
|
||||
ImageUsageFlags::from_raw(TRANSFER_USAGE.as_raw() | TEX_USAGE.as_raw());
|
||||
|
||||
pub const BLEND_FORMAT: &Format = ABGR16161616F;
|
||||
const BLEND_FEATURES: FormatFeatureFlags = FormatFeatureFlags::from_raw(
|
||||
0 | FormatFeatureFlags::COLOR_ATTACHMENT.as_raw()
|
||||
| FormatFeatureFlags::COLOR_ATTACHMENT_BLEND.as_raw()
|
||||
| FormatFeatureFlags::SAMPLED_IMAGE.as_raw(),
|
||||
);
|
||||
pub const BLEND_USAGE: ImageUsageFlags = ImageUsageFlags::from_raw(
|
||||
ImageUsageFlags::COLOR_ATTACHMENT.as_raw() | ImageUsageFlags::SAMPLED.as_raw(),
|
||||
);
|
||||
|
||||
impl VulkanInstance {
|
||||
pub(super) fn load_formats(
|
||||
&self,
|
||||
|
|
@ -126,6 +142,29 @@ impl VulkanInstance {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn load_blend_format_limits(
|
||||
&self,
|
||||
phy_dev: PhysicalDevice,
|
||||
) -> Result<VulkanBlendBufferLimits, VulkanError> {
|
||||
let format_properties = unsafe {
|
||||
self.instance
|
||||
.get_physical_device_format_properties(phy_dev, BLEND_FORMAT.vk_format)
|
||||
};
|
||||
let l = self
|
||||
.load_internal_format(
|
||||
phy_dev,
|
||||
BLEND_FORMAT,
|
||||
&format_properties,
|
||||
BLEND_FEATURES,
|
||||
BLEND_USAGE,
|
||||
)?
|
||||
.unwrap_or_default();
|
||||
Ok(VulkanBlendBufferLimits {
|
||||
max_width: l.limits.max_width,
|
||||
max_height: l.limits.max_height,
|
||||
})
|
||||
}
|
||||
|
||||
fn load_shm_format(
|
||||
&self,
|
||||
phy_dev: PhysicalDevice,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue