public EffectParameterUpdaterLayout(GraphicsDevice graphicsDevice, Effect effect, DescriptorSetLayoutBuilder[] layouts) { Layouts = layouts; // Process constant buffers ResourceGroupLayouts = new ResourceGroupLayout[layouts.Length]; for (int layoutIndex = 0; layoutIndex < layouts.Length; layoutIndex++) { var layout = layouts[layoutIndex]; if (layout == null) continue; ParameterCollectionLayout.ProcessResources(layout); EffectConstantBufferDescription cbuffer = null; for (int entryIndex = 0; entryIndex < layout.Entries.Count; ++entryIndex) { var layoutEntry = layout.Entries[entryIndex]; if (layoutEntry.Class == EffectParameterClass.ConstantBuffer) { // For now we assume first cbuffer will be the main one if (cbuffer == null) { cbuffer = effect.Bytecode.Reflection.ConstantBuffers.First(x => x.Name == layoutEntry.Key.Name); ParameterCollectionLayout.ProcessConstantBuffer(cbuffer); } } } var resourceGroupDescription = new ResourceGroupDescription(layout, cbuffer); ResourceGroupLayouts[layoutIndex] = ResourceGroupLayout.New(graphicsDevice, resourceGroupDescription, effect.Bytecode); } }
private void UpdateGroupDescriptions() { ResourceGroupDescription groupDescription = new ResourceGroupDescription(); groupDescription.ResourceType = "TV"; this.GroupDescriptions.Add(groupDescription); }
private RenderSystemResourceGroupLayout CreateDrawResourceGroupLayout(ResourceGroupDescription resourceGroupDescription, EffectBytecode effectBytecode) { if (resourceGroupDescription.DescriptorSetLayout == null) { return(null); } var result = new RenderSystemResourceGroupLayout { DescriptorSetLayout = DescriptorSetLayout.New(RenderSystem.GraphicsDevice, resourceGroupDescription.DescriptorSetLayout), ConstantBufferReflection = resourceGroupDescription.ConstantBufferReflection, }; if (resourceGroupDescription.ConstantBufferReflection != null) { result.ConstantBufferSize = resourceGroupDescription.ConstantBufferReflection.Size; result.ConstantBufferHash = resourceGroupDescription.ConstantBufferReflection.Hash; } // Resolve slots result.ConstantBufferOffsets = new int[drawCBufferOffsetSlots.Count]; for (int index = 0; index < drawCBufferOffsetSlots.Count; index++) { ResolveCBufferOffset(result, index, drawCBufferOffsetSlots[index].Variable); } return(result); }
private void AddGroupDescription(string groupName) { if (!this.IsExistingGroup(groupName)) { ResourceGroupDescription groupDescription = new ResourceGroupDescription(); groupDescription.ResourceType = groupName; this.GroupDescriptions.Add(groupDescription); } }
private ViewResourceGroupLayout CreateViewResourceGroupLayout(ResourceGroupDescription resourceGroupDescription, RenderEffectState effectState) { if (resourceGroupDescription.DescriptorSetLayout == null) { return(null); } // We combine both hash for DescriptorSet and cbuffer itself (if it exists) var hash = resourceGroupDescription.Hash; var effectStateHash = new ObjectId(0, 0, 0, (uint)effectState); ObjectId.Combine(ref effectStateHash, ref hash, out hash); ViewResourceGroupLayout result; if (!viewResourceLayouts.TryGetValue(hash, out result)) { result = new ViewResourceGroupLayout { DescriptorSetLayoutBuilder = resourceGroupDescription.DescriptorSetLayout, DescriptorSetLayout = DescriptorSetLayout.New(RenderSystem.GraphicsDevice, resourceGroupDescription.DescriptorSetLayout), ConstantBufferReflection = resourceGroupDescription.ConstantBufferReflection, Entries = new ResourceGroupEntry[RenderSystem.Views.Count], State = effectState, }; for (int index = 0; index < result.Entries.Length; index++) { result.Entries[index].Resources = new ResourceGroup(); } if (resourceGroupDescription.ConstantBufferReflection != null) { result.ConstantBufferSize = resourceGroupDescription.ConstantBufferReflection.Size; result.ConstantBufferHash = resourceGroupDescription.ConstantBufferReflection.Hash; } // Resolve slots result.ConstantBufferOffsets = new int[viewCBufferOffsetSlots.Count]; for (int index = 0; index < viewCBufferOffsetSlots.Count; index++) { ResolveCBufferOffset(result, index, viewCBufferOffsetSlots[index].Variable); } // Resolve logical groups result.LogicalGroups = new LogicalGroup[viewLogicalGroups.Count]; for (int index = 0; index < viewLogicalGroups.Count; index++) { ResolveLogicalGroup(result, index, viewLogicalGroups[index].Variable); } viewResourceLayouts.Add(hash, result); } return(result); }
private ViewResourceGroupLayout CreateViewResourceGroupLayout(ResourceGroupDescription resourceGroupDescription, EffectBytecode effectBytecode) { if (resourceGroupDescription.DescriptorSetLayout == null) { return(null); } // We combine both hash for DescriptorSet and cbuffer itself (if it exists) var hash = resourceGroupDescription.Hash; ViewResourceGroupLayout result; if (!viewResourceLayouts.TryGetValue(hash, out result)) { result = new ViewResourceGroupLayout { DescriptorSetLayout = DescriptorSetLayout.New(RenderSystem.GraphicsDevice, resourceGroupDescription.DescriptorSetLayout), ConstantBufferReflection = resourceGroupDescription.ConstantBufferReflection, Entries = new ResourceGroupEntry[RenderSystem.Views.Count], }; for (int index = 0; index < result.Entries.Length; index++) { result.Entries[index].Resources = new ResourceGroup(); } if (resourceGroupDescription.ConstantBufferReflection != null) { result.ConstantBufferSize = resourceGroupDescription.ConstantBufferReflection.Size; result.ConstantBufferHash = resourceGroupDescription.ConstantBufferReflection.Hash; } // Resolve slots result.ConstantBufferOffsets = new int[viewCBufferOffsetSlots.Count]; for (int index = 0; index < viewCBufferOffsetSlots.Count; index++) { ResolveCBufferOffset(result, index, viewCBufferOffsetSlots[index].Variable); } viewResourceLayouts.Add(hash, result); } return(result); }
private static void OnIsTimeMarkerGroupingEnabledChagned(DependencyObject d, DependencyPropertyChangedEventArgs e) { d.Dispatcher.BeginInvoke(new Action(() => { scheduleView = d as RadScheduleView; if (scheduleView != null && e.NewValue != e.OldValue) { if ((bool)e.NewValue) { var viewModel = scheduleView.DataContext as MyViewModel; var timeMarkers = scheduleView.TimeMarkersSource; var timeMarkerResources = new ResourceType("TimeMarkers"); foreach (TimeMarker marker in timeMarkers) { Resource res = new Resource(marker.TimeMarkerName); timeMarkerResources.Resources.Add(res); } viewModel.ResourcesTypes.Add(timeMarkerResources); ResourceGroupDescription groupDescription = new ResourceGroupDescription(); groupDescription.ResourceType = timeMarkerResources.Name; groupDescription.ShowNullGroup = true; viewModel.GroupDescriptions.Add(groupDescription); scheduleView.AppointmentCreated += OnAppointmentCreated; scheduleView.AppointmentEdited += OnAppointmentEdited; scheduleView.DialogClosing += OnDialogClosing; scheduleView.Loaded += OnLoaded; } else { scheduleView.AppointmentCreated -= OnAppointmentCreated; scheduleView.AppointmentEdited -= OnAppointmentEdited; scheduleView.DialogClosing -= OnDialogClosing; scheduleView.Loaded -= OnLoaded; } } })); }
private static void OnIsTimeMarkerGroupingEnabledChagned(DependencyObject d, DependencyPropertyChangedEventArgs e) { d.Dispatcher.BeginInvoke(new Action(() => { scheduleView = d as RadScheduleView; if (scheduleView != null && e.NewValue != e.OldValue) { if ((bool)e.NewValue) { var viewModel = scheduleView.DataContext as MyViewModel; var timeMarkers = scheduleView.TimeMarkersSource; var timeMarkerResources = new ResourceType("TimeMarkers"); foreach (TimeMarker marker in timeMarkers) { Resource res = new Resource(marker.TimeMarkerName); timeMarkerResources.Resources.Add(res); } viewModel.ResourcesTypes.Add(timeMarkerResources); ResourceGroupDescription groupDescription = new ResourceGroupDescription(); groupDescription.ResourceType = timeMarkerResources.Name; groupDescription.ShowNullGroup = true; viewModel.GroupDescriptions.Add(groupDescription); scheduleView.AppointmentCreated += OnAppointmentCreated; scheduleView.AppointmentEdited += OnAppointmentEdited; scheduleView.DialogClosing += OnDialogClosing; scheduleView.Loaded += OnLoaded; } else { scheduleView.AppointmentCreated -= OnAppointmentCreated; scheduleView.AppointmentEdited -= OnAppointmentEdited; scheduleView.DialogClosing -= OnDialogClosing; scheduleView.Loaded -= OnLoaded; } } })); }
public EffectParameterUpdaterLayout(GraphicsDevice graphicsDevice, Effect effect, DescriptorSetLayoutBuilder[] layouts) { Layouts = layouts; // Process constant buffers ResourceGroupLayouts = new ResourceGroupLayout[layouts.Length]; for (int layoutIndex = 0; layoutIndex < layouts.Length; layoutIndex++) { var layout = layouts[layoutIndex]; if (layout == null) { continue; } ParameterCollectionLayout.ProcessResources(layout); EffectConstantBufferDescription cbuffer = null; for (int entryIndex = 0; entryIndex < layout.Entries.Count; ++entryIndex) { var layoutEntry = layout.Entries[entryIndex]; if (layoutEntry.Class == EffectParameterClass.ConstantBuffer) { // For now we assume first cbuffer will be the main one if (cbuffer == null) { cbuffer = effect.Bytecode.Reflection.ConstantBuffers.First(x => x.Name == layoutEntry.Key.Name); ParameterCollectionLayout.ProcessConstantBuffer(cbuffer); } } } var resourceGroupDescription = new ResourceGroupDescription(layout, cbuffer); ResourceGroupLayouts[layoutIndex] = ResourceGroupLayout.New(graphicsDevice, resourceGroupDescription, effect.Bytecode); } }
private void UpdateGroupDescriptions() { if (this.EnableGrouping) { foreach (var resource in this.ResourceTypes) { ResourceGroupDescription groupDescription = new ResourceGroupDescription(); groupDescription.ResourceType = resource.Name; this.GroupDescriptions.Add(groupDescription); } }else { this.GroupDescriptions.RemoveAll((GroupDescription g) => g is ResourceGroupDescription); } }
private ViewResourceGroupLayout CreateViewResourceGroupLayout(ResourceGroupDescription resourceGroupDescription, RenderEffectState effectState) { if (resourceGroupDescription.DescriptorSetLayout == null) return null; // We combine both hash for DescriptorSet and cbuffer itself (if it exists) var hash = resourceGroupDescription.Hash; var effectStateHash = new ObjectId(0, 0, 0, (uint)effectState); ObjectId.Combine(ref effectStateHash, ref hash, out hash); ViewResourceGroupLayout result; if (!viewResourceLayouts.TryGetValue(hash, out result)) { result = new ViewResourceGroupLayout { DescriptorSetLayoutBuilder = resourceGroupDescription.DescriptorSetLayout, DescriptorSetLayout = DescriptorSetLayout.New(RenderSystem.GraphicsDevice, resourceGroupDescription.DescriptorSetLayout), ConstantBufferReflection = resourceGroupDescription.ConstantBufferReflection, Entries = new ResourceGroupEntry[RenderSystem.Views.Count], State = effectState, }; for (int index = 0; index < result.Entries.Length; index++) { result.Entries[index].Resources = new ResourceGroup(); } if (resourceGroupDescription.ConstantBufferReflection != null) { result.ConstantBufferSize = resourceGroupDescription.ConstantBufferReflection.Size; result.ConstantBufferHash = resourceGroupDescription.ConstantBufferReflection.Hash; } // Resolve slots result.ConstantBufferOffsets = new int[viewCBufferOffsetSlots.Count]; for (int index = 0; index < viewCBufferOffsetSlots.Count; index++) { ResolveCBufferOffset(result, index, viewCBufferOffsetSlots[index].Variable); } // Resolve logical groups result.LogicalGroups = new LogicalGroup[viewLogicalGroups.Count]; for (int index = 0; index < viewLogicalGroups.Count; index++) { ResolveLogicalGroup(result, index, viewLogicalGroups[index].Variable); } viewResourceLayouts.Add(hash, result); } return result; }
private RenderSystemResourceGroupLayout CreateDrawResourceGroupLayout(ResourceGroupDescription resourceGroupDescription, RenderEffectState effectState) { if (resourceGroupDescription.DescriptorSetLayout == null) return null; var result = new RenderSystemResourceGroupLayout { DescriptorSetLayoutBuilder = resourceGroupDescription.DescriptorSetLayout, DescriptorSetLayout = DescriptorSetLayout.New(RenderSystem.GraphicsDevice, resourceGroupDescription.DescriptorSetLayout), ConstantBufferReflection = resourceGroupDescription.ConstantBufferReflection, }; result.State = effectState; if (resourceGroupDescription.ConstantBufferReflection != null) { result.ConstantBufferSize = resourceGroupDescription.ConstantBufferReflection.Size; result.ConstantBufferHash = resourceGroupDescription.ConstantBufferReflection.Hash; } // Resolve slots result.ConstantBufferOffsets = new int[drawCBufferOffsetSlots.Count]; for (int index = 0; index < drawCBufferOffsetSlots.Count; index++) { ResolveCBufferOffset(result, index, drawCBufferOffsetSlots[index].Variable); } // Resolve logical groups result.LogicalGroups = new LogicalGroup[drawLogicalGroups.Count]; for (int index = 0; index < drawLogicalGroups.Count; index++) { ResolveLogicalGroup(result, index, drawLogicalGroups[index].Variable); } return result; }