Exemplo n.º 1
0
        public unsafe DescriptorSet(DescriptorPool descriptorPool, uint setCount = 1)
        {
            _device         = descriptorPool.Device;
            _descriptorPool = descriptorPool;

            var layouts = new NativeList <VkDescriptorSetLayout>(setCount);

            for (int i = 0; i < setCount; i++)
            {
                layouts.Add(descriptorPool.Layout.Handle);
            }

            var allocateInfo = new VkDescriptorSetAllocateInfo
            {
                sType              = VkStructureType.DescriptorSetAllocateInfo,
                descriptorPool     = descriptorPool.Handle,
                descriptorSetCount = setCount,
                pSetLayouts        = (VkDescriptorSetLayout *)layouts.Data.ToPointer()
            };

            VkDescriptorSet descriptorSet;

            if (VulkanNative.vkAllocateDescriptorSets(
                    _device.Handle,
                    &allocateInfo,
                    &descriptorSet
                    ) != VkResult.Success)
            {
                throw new Exception("failed to allocate descriptor sets");
            }
            _handle = descriptorSet;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new descriptor type binding
        /// </summary>
        /// <param name="key">key for this descriptor set</param>
        /// <param name="layout">what type of data does this descriptor set have?</param>
        public virtual void InsertKey(
            string key,
            API.DescriptorLayout layout
            )
        {
            if (_handle.ContainsKey(key))
            {
                return;
            }
            if (layout == null)
            {
                _handle[key] = new DescriptorObject();
                return;
            }

            var pool = new API.DescriptorPool(layout, 1);

            _handle[key] = new DescriptorObject
            {
                Layout         = layout,
                Pool           = pool,
                Set            = new API.DescriptorSet(pool),
                StagingBuffers = new API.Buffer[layout.Bindings.Count],
                Buffers        = new API.Buffer[layout.Bindings.Count],
                Images         = new API.Image[layout.Bindings.Count],
                ImageViews     = new API.ImageView[layout.Bindings.Count],
                Samplers       = new API.Sampler[layout.Bindings.Count],
                CommandBuffer  = new API.CommandBuffer[layout.Bindings.Count]
            };
        }