Advertisement
Guest User

Untitled

a guest
May 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 3.49 KB | None | 0 0
  1. // QUESTION: This is in the vertex shader.. it doesn't seem to matter if binding = 0 or 2
  2. // VERTEX SHADER: https://github.com/aclysma/test_rendy_imgui/blob/master/assets/gui.vert
  3. /*
  4. layout(set = 0, binding = 2) uniform Args {
  5.     mat4 mvp;
  6. };
  7. */
  8.  
  9. // Descriptor layout() impl
  10. fn layout(&self) -> Layout {
  11.         return Layout {
  12.             sets: vec![SetLayout {
  13.                 bindings: vec![
  14.                     gfx_hal::pso::DescriptorSetLayoutBinding {
  15.                         binding: 0,
  16.                         ty: gfx_hal::pso::DescriptorType::SampledImage,
  17.                         count: 1,
  18.                         stage_flags: gfx_hal::pso::ShaderStageFlags::FRAGMENT,
  19.                         immutable_samplers: false,
  20.                     },
  21.                     gfx_hal::pso::DescriptorSetLayoutBinding {
  22.                         binding: 1,
  23.                         ty: gfx_hal::pso::DescriptorType::Sampler,
  24.                         count: 1,
  25.                         stage_flags: gfx_hal::pso::ShaderStageFlags::FRAGMENT,
  26.                         immutable_samplers: false,
  27.                     },
  28.                     gfx_hal::pso::DescriptorSetLayoutBinding {
  29. // 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
  30.                         binding: 2,
  31.                         ty: gfx_hal::pso::DescriptorType::UniformBuffer,
  32.                         count: 1,
  33.                         stage_flags: gfx_hal::pso::ShaderStageFlags::VERTEX,
  34.                         immutable_samplers: false,
  35.                     },
  36.                 ],
  37.             }],
  38.             push_constants: vec![/*(gfx_hal::pso::ShaderStageFlags::VERTEX, 0..16)*/],
  39.         };
  40.     }
  41. }
  42.  
  43. // Descriptor build() impl
  44.     fn build<'a>(
  45.        self,
  46.        _ctx: &GraphContext<B>,
  47.        factory: &mut Factory<B>,
  48.        queue: QueueId,
  49.        aux: &Resources,
  50.        buffers: Vec<NodeBuffer>,
  51.        images: Vec<NodeImage>,
  52.        set_layouts: &[Handle<DescriptorSetLayout<B>>],
  53.    ) -> Result<ImguiRenderPipeline<B>, failure::Error> {
  54.        assert!(buffers.is_empty());
  55.        assert!(images.is_empty());
  56.        assert_eq!(set_layouts.len(), 1);
  57.  
  58.        // other setup first...
  59.        unsafe {
  60.            use gfx_hal::device::Device;
  61.            factory.device().write_descriptor_sets(vec![
  62.                gfx_hal::pso::DescriptorSetWrite {
  63.                    set: descriptor_set.raw(),
  64.                    binding: 0,
  65.                    array_offset: 0,
  66.                    descriptors: vec![gfx_hal::pso::Descriptor::Image(
  67.                        texture.view().raw(),
  68.                        gfx_hal::image::Layout::ShaderReadOnlyOptimal,
  69.                    )],
  70.                },
  71.                gfx_hal::pso::DescriptorSetWrite {
  72.                    set: descriptor_set.raw(),
  73.                    binding: 1,
  74.                    array_offset: 0,
  75.                    descriptors: vec![gfx_hal::pso::Descriptor::Sampler(texture.sampler().raw())],
  76.                },
  77.                gfx_hal::pso::DescriptorSetWrite {
  78.                    set: descriptor_set.raw(),
  79. // QUESTION: Does this binding ID matter?
  80.                    binding: 0,
  81.                    array_offset: 0,
  82.                    descriptors: vec![gfx_hal::pso::Descriptor::Buffer(
  83.                        uniform_buf.raw(),
  84.                        Some(0)..Some(UNIFORM_SIZE),
  85.                    )],
  86.                },
  87.            ]);
  88.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement