Skip to content

Commit

Permalink
gl,vk,empty: Adopt dynamic offset API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
msiglreith committed Jun 5, 2018
1 parent abc7966 commit 9b6d27f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 31 deletions.
8 changes: 6 additions & 2 deletions src/backend/empty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,12 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
unimplemented!()
}

fn bind_graphics_descriptor_sets<I>(&mut self, _: &(), _: usize, _: I)
fn bind_graphics_descriptor_sets<I, J>(&mut self, _: &(), _: usize, _: I, _: J)
where
I: IntoIterator,
I::Item: Borrow<()>,
J: IntoIterator,
J::Item: Borrow<command::DescriptorSetOffset>,
{
unimplemented!()
}
Expand All @@ -575,10 +577,12 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
unimplemented!()
}

fn bind_compute_descriptor_sets<I>(&mut self, _: &(), _: usize, _: I)
fn bind_compute_descriptor_sets<I, J>(&mut self, _: &(), _: usize, _: I, _: J)
where
I: IntoIterator,
I::Item: Borrow<()>,
J: IntoIterator,
J::Item: Borrow<command::DescriptorSetOffset>,
{
unimplemented!()
}
Expand Down
22 changes: 14 additions & 8 deletions src/backend/gl/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,14 +834,17 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
self.update_blend_targets(blend_targets);
}

fn bind_graphics_descriptor_sets<T>(
fn bind_graphics_descriptor_sets<I, J>(
&mut self,
_layout: &n::PipelineLayout,
_first_set: usize,
_sets: T,
_sets: I,
_offsets: J,
) where
T: IntoIterator,
T::Item: Borrow<n::DescriptorSet>,
I: IntoIterator,
I::Item: Borrow<n::DescriptorSet>,
J: IntoIterator,
J::Item: Borrow<command::DescriptorSetOffset>,
{
// TODO
}
Expand All @@ -857,14 +860,17 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
}
}

fn bind_compute_descriptor_sets<T>(
fn bind_compute_descriptor_sets<I, J>(
&mut self,
_layout: &n::PipelineLayout,
_first_set: usize,
_sets: T,
_sets: I,
_offsets: J,
) where
T: IntoIterator,
T::Item: Borrow<n::DescriptorSet>,
I: IntoIterator,
I::Item: Borrow<n::DescriptorSet>,
J: IntoIterator,
J::Item: Borrow<command::DescriptorSetOffset>,
{
// TODO
}
Expand Down
41 changes: 26 additions & 15 deletions src/backend/vulkan/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ where
}

impl CommandBuffer {
fn bind_descriptor_sets<T>(
fn bind_descriptor_sets<I, J>(
&mut self,
bind_point: vk::PipelineBindPoint,
layout: &n::PipelineLayout,
first_set: usize,
sets: T,
sets: I,
offsets: J,
) where
T: IntoIterator,
T::Item: Borrow<n::DescriptorSet>,
I: IntoIterator,
I::Item: Borrow<n::DescriptorSet>,
J: IntoIterator,
J::Item: Borrow<com::DescriptorSetOffset>,
{
let sets: SmallVec<[vk::DescriptorSet; 16]> = sets.into_iter().map(|set| set.borrow().raw).collect();
let dynamic_offsets = &[]; // TODO
let sets: SmallVec<[_; 16]> = sets.into_iter().map(|set| set.borrow().raw).collect();
let dynamic_offsets: SmallVec<[_; 16]> = offsets.into_iter().map(|offset| *offset.borrow()).collect();

unsafe {
self.device.0.cmd_bind_descriptor_sets(
Expand All @@ -73,7 +76,7 @@ impl CommandBuffer {
layout.raw,
first_set as u32,
&sets,
dynamic_offsets,
&dynamic_offsets,
);
}
}
Expand Down Expand Up @@ -605,20 +608,24 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
}
}

fn bind_graphics_descriptor_sets<T>(
fn bind_graphics_descriptor_sets<I, J>(
&mut self,
layout: &n::PipelineLayout,
first_set: usize,
sets: T,
sets: I,
offsets: J,
) where
T: IntoIterator,
T::Item: Borrow<n::DescriptorSet>,
I: IntoIterator,
I::Item: Borrow<n::DescriptorSet>,
J: IntoIterator,
J::Item: Borrow<com::DescriptorSetOffset>,
{
self.bind_descriptor_sets(
vk::PipelineBindPoint::Graphics,
layout,
first_set,
sets,
offsets,
);
}

Expand All @@ -632,20 +639,24 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
}
}

fn bind_compute_descriptor_sets<T>(
fn bind_compute_descriptor_sets<I, J>(
&mut self,
layout: &n::PipelineLayout,
first_set: usize,
sets: T,
sets: I,
offsets: J,
) where
T: IntoIterator,
T::Item: Borrow<n::DescriptorSet>,
I: IntoIterator,
I::Item: Borrow<n::DescriptorSet>,
J: IntoIterator,
J::Item: Borrow<com::DescriptorSetOffset>,
{
self.bind_descriptor_sets(
vk::PipelineBindPoint::Compute,
layout,
first_set,
sets,
offsets,
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/hal/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use std::borrow::Borrow;

use {Backend, WorkGroupCount};
use buffer::Offset;
use command::raw::DescriptorSetOffset;
use queue::capability::{Compute, Supports};
use super::{CommandBuffer, RawCommandBuffer, Shot, Level};
use super::{CommandBuffer, DescriptorSetOffset, RawCommandBuffer, Shot, Level};

impl<'a, B: Backend, C: Supports<Compute>, S: Shot, L: Level> CommandBuffer<'a, B, C, S, L> {
/// Identical to the `RawCommandBuffer` method of the same name.
Expand Down
3 changes: 1 addition & 2 deletions src/hal/src/command/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ use std::ops::Range;
use Backend;
use {image, pso};
use buffer::IndexBufferView;
use command::raw::DescriptorSetOffset;
use query::{Query, QueryControl, QueryId};
use queue::capability::{Graphics, GraphicsOrCompute, Supports};
use super::{
CommandBuffer, RawCommandBuffer,
RenderPassInlineEncoder, RenderPassSecondaryEncoder,
Shot, Level, Primary,
ClearColorRaw, ClearDepthStencilRaw, ClearValueRaw,
ClearColorRaw, ClearDepthStencilRaw, ClearValueRaw, DescriptorSetOffset,
};


Expand Down
3 changes: 1 addition & 2 deletions src/hal/src/command/render_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use std::marker::PhantomData;

use {buffer, pso};
use {Backend, DrawCount, IndexCount, InstanceCount, VertexCount, VertexOffset};
use command::raw::DescriptorSetOffset;
use queue::{Supports, Graphics};
use super::{
AttachmentClear, ClearValue, ClearValueRaw, CommandBuffer, RawCommandBuffer,
Shot, Level, Primary, Secondary, Submittable, Submit
Shot, Level, Primary, Secondary, Submittable, Submit, DescriptorSetOffset,
};

/// Specifies how commands for the following renderpasses will be recorded.
Expand Down

0 comments on commit 9b6d27f

Please sign in to comment.