Skip to content

Commit d7e0676

Browse files
committed
Adds basic descriptor set support to the opengl backend
Signed-off-by: Hal Gentz <[email protected]>
1 parent 0e1c915 commit d7e0676

File tree

7 files changed

+403
-28
lines changed

7 files changed

+403
-28
lines changed

src/backend/gl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ gfx_gl = "0.5"
2424
gfx-hal = { path = "../../hal", version = "0.1" }
2525
smallvec = "0.6"
2626
glutin = { version = "0.16", optional = true }
27-
spirv_cross = "0.8"
27+
spirv_cross = "0.9.2"

src/backend/gl/src/command.rs

+48-5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ pub enum Command {
108108
CopySurfaceToBuffer(n::Surface, n::RawBuffer, command::BufferImageCopy),
109109
CopyImageToTexture(n::ImageKind, n::Texture, command::ImageCopy),
110110
CopyImageToSurface(n::ImageKind, n::Surface, command::ImageCopy),
111+
112+
BindBufferRange(gl::types::GLenum, gl::types::GLuint, n::RawBuffer, gl::types::GLintptr, gl::types::GLsizeiptr),
113+
BindTexture(gl::types::GLenum, n::Texture),
114+
BindSampler(gl::types::GLuint, n::Texture),
111115
}
112116

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

863867
fn bind_graphics_descriptor_sets<I, J>(
864868
&mut self,
865-
_layout: &n::PipelineLayout,
866-
_first_set: usize,
867-
_sets: I,
868-
_offsets: J,
869+
layout: &n::PipelineLayout,
870+
first_set: usize,
871+
sets: I,
872+
offsets: J,
869873
) where
870874
I: IntoIterator,
871875
I::Item: Borrow<n::DescriptorSet>,
872876
J: IntoIterator,
873877
J::Item: Borrow<command::DescriptorSetOffset>,
874878
{
875-
// TODO
879+
assert!(offsets.into_iter().next().is_none()); // TODO: offsets unsupported
880+
881+
let mut set = first_set as _;
882+
let drd = &*layout.desc_remap_data.read().unwrap();
883+
884+
for desc_set in sets {
885+
let desc_set = desc_set.borrow();
886+
for new_binding in &*desc_set.bindings.lock().unwrap() {
887+
match new_binding {
888+
n::DescSetBindings::Buffer {ty: btype, binding, buffer, offset, size} => {
889+
for binding in drd.get_binding(n::BindingTypes::UniformBuffers, set, *binding).unwrap() {
890+
self.push_cmd(Command::BindBufferRange(
891+
gl::UNIFORM_BUFFER,
892+
*binding,
893+
*buffer,
894+
*offset,
895+
*size,
896+
))
897+
}
898+
}
899+
n::DescSetBindings::Texture(binding, texture) => {
900+
for binding in drd.get_binding(n::BindingTypes::Images, set, *binding).unwrap() {
901+
self.push_cmd(Command::BindTexture(
902+
*binding,
903+
*texture,
904+
))
905+
}
906+
}
907+
n::DescSetBindings::Sampler(binding, sampler) => {
908+
for binding in drd.get_binding(n::BindingTypes::Images, set, *binding).unwrap() {
909+
self.push_cmd(Command::BindSampler(
910+
*binding,
911+
*sampler,
912+
))
913+
}
914+
}
915+
}
916+
}
917+
set += 1;
918+
}
876919
}
877920

878921
fn bind_compute_pipeline(&mut self, pipeline: &n::ComputePipeline) {

0 commit comments

Comments
 (0)