Example #1
0
        public void Init(PipelineLayout pipelineLayout)
        {
            this.pipelineLayout = pipelineLayout;

            int count = pipelineLayout.ResourceLayout.Length;

            ResourceSet = new DescriptorSet[count];
            if (count <= 0)
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                ResourceSet[i] = new DescriptorSet(pipelineLayout.ResourceLayout[i]);

                var resLayout = pipelineLayout.ResourceLayout[i];
                foreach (var binding in resLayout.Bindings)
                {
                    if (binding.IsInlineUniformBlock && binding.resourceInfo != null)
                    {
                        if (inlineUniformBlocks == null)
                        {
                            inlineUniformBlocks = new List <InlineUniformBlock>();
                        }

                        var inlineUniformBlock = new InlineUniformBlock(binding.resourceInfo);
                        inlineUniformBlock.descriptorSet = ResourceSet[i];
                        ResourceSet[i].Bind(binding.binding, inlineUniformBlock);
                        inlineUniformBlocks.Add(inlineUniformBlock);
                    }
                }
            }

            if (pipelineLayout.PushConstantNames != null)
            {
                for (int i = 0; i < pipelineLayout.PushConstantNames.Count; i++)
                {
                    var constName = pipelineLayout.PushConstantNames[i];
                    if (constName.StartsWith("g_"))
                    {
                        continue;
                    }

                    var pushConst = pipelineLayout.PushConstant[i];
                    if (pushConst.offset + pushConst.size > Device.MaxPushConstantsSize)
                    {
                        Log.Error("PushConst out of range" + constName);
                        continue;
                    }

                    if (pushConst.offset < minPushConstRange)
                    {
                        minPushConstRange = pushConst.offset;
                    }

                    if (pushConst.offset + pushConst.size > maxPushConstRange)
                    {
                        maxPushConstRange = pushConst.offset + pushConst.size;
                    }
                }
            }
        }
Example #2
0
 public PipelineResourceSet(PipelineLayout pipelineLayout)
 {
     Init(pipelineLayout);
 }