Skip to content

Commit

Permalink
Merge #2071
Browse files Browse the repository at this point in the history
2071: Remaping descriptor sets in the gl backend r=kvark a=ZeGentzy

I'll rebase off master when I'm done.

Uniforms in gl only have a bindings field, not a set one. This means that for shaders that use multiple sets to work, we must change where we are binding them.

See page 14 for what I mean: https://www.khronos.org/assets/uploads/developers/library/2016-vulkan-devday-uk/4-Using-spir-v-with-spirv-cross.pdf

PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: Hal Gentz <[email protected]>
  • Loading branch information
bors[bot] and goddessfreya committed Jun 20, 2018
2 parents 842b931 + 6c1a9c6 commit d460d32
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 27 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.15", 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 d460d32

Please sign in to comment.