Ejemplo n.º 1
0
        public AmtDescriptorSetUpdateKey Add(uint binding)
        {
            var output = new AmtDescriptorSetUpdateKey {
            };

            mUpdates.Add(binding, output);
            return(output);
        }
Ejemplo n.º 2
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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public bool TryGetValue(uint binding, out AmtDescriptorSetUpdateKey result)
 {
     return(mUpdates.TryGetValue(binding, out result));
 }