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(); foreach (var effectDescriptorSetSlot in effectDescriptorSetSlots) { // Find all resources related to this slot name var descriptorSetLayoutBuilder = new DescriptorSetLayoutBuilder(); bool hasBindings = false; foreach (var resourceBinding in effectBytecode.Reflection.ResourceBindings .Where(x => x.Param.ResourceGroup == effectDescriptorSetSlot || (effectDescriptorSetSlot == defaultSetSlot && (x.Param.ResourceGroup == null || x.Param.ResourceGroup == "Globals"))) .GroupBy(x => new { Key = x.Param.Key, Class = x.Param.Class, SlotCount = x.SlotCount }) .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.Class, resourceBinding.Key.SlotCount, samplerState); } descriptorSetLayouts.AddLayout(effectDescriptorSetSlot, hasBindings ? descriptorSetLayoutBuilder : null); } return(descriptorSetLayouts); }
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, 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.SlotCount, samplerState); } descriptorSetLayouts.AddLayout(effectDescriptorSetSlot, hasBindings ? descriptorSetLayoutBuilder : null); } return descriptorSetLayouts; }