コード例 #1
0
        public MTLResourceLayout(ref ResourceLayoutDescription description, MTLGraphicsDevice gd)
            : base(ref description)
        {
            ResourceLayoutElementDescription[] elements = description.Elements;
#if !VALIDATE_USAGE
            ResourceKinds = new ResourceKind[elements.Length];
            for (int i = 0; i < elements.Length; i++)
            {
                ResourceKinds[i] = elements[i].Kind;
            }
#endif

            _bindingInfosByVdIndex = new ResourceBindingInfo[elements.Length];

            uint bufferIndex  = 0;
            uint texIndex     = 0;
            uint samplerIndex = 0;

            for (int i = 0; i < _bindingInfosByVdIndex.Length; i++)
            {
                uint slot;
                switch (elements[i].Kind)
                {
                case ResourceKind.UniformBuffer:
                    slot = bufferIndex++;
                    break;

                case ResourceKind.StructuredBufferReadOnly:
                    slot = bufferIndex++;
                    break;

                case ResourceKind.StructuredBufferReadWrite:
                    slot = bufferIndex++;
                    break;

                case ResourceKind.TextureReadOnly:
                    slot = texIndex++;
                    break;

                case ResourceKind.TextureReadWrite:
                    slot = texIndex++;
                    break;

                case ResourceKind.Sampler:
                    slot = samplerIndex++;
                    break;

                default: throw Illegal.Value <ResourceKind>();
                }

                _bindingInfosByVdIndex[i] = new ResourceBindingInfo(slot, elements[i].Stages, elements[i].Kind);
            }

            BufferCount  = bufferIndex;
            TextureCount = texIndex;
            SamplerCount = samplerIndex;
        }
コード例 #2
0
ファイル: BackendInfoMetal.cs プロジェクト: feliwir/veldrid
 internal BackendInfoMetal(MTLGraphicsDevice gd)
 {
     _gd         = gd;
     _featureSet = new ReadOnlyCollection <MTLFeatureSet>(_gd.MetalFeatures.ToArray());
 }
コード例 #3
0
 public MTLResourceSet(ref ResourceSetDescription description, MTLGraphicsDevice gd)
     : base(ref description)
 {
     Resources = Util.ShallowClone(description.BoundResources);
     Layout    = Util.AssertSubtype <ResourceLayout, MTLResourceLayout>(description.Layout);
 }