Finish turning Framebuffer into a trait

This commit is contained in:
Pierre Krieger 2016-08-26 20:49:26 +02:00
parent cedd503b2b
commit 4fed4df0b6
6 changed files with 14 additions and 11 deletions

View File

@ -27,6 +27,7 @@ use command_buffer::sys::Kind;
use device::Device;
use device::Queue;
use framebuffer::EmptySinglePassRenderPass;
use framebuffer::Framebuffer as OldFramebuffer;
use image::traits::TrackedImage;
use instance::QueueFamily;
use pipeline::ComputePipeline;
@ -97,7 +98,7 @@ unsafe impl<P> StdCommandsList for PrimaryCbBuilder<P> where P: CommandPool {
where F: FnOnce(&mut UnsafeCommandBufferBuilder<Self::Pool>),
I: Iterator<Item = (usize, PipelineBarrierBuilder)>
{
let kind = Kind::Primary::<EmptySinglePassRenderPass, EmptySinglePassRenderPass>;
let kind = Kind::Primary::<EmptySinglePassRenderPass, OldFramebuffer<EmptySinglePassRenderPass>>;
let mut cb = UnsafeCommandBufferBuilder::new(self.pool, kind,
self.flags).unwrap(); // TODO: handle error

View File

@ -47,8 +47,8 @@ pub struct BeginRenderPassCommand<L, Rp, F>
framebuffer: F,
}
impl<L, Rp, F> BeginRenderPassCommand<L, Rp, F>
where L: StdCommandsList + OutsideRenderPass, Rp: RenderPass, F: Framebuffer
impl<L, F> BeginRenderPassCommand<L, F::RenderPass, F>
where L: StdCommandsList + OutsideRenderPass, F: Framebuffer
{
/// See the documentation of the `begin_render_pass` method.
// TODO: allow setting more parameters

View File

@ -21,6 +21,7 @@ use command_buffer::sys::UnsafeCommandBuffer;
use device::Device;
use device::Queue;
use framebuffer::EmptySinglePassRenderPass;
use framebuffer::Framebuffer as OldFramebuffer;
use sync::Fence;
use sync::PipelineStages;
use sync::Semaphore;
@ -291,7 +292,7 @@ unsafe impl<C, R> SubmitList for (C, R) where C: CommandBuffer + 'static, R: Sub
if !current_infos.pre_pipeline_barrier.is_empty() {
let mut cb = UnsafeCommandBufferBuilder::new(Device::standard_command_pool(&device, queue.family()),
Kind::Primary::<EmptySinglePassRenderPass,
EmptySinglePassRenderPass>,
OldFramebuffer<EmptySinglePassRenderPass>>,
Flags::OneTimeSubmit).unwrap();
cb.pipeline_barrier(current_infos.pre_pipeline_barrier);
new_submit.commandBufferCount += 1;
@ -304,7 +305,7 @@ unsafe impl<C, R> SubmitList for (C, R) where C: CommandBuffer + 'static, R: Sub
if !current_infos.post_pipeline_barrier.is_empty() {
let mut cb = UnsafeCommandBufferBuilder::new(Device::standard_command_pool(&device, queue.family()),
Kind::Primary::<EmptySinglePassRenderPass,
EmptySinglePassRenderPass>,
OldFramebuffer<EmptySinglePassRenderPass>>,
Flags::OneTimeSubmit).unwrap();
cb.pipeline_barrier(current_infos.post_pipeline_barrier);
new_submit.commandBufferCount += 1;
@ -349,6 +350,7 @@ mod tests {
use device::Device;
use device::Queue;
use framebuffer::EmptySinglePassRenderPass;
use framebuffer::Framebuffer as OldFramebuffer;
use sync::Fence;
use sync::PipelineStages;
use sync::Semaphore;
@ -380,7 +382,7 @@ mod tests {
let (device, queue) = gfx_dev_and_queue!();
let pool = Device::standard_command_pool(&device, queue.family());
let kind = Kind::Primary::<EmptySinglePassRenderPass, EmptySinglePassRenderPass>;
let kind = Kind::Primary::<EmptySinglePassRenderPass, OldFramebuffer<EmptySinglePassRenderPass>>;
let cb = UnsafeCommandBufferBuilder::new(pool, kind, Flags::OneTimeSubmit).unwrap();
let cb = Basic { inner: cb.build().unwrap() };

View File

@ -691,9 +691,9 @@ impl<P> UnsafeCommandBufferBuilder<P> where P: CommandPool {
/// - The render pass and the framebuffer must be compatible.
/// - The clear values must be valid for the attachments.
///
pub unsafe fn begin_render_pass<L, I, F>(&mut self, render_pass: &UnsafeRenderPass,
framebuffer: &F, clear_values: I,
rect: [Range<u32>; 2], secondary: bool)
pub unsafe fn begin_render_pass<I, F>(&mut self, render_pass: &UnsafeRenderPass,
framebuffer: &F, clear_values: I,
rect: [Range<u32>; 2], secondary: bool)
where I: Iterator<Item = ClearValue>,
F: Framebuffer
{

View File

@ -176,7 +176,7 @@ impl<L> Framebuffer<L> {
}
}
unsafe impl<L> FramebufferTrait for Framebuffer<L> {
unsafe impl<L> FramebufferTrait for Framebuffer<L> where L: RenderPass {
type RenderPass = L;
#[inline]

View File

@ -26,7 +26,7 @@ use vk;
use VulkanObject;
pub unsafe trait Framebuffer: VulkanObject<Object = vk::Framebuffer> {
type RenderPass;
type RenderPass: RenderPass;
// TODO: don't return an Arc
fn render_pass(&self) -> &Arc<Self::RenderPass>;