mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 23:05:43 +00:00
Minor cleanups in Framebuffer type
This commit is contained in:
parent
f0341b3e35
commit
5a2ff9ce59
@ -17,6 +17,8 @@ use smallvec::SmallVec;
|
|||||||
use device::Device;
|
use device::Device;
|
||||||
use framebuffer::RenderPass;
|
use framebuffer::RenderPass;
|
||||||
use framebuffer::RenderPassAttachmentsList;
|
use framebuffer::RenderPassAttachmentsList;
|
||||||
|
use framebuffer::RenderPassCompatible;
|
||||||
|
use framebuffer::UnsafeRenderPass;
|
||||||
use image::Layout as ImageLayout;
|
use image::Layout as ImageLayout;
|
||||||
use image::traits::Image;
|
use image::traits::Image;
|
||||||
use image::traits::ImageView;
|
use image::traits::ImageView;
|
||||||
@ -48,16 +50,8 @@ impl<L> Framebuffer<L> {
|
|||||||
/// Builds a new framebuffer.
|
/// Builds a new framebuffer.
|
||||||
///
|
///
|
||||||
/// The `attachments` parameter depends on which `RenderPass` implementation is used.
|
/// The `attachments` parameter depends on which `RenderPass` implementation is used.
|
||||||
///
|
pub fn new<A>(render_pass: &Arc<L>, dimensions: [u32; 3],
|
||||||
/// # Panic
|
attachments: A) -> Result<Arc<Framebuffer<L>>, FramebufferCreationError>
|
||||||
///
|
|
||||||
/// - Panicks if one of the attachments has a different sample count than what the render pass
|
|
||||||
/// describes.
|
|
||||||
/// - Additionally, some methods in the `RenderPassAttachmentsList` implementation may panic
|
|
||||||
/// if you pass invalid attachments. // TODO: should be error instead
|
|
||||||
///
|
|
||||||
pub fn new<'a, A>(render_pass: &Arc<L>, dimensions: [u32; 3],
|
|
||||||
attachments: A) -> Result<Arc<Framebuffer<L>>, FramebufferCreationError>
|
|
||||||
where L: RenderPass + RenderPassAttachmentsList<A>
|
where L: RenderPass + RenderPassAttachmentsList<A>
|
||||||
{
|
{
|
||||||
let vk = render_pass.render_pass().device().pointers();
|
let vk = render_pass.render_pass().device().pointers();
|
||||||
@ -71,7 +65,9 @@ impl<L> Framebuffer<L> {
|
|||||||
let limits = render_pass.render_pass().device().physical_device().limits();
|
let limits = render_pass.render_pass().device().physical_device().limits();
|
||||||
let limits = [limits.max_framebuffer_width(), limits.max_framebuffer_height(),
|
let limits = [limits.max_framebuffer_width(), limits.max_framebuffer_height(),
|
||||||
limits.max_framebuffer_layers()];
|
limits.max_framebuffer_layers()];
|
||||||
if dimensions[0] > limits[0] || dimensions[1] > limits[1] || dimensions[2] > limits[2] {
|
if dimensions[0] > limits[0] || dimensions[1] > limits[1] ||
|
||||||
|
dimensions[2] > limits[2]
|
||||||
|
{
|
||||||
return Err(FramebufferCreationError::DimensionsTooLarge);
|
return Err(FramebufferCreationError::DimensionsTooLarge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,13 +123,12 @@ impl<L> Framebuffer<L> {
|
|||||||
/// Returns true if this framebuffer can be used with the specified renderpass.
|
/// Returns true if this framebuffer can be used with the specified renderpass.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_compatible_with<R>(&self, render_pass: &Arc<R>) -> bool
|
pub fn is_compatible_with<R>(&self, render_pass: &Arc<R>) -> bool
|
||||||
where R: RenderPass, L: RenderPass
|
where R: RenderPass,
|
||||||
|
L: RenderPass + RenderPassCompatible<R>
|
||||||
{
|
{
|
||||||
// FIXME:
|
(&*self.render_pass.render_pass() as *const UnsafeRenderPass as usize ==
|
||||||
true
|
&*render_pass.render_pass() as *const UnsafeRenderPass as usize) ||
|
||||||
/*(&*self.renderpass as *const UnsafeRenderPass<L> as usize ==
|
self.render_pass.is_compatible_with(render_pass)
|
||||||
&**renderpass as *const UnsafeRenderPass<R> as usize) ||
|
|
||||||
self.renderpass.is_compatible_with(renderpass)*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the width, height and layers of this framebuffer.
|
/// Returns the width, height and layers of this framebuffer.
|
||||||
@ -173,6 +168,7 @@ impl<L> Framebuffer<L> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns all the resources attached to that framebuffer.
|
/// Returns all the resources attached to that framebuffer.
|
||||||
|
// TODO: crappy API
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn attachments(&self) -> &[(Arc<ImageView>, Arc<Image>, ImageLayout, ImageLayout)] {
|
pub fn attachments(&self) -> &[(Arc<ImageView>, Arc<Image>, ImageLayout, ImageLayout)] {
|
||||||
&self.resources
|
&self.resources
|
||||||
|
Loading…
Reference in New Issue
Block a user