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; }
public D3D11ResourceLayout(ref ResourceLayoutDescription description) : base(ref description) { ResourceLayoutElementDescription[] elements = description.Elements; _bindingInfosByVdIndex = new ResourceBindingInfo[elements.Length]; int cbIndex = 0; int texIndex = 0; int samplerIndex = 0; int unorderedAccessIndex = 0; for (int i = 0; i < _bindingInfosByVdIndex.Length; i++) { int slot; switch (elements[i].Kind) { case ResourceKind.UniformBuffer: slot = cbIndex++; break; case ResourceKind.StructuredBufferReadOnly: slot = texIndex++; break; case ResourceKind.StructuredBufferReadWrite: slot = unorderedAccessIndex++; break; case ResourceKind.TextureReadOnly: slot = texIndex++; break; case ResourceKind.TextureReadWrite: slot = unorderedAccessIndex++; break; case ResourceKind.Sampler: slot = samplerIndex++; break; default: throw Illegal.Value <ResourceKind>(); } _bindingInfosByVdIndex[i] = new ResourceBindingInfo( slot, elements[i].Stages, elements[i].Kind, (elements[i].Options & ResourceLayoutElementOptions.DynamicBinding) != 0); } UniformBufferCount = cbIndex; StorageBufferCount = unorderedAccessIndex; TextureCount = texIndex; SamplerCount = samplerIndex; }
public D3D11ResourceLayout(ref ResourceLayoutDescription description) { ResourceLayoutElementDescription[] elements = description.Elements; _bindingInfosByVdIndex = new ResourceBindingInfo[elements.Length]; int cbIndex = 0; int texIndex = 0; int samplerIndex = 0; for (int i = 0; i < _bindingInfosByVdIndex.Length; i++) { int slot; switch (elements[i].Kind) { case ResourceKind.Uniform: slot = cbIndex++; break; case ResourceKind.Texture: slot = texIndex++; break; case ResourceKind.Sampler: slot = samplerIndex++; break; default: throw Illegal.Value <ResourceKind>(); } _bindingInfosByVdIndex[i] = new ResourceBindingInfo(slot, elements[i].Stages); } UniformBufferCount = cbIndex; TextureCount = texIndex; SamplerCount = samplerIndex; }