Esempio n. 1
0
        public AmtPipelineLayoutStageResource(
            MgShaderStageFlagBits mask,
            AmtDescriptorSetLayout setLayout,
            IAmtDescriptorSetBindingLocator locator)
        {
            var vertBuffers = new SortedList <uint, AmtPipelineLayoutBufferBinding>();
            var textures    = new SortedList <uint, AmtPipelineLayoutTextureBinding>();
            var samplers    = new SortedList <uint, AmtPipelineLayoutSamplerBinding>();

            Stage = mask;
            Initialise(mask, setLayout, locator, vertBuffers, textures, samplers);
            ConvertToArrays(vertBuffers, textures, samplers);
        }
Esempio n. 2
0
        public void Initialize(AmtDescriptorSetLayout layout)
        {
            // TODO : create a dictionary to find which location to bind
            //PipelineResources = layout.PipelineResources;

            var computeResources = new AmtPipelineLayoutStageResource(MgShaderStageFlagBits.COMPUTE_BIT, layout, Locator);

            Compute = new AmtDescriptorSetBindingMap(computeResources);

            var vertResources = new AmtPipelineLayoutStageResource(MgShaderStageFlagBits.VERTEX_BIT, layout, Locator);

            Vertex = new AmtDescriptorSetBindingMap(vertResources);

            var fragResources = new AmtPipelineLayoutStageResource(MgShaderStageFlagBits.FRAGMENT_BIT, layout, Locator);

            Fragment = new AmtDescriptorSetBindingMap(fragResources);
        }
Esempio n. 3
0
        void Initialise(
            MgShaderStageFlagBits mask,
            AmtDescriptorSetLayout setLayout,
            IAmtDescriptorSetBindingLocator locator,
            SortedList <uint, AmtPipelineLayoutBufferBinding> vertBuffers,
            SortedList <uint, AmtPipelineLayoutTextureBinding> textures,
            SortedList <uint, AmtPipelineLayoutSamplerBinding> samplers
            )
        {
            for (var i = 0; i < setLayout.PipelineResources.Length; ++i)
            {
                var resource = setLayout.PipelineResources[i];

                AmtDescriptorSetUpdateKey item = null;
                if (locator != null)
                {
                    if (!locator.TryGetValue(resource.Binding, out item))
                    {
                        item = locator.Add(resource.Binding);
                    }
                }

                if ((resource.Stage & mask) == mask)
                {
                    switch (resource.DescriptorType)
                    {
                    case MgDescriptorType.COMBINED_IMAGE_SAMPLER:
                    case MgDescriptorType.SAMPLED_IMAGE:

                        var texture = new AmtPipelineLayoutTextureBinding
                        {
                            Binding        = resource.Binding,
                            DescriptorType = resource.DescriptorType,
                        };

                        var sampler = new AmtPipelineLayoutSamplerBinding
                        {
                            Binding        = resource.Binding,
                            DescriptorType = resource.DescriptorType,
                        };

                        if (locator != null)
                        {
                            var nextTextureIndex = (uint)textures.Count;
                            var nextSamplerIndex = (uint)samplers.Count;
                            item.SetCombinedSampler(mask, nextTextureIndex, nextSamplerIndex);
                        }

                        textures.Add(texture.Binding, texture);
                        samplers.Add(sampler.Binding, sampler);

                        break;

                    case MgDescriptorType.STORAGE_BUFFER:
                    case MgDescriptorType.STORAGE_BUFFER_DYNAMIC:
                    {
                        var sBuffer = new AmtPipelineLayoutBufferBinding
                        {
                            Binding         = resource.Binding,
                            Category        = AmtPipelineLayoutBufferBindingCategory.StorageBuffer,
                            DescriptorCount = resource.DescriptorCount,
                        };

                        if (locator != null)
                        {
                            var nextOffset = (uint)vertBuffers.Count;
                            item.SetBuffer(mask, nextOffset);
                        }

                        vertBuffers.Add(sBuffer.Binding, sBuffer);
                    }
                    break;

                    case MgDescriptorType.UNIFORM_BUFFER:
                    case MgDescriptorType.UNIFORM_BUFFER_DYNAMIC:
                    {
                        var vBuffer = new AmtPipelineLayoutBufferBinding
                        {
                            Binding         = resource.Binding,
                            Category        = AmtPipelineLayoutBufferBindingCategory.UniformBuffer,
                            DescriptorCount = resource.DescriptorCount,
                        };

                        if (locator != null)
                        {
                            var nextOffset = (uint)vertBuffers.Count;
                            item.SetBuffer(mask, nextOffset);
                        }

                        vertBuffers.Add(vBuffer.Binding, vBuffer);
                    }
                    break;
                    }
                }
            }
        }
Esempio n. 4
0
 public Result CreateDescriptorSetLayout(MgDescriptorSetLayoutCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgDescriptorSetLayout pSetLayout)
 {
     pSetLayout = new AmtDescriptorSetLayout(pCreateInfo);
     return(Result.SUCCESS);
 }