Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // QUESTION: This is in the vertex shader.. it doesn't seem to matter if binding = 0 or 2
- // VERTEX SHADER: https://github.com/aclysma/test_rendy_imgui/blob/master/assets/gui.vert
- /*
- layout(set = 0, binding = 2) uniform Args {
- mat4 mvp;
- };
- */
- // Descriptor layout() impl
- fn layout(&self) -> Layout {
- return Layout {
- sets: vec![SetLayout {
- bindings: vec![
- gfx_hal::pso::DescriptorSetLayoutBinding {
- binding: 0,
- ty: gfx_hal::pso::DescriptorType::SampledImage,
- count: 1,
- stage_flags: gfx_hal::pso::ShaderStageFlags::FRAGMENT,
- immutable_samplers: false,
- },
- gfx_hal::pso::DescriptorSetLayoutBinding {
- binding: 1,
- ty: gfx_hal::pso::DescriptorType::Sampler,
- count: 1,
- stage_flags: gfx_hal::pso::ShaderStageFlags::FRAGMENT,
- immutable_samplers: false,
- },
- gfx_hal::pso::DescriptorSetLayoutBinding {
- // QUESTION: does this binding ID matter? It will crash if it's 0, but I think it's just because there is already a binding above
- binding: 2,
- ty: gfx_hal::pso::DescriptorType::UniformBuffer,
- count: 1,
- stage_flags: gfx_hal::pso::ShaderStageFlags::VERTEX,
- immutable_samplers: false,
- },
- ],
- }],
- push_constants: vec![/*(gfx_hal::pso::ShaderStageFlags::VERTEX, 0..16)*/],
- };
- }
- }
- // Descriptor build() impl
- fn build<'a>(
- self,
- _ctx: &GraphContext<B>,
- factory: &mut Factory<B>,
- queue: QueueId,
- aux: &Resources,
- buffers: Vec<NodeBuffer>,
- images: Vec<NodeImage>,
- set_layouts: &[Handle<DescriptorSetLayout<B>>],
- ) -> Result<ImguiRenderPipeline<B>, failure::Error> {
- assert!(buffers.is_empty());
- assert!(images.is_empty());
- assert_eq!(set_layouts.len(), 1);
- // other setup first...
- unsafe {
- use gfx_hal::device::Device;
- factory.device().write_descriptor_sets(vec![
- gfx_hal::pso::DescriptorSetWrite {
- set: descriptor_set.raw(),
- binding: 0,
- array_offset: 0,
- descriptors: vec![gfx_hal::pso::Descriptor::Image(
- texture.view().raw(),
- gfx_hal::image::Layout::ShaderReadOnlyOptimal,
- )],
- },
- gfx_hal::pso::DescriptorSetWrite {
- set: descriptor_set.raw(),
- binding: 1,
- array_offset: 0,
- descriptors: vec![gfx_hal::pso::Descriptor::Sampler(texture.sampler().raw())],
- },
- gfx_hal::pso::DescriptorSetWrite {
- set: descriptor_set.raw(),
- // QUESTION: Does this binding ID matter?
- binding: 0,
- array_offset: 0,
- descriptors: vec![gfx_hal::pso::Descriptor::Buffer(
- uniform_buf.raw(),
- Some(0)..Some(UNIFORM_SIZE),
- )],
- },
- ]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement