Skip to content

Commit

Permalink
Adds basic descriptor set support to the opengl backend
Browse files Browse the repository at this point in the history
Signed-off-by: Hal Gentz <[email protected]>
  • Loading branch information
goddessfreya committed Jun 22, 2018
1 parent 0e1c915 commit d7e0676
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/backend/gl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ gfx_gl = "0.5"
gfx-hal = { path = "../../hal", version = "0.1" }
smallvec = "0.6"
glutin = { version = "0.16", optional = true }
spirv_cross = "0.8"
spirv_cross = "0.9.2"
53 changes: 48 additions & 5 deletions src/backend/gl/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ pub enum Command {
CopySurfaceToBuffer(n::Surface, n::RawBuffer, command::BufferImageCopy),
CopyImageToTexture(n::ImageKind, n::Texture, command::ImageCopy),
CopyImageToSurface(n::ImageKind, n::Surface, command::ImageCopy),

BindBufferRange(gl::types::GLenum, gl::types::GLuint, n::RawBuffer, gl::types::GLintptr, gl::types::GLsizeiptr),
BindTexture(gl::types::GLenum, n::Texture),
BindSampler(gl::types::GLuint, n::Texture),
}

pub type FrameBufferTarget = gl::types::GLenum;
Expand Down Expand Up @@ -862,17 +866,56 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {

fn bind_graphics_descriptor_sets<I, J>(
&mut self,
_layout: &n::PipelineLayout,
_first_set: usize,
_sets: I,
_offsets: J,
layout: &n::PipelineLayout,
first_set: usize,
sets: I,
offsets: J,
) where
I: IntoIterator,
I::Item: Borrow<n::DescriptorSet>,
J: IntoIterator,
J::Item: Borrow<command::DescriptorSetOffset>,
{
// TODO
assert!(offsets.into_iter().next().is_none()); // TODO: offsets unsupported

let mut set = first_set as _;
let drd = &*layout.desc_remap_data.read().unwrap();

for desc_set in sets {
let desc_set = desc_set.borrow();
for new_binding in &*desc_set.bindings.lock().unwrap() {
match new_binding {
n::DescSetBindings::Buffer {ty: btype, binding, buffer, offset, size} => {
for binding in drd.get_binding(n::BindingTypes::UniformBuffers, set, *binding).unwrap() {
self.push_cmd(Command::BindBufferRange(
gl::UNIFORM_BUFFER,
*binding,
*buffer,
*offset,
*size,
))
}
}
n::DescSetBindings::Texture(binding, texture) => {
for binding in drd.get_binding(n::BindingTypes::Images, set, *binding).unwrap() {
self.push_cmd(Command::BindTexture(
*binding,
*texture,
))
}
}
n::DescSetBindings::Sampler(binding, sampler) => {
for binding in drd.get_binding(n::BindingTypes::Images, set, *binding).unwrap() {
self.push_cmd(Command::BindSampler(
*binding,
*sampler,
))
}
}
}
}
set += 1;
}
}

fn bind_compute_pipeline(&mut self, pipeline: &n::ComputePipeline) {
Expand Down
Loading

0 comments on commit d7e0676

Please sign in to comment.