Ejemplo n.º 1
0
        void CreateDescriptorSet()
        {
            var layouts = new List <VkDescriptorSetLayout> {
                descriptorSetLayout
            };
            var info = new VkDescriptorSetAllocateInfo();

            info.setLayouts = layouts;

            descriptorSet = descriptorPool.Allocate(info)[0];

            var bufferInfo = new VkDescriptorBufferInfo();

            bufferInfo.buffer = uniformBuffer;
            bufferInfo.offset = 0;
            bufferInfo.range  = Interop.SizeOf <UniformBufferObject>();

            var descriptorWrites = new List <VkWriteDescriptorSet>();

            descriptorWrites.Add(new VkWriteDescriptorSet());
            descriptorWrites[0].dstSet          = descriptorSet;
            descriptorWrites[0].dstBinding      = 0;
            descriptorWrites[0].dstArrayElement = 0;
            descriptorWrites[0].descriptorType  = VkDescriptorType.UniformBuffer;
            descriptorWrites[0].bufferInfo      = new List <VkDescriptorBufferInfo> {
                bufferInfo
            };

            descriptorSet.Update(descriptorWrites, null);
        }
Ejemplo n.º 2
0
        void CreateDescriptorSet()
        {
            var layouts = new List <VkDescriptorSetLayout> {
                descriptorSetLayout
            };
            var info = new VkDescriptorSetAllocateInfo();

            info.setLayouts = layouts;

            descriptorSet = descriptorPool.Allocate(info)[0];

            var bufferInfo = new VkDescriptorBufferInfo();

            bufferInfo.buffer = uniformBuffer;
            bufferInfo.offset = 0;
            bufferInfo.range  = Interop.SizeOf <UniformBufferObject>();

            var imageInfo = new VkDescriptorImageInfo();

            imageInfo.imageLayout = VkImageLayout.ShaderReadOnlyOptimal;
            imageInfo.imageView   = textureImageView;
            imageInfo.sampler     = textureSampler;

            var descriptorWrites = new List <VkWriteDescriptorSet>();

            descriptorWrites.Add(new VkWriteDescriptorSet());
            descriptorWrites[0].dstSet          = descriptorSet;
            descriptorWrites[0].dstBinding      = 0;
            descriptorWrites[0].dstArrayElement = 0;
            descriptorWrites[0].descriptorType  = VkDescriptorType.UniformBuffer;
            descriptorWrites[0].bufferInfo      = new List <VkDescriptorBufferInfo> {
                bufferInfo
            };

            descriptorWrites.Add(new VkWriteDescriptorSet());
            descriptorWrites[1].dstSet          = descriptorSet;
            descriptorWrites[1].dstBinding      = 1;
            descriptorWrites[1].dstArrayElement = 0;
            descriptorWrites[1].descriptorType  = VkDescriptorType.CombinedImageSampler;
            descriptorWrites[1].imageInfo       = new List <VkDescriptorImageInfo> {
                imageInfo
            };

            descriptorSet.Update(descriptorWrites, null);
        }