public ResourceGroupDescription(DescriptorSetLayoutBuilder descriptorSetLayout, EffectConstantBufferDescription constantBufferReflection) : this() { DescriptorSetLayout = descriptorSetLayout; ConstantBufferReflection = constantBufferReflection; // We combine both hash for DescriptorSet and cbuffer itself (if it exists) Hash = descriptorSetLayout.Hash; if (constantBufferReflection != null) { ObjectId.Combine(ref Hash, ref constantBufferReflection.Hash, out Hash); } }
public static EffectDescriptorSetReflection New(GraphicsDevice graphicsDevice, EffectBytecode effectBytecode, List <string> effectDescriptorSetSlots, string defaultSetSlot) { // Find resource groups // TODO: We should precompute most of that at compile time in BytecodeReflection // just waiting for format to be more stable var descriptorSetLayouts = new EffectDescriptorSetReflection { DefaultSetSlot = defaultSetSlot }; foreach (var effectDescriptorSetSlot in effectDescriptorSetSlots) { // Find all resources related to this slot name // NOTE: Ordering is mirrored by GLSL layout in Vulkan var descriptorSetLayoutBuilder = new DescriptorSetLayoutBuilder(); bool hasBindings = false; foreach (var resourceBinding in effectBytecode.Reflection.ResourceBindings .Where(x => x.ResourceGroup == effectDescriptorSetSlot || (effectDescriptorSetSlot == defaultSetSlot && (x.ResourceGroup == null || x.ResourceGroup == "Globals"))) .GroupBy(x => new { Key = x.KeyInfo.Key, Class = x.Class, Type = x.Type, ElementType = x.ElementType.Type, SlotCount = x.SlotCount, LogicalGroup = x.LogicalGroup }) .OrderBy(x => x.Key.Class == EffectParameterClass.ConstantBuffer ? 0 : 1)) // Note: Putting cbuffer first for now { SamplerState samplerState = null; if (resourceBinding.Key.Class == EffectParameterClass.Sampler) { var matchingSamplerState = effectBytecode.Reflection.SamplerStates.FirstOrDefault(x => x.Key == resourceBinding.Key.Key); if (matchingSamplerState != null) { samplerState = SamplerState.New(graphicsDevice, matchingSamplerState.Description); } } hasBindings = true; descriptorSetLayoutBuilder.AddBinding(resourceBinding.Key.Key, resourceBinding.Key.LogicalGroup, resourceBinding.Key.Class, resourceBinding.Key.Type, resourceBinding.Key.ElementType, resourceBinding.Key.SlotCount, samplerState); } descriptorSetLayouts.AddLayout(effectDescriptorSetSlot, hasBindings ? descriptorSetLayoutBuilder : null); } return(descriptorSetLayouts); }
private DescriptorSetLayout(GraphicsDevice device, DescriptorSetLayoutBuilder builder) { BindingOffsets = new int[builder.ElementCount]; int currentBindingOffset = 0; foreach (var entry in builder.Entries) { // We will both setup BindingOffsets and increment SamplerCount/SrvCount at the same time if (entry.Class == EffectParameterClass.Sampler) { for (int i = 0; i < entry.ArraySize; ++i) { BindingOffsets[currentBindingOffset++] = entry.ImmutableSampler != null ? -1 : SamplerCount++ *device.SamplerHandleIncrementSize; } } else { for (int i = 0; i < entry.ArraySize; ++i) { BindingOffsets[currentBindingOffset++] = SrvCount++ *device.SrvHandleIncrementSize; } } } }
public static void ProcessResources(this ParameterCollectionLayout parameterCollectionLayout, DescriptorSetLayoutBuilder layout) { foreach (var layoutEntry in layout.Entries) { parameterCollectionLayout.LayoutParameterKeyInfos.Add(new ParameterKeyInfo(layoutEntry.Key, parameterCollectionLayout.ResourceCount++)); } }
private DescriptorSetLayout(GraphicsDevice device, DescriptorSetLayoutBuilder builder) { ElementCount = builder.ElementCount; Entries = builder.Entries.ToArray(); }
public static DescriptorSetLayout New(GraphicsDevice device, DescriptorSetLayoutBuilder builder) { return(new DescriptorSetLayout(device, builder)); }
public LayoutEntry(string name, DescriptorSetLayoutBuilder layout) { Name = name; Layout = layout; }
public void AddLayout(string descriptorSetName, DescriptorSetLayoutBuilder descriptorSetLayoutBuilder) { Layouts.Add(new LayoutEntry(descriptorSetName, descriptorSetLayoutBuilder)); }
private DescriptorSetLayout(GraphicsDevice device, DescriptorSetLayoutBuilder builder) : base(device) { this.Builder = builder; Recreate(); }