public ShaderResourceDescription(string name, ShaderResourceType type, int dataSizeInBytes, ShaderStages stages = ShaderStages.All) { Name = name; Type = type; DataSizeInBytes = dataSizeInBytes; Stages = stages; }
public static string Str(this ShaderResourceType type) { switch (type) { case ShaderResourceType.None: return("None"); case ShaderResourceType.Buffer: return("Buffer"); case ShaderResourceType.Texture1D: return("1D"); case ShaderResourceType.Texture1DArray: return("1D Array"); case ShaderResourceType.Texture2D: return("2D"); case ShaderResourceType.TextureRect: return("Rect"); case ShaderResourceType.Texture2DArray: return("2D Array"); case ShaderResourceType.Texture2DMS: return("2D MS"); case ShaderResourceType.Texture2DMSArray: return("2D MS Array"); case ShaderResourceType.Texture3D: return("3D"); case ShaderResourceType.TextureCube: return("Cube"); case ShaderResourceType.TextureCubeArray: return("Cube Array"); } return("Unknown resource type"); }
internal ShaderResourceInfo(string name, ShaderResourceType type, HashSet <BindPointInfo> bindPoints) { ResourceType = type; Name = name; var bSlots = new List <BindPointInfo>(bindPoints); BindPoints = bSlots.AsReadOnly(); }
public ShaderResourceAttribute(ShaderResourceType resourceType, Type structureType = null) { ResourceType = resourceType; StructureType = structureType; if (resourceType == ShaderResourceType.StructuredBuffer && structureType == null) { throw new ArgumentException("StructuredBuffer requires specified type"); } }
public IShader CreateShader(ShaderResourceType type) { switch (type) { case ShaderResourceType.BaseShader: return new Shader(); default: throw new ArgumentOutOfRangeException("type"); } }
public IShader CreateShader(ShaderResourceType type) { switch (type) { case ShaderResourceType.BaseShader: return(new Shader()); default: throw new ArgumentOutOfRangeException("type"); } }
public ShaderMember(string name, List <int> arrayDimensions, int elementCount, int startOffset, ShaderElementInfo elementInfo, int sizeOf, ShaderResourceType resType, ShaderResourceBaseType resBaseType) { Name = name; ArrayDimensions = arrayDimensions.AsReadOnly(); ElementCount = elementCount; StartOffset = startOffset; ElementInfo = elementInfo; SizeOf = sizeOf; ResourceType = resType; ResourceBaseType = resBaseType; }
public ShaderResourceDescription(string name, ShaderConstantType constantType, ShaderStages stages = ShaderStages.All) { Name = name; Type = ShaderResourceType.ConstantBuffer; if (!FormatHelpers.GetShaderConstantTypeByteSize(constantType, out int dataSizeInBytes)) { throw new VeldridException("Invalid shader constant type: " + constantType); } DataSizeInBytes = dataSizeInBytes; Stages = stages; }
public ShaderResourceDescription(string name, ShaderResourceType type, ShaderStages stages = ShaderStages.All) { if (type == ShaderResourceType.ConstantBuffer) { throw new VeldridException( "If ShaderResourceType.ConstantBuffer is specified, dataSizeInBytes must also be provided."); } Name = name; Type = type; DataSizeInBytes = -1; Stages = stages; }
/// <summary> /// Gets the resource location. /// </summary> /// <param name="resourceType">Type of the resource.</param> /// <param name="name">The name.</param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException">Unknown ShaderResourceType</exception> public int GetResourceLocation(ShaderResourceType resourceType, string name) { switch (resourceType) { case ShaderResourceType.Attribute: return(GL.GetAttribLocation(ProgramID, name)); case ShaderResourceType.UniformBuffer: return(GetResourceIndex(name, ProgramInterface.UniformBlock)); case ShaderResourceType.RWBuffer: return(GetResourceIndex(name, ProgramInterface.ShaderStorageBlock)); case ShaderResourceType.Uniform: return(GetResourceIndex(name, ProgramInterface.Uniform)); default: throw new ArgumentOutOfRangeException("Unknown ShaderResourceType"); } }
public static ResourceTypeDescription GetDescription(this ShaderResourceType en) { Type type = en.GetType(); MemberInfo[] memInfo = type.GetMember(en.ToString()); if (memInfo != null && memInfo.Length > 0) { object[] attrs = memInfo[0].GetCustomAttributes(typeof(ResourceTypeDescription), false); if (attrs != null && attrs.Length > 0) { return((ResourceTypeDescription)attrs[0]); } } throw new ArgumentException(string.Format("Resource type {0} doesn't have a description.", en.ToString())); }
private VkDescriptorType MapDescriptorType(ShaderResourceType type) { switch (type) { case ShaderResourceType.ConstantBuffer: return(VkDescriptorType.UniformBuffer); case ShaderResourceType.Texture: return(VkDescriptorType.SampledImage); case ShaderResourceType.Sampler: return(VkDescriptorType.Sampler); default: throw Illegal.Value <ShaderResourceType>(); } }
public ShaderResourceBinding( string name, ShaderResourceType resourceType, ShaderType shaderStage, int slot, int constantBufferSizeInBytes, ConstantBufferField[] constantBufferFields) { Name = name; ResourceType = resourceType; ShaderType = shaderStage; Slot = slot; ConstantBufferSizeInBytes = constantBufferSizeInBytes; ConstantBufferFields = constantBufferFields; _constantBufferFieldsDictionary = constantBufferFields?.ToDictionary(x => x.Name); }
private void AppendUpdateStatistics(FetchFrameInfo frameInfo) { // #mivance see AppendConstantBindStatistics FetchFrameUpdateStats template = frameInfo.stats.updates; FetchFrameUpdateStats totalUpdates = new FetchFrameUpdateStats(); totalUpdates.types = new UInt32[template.types.Length]; totalUpdates.sizes = new UInt32[template.sizes.Length]; { FetchFrameUpdateStats updates = frameInfo.stats.updates; totalUpdates.calls += updates.calls; totalUpdates.clients += updates.clients; totalUpdates.servers += updates.servers; System.Diagnostics.Debug.Assert(totalUpdates.types.Length == updates.types.Length); for (var t = 0; t < updates.types.Length; t++) { totalUpdates.types[t] += updates.types[t]; } System.Diagnostics.Debug.Assert(totalUpdates.sizes.Length == updates.sizes.Length); for (var t = 0; t < updates.sizes.Length; t++) { totalUpdates.sizes[t] += updates.sizes[t]; } } statisticsLog.AppendText("\n*** Resource Update Statistics ***\n\n"); statisticsLog.AppendText(String.Format("Total calls: {0}, client-updated memory: {1}, server-updated memory: {2}\n", totalUpdates.calls, totalUpdates.clients, totalUpdates.servers)); statisticsLog.AppendText("\nUpdated resource types:\n"); UInt32 maxCount = 0; int maxWithValue = 0; for (var s = 1; s < totalUpdates.types.Length; s++) { UInt32 value = totalUpdates.types[s]; if (value > 0) { maxWithValue = s; } maxCount = Math.Max(maxCount, value); } for (var s = 1; s <= maxWithValue; s++) { UInt32 count = totalUpdates.types[s]; int slice = SliceForString(Stars, count, maxCount); ShaderResourceType type = (ShaderResourceType)s; statisticsLog.AppendText(String.Format("{0,16}: {1} {2}\n", type.ToString(), Stars.Substring(0, slice), CountOrEmpty(count))); } statisticsLog.AppendText("\nUpdated resource sizes:\n"); maxCount = 0; maxWithValue = 0; for (var s = 0; s < totalUpdates.sizes.Length; s++) { UInt32 value = totalUpdates.sizes[s]; if (value > 0) { maxWithValue = s; } maxCount = Math.Max(maxCount, value); } for (var s = 0; s <= maxWithValue; s++) { UInt32 count = totalUpdates.sizes[s]; int slice = SliceForString(Stars, count, maxCount); statisticsLog.AppendText(String.Format("{0,8}: {1} {2}\n", Pow2IndexAsReadable(s), Stars.Substring(0, slice), CountOrEmpty(count))); } }
private void AppendResourceBindStatistics(FetchFrameInfo frameInfo) { // #mivance see AppendConstantBindStatistics FetchFrameResourceBindStats template = frameInfo.stats.resources[0]; FetchFrameResourceBindStats[] totalResourcesPerStage = new FetchFrameResourceBindStats[(int)ShaderStageType.Count]; for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++) { totalResourcesPerStage[s] = new FetchFrameResourceBindStats(); totalResourcesPerStage[s].types = new UInt32[template.types.Length]; totalResourcesPerStage[s].bindslots = new UInt32[template.bindslots.Length]; } { FetchFrameResourceBindStats[] resources = frameInfo.stats.resources; for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++) { totalResourcesPerStage[s].calls += resources[s].calls; totalResourcesPerStage[s].sets += resources[s].sets; totalResourcesPerStage[s].nulls += resources[s].nulls; System.Diagnostics.Debug.Assert(totalResourcesPerStage[s].types.Length == resources[s].types.Length); for (var z = 0; z < resources[s].types.Length; z++) { totalResourcesPerStage[s].types[z] += resources[s].types[z]; } System.Diagnostics.Debug.Assert(totalResourcesPerStage[s].bindslots.Length == resources[s].bindslots.Length); for (var l = 0; l < resources[s].bindslots.Length; l++) { totalResourcesPerStage[s].bindslots[l] += resources[s].bindslots[l]; } } } FetchFrameResourceBindStats totalResourcesForAllStages = new FetchFrameResourceBindStats(); totalResourcesForAllStages.types = new UInt32[totalResourcesPerStage[0].types.Length]; totalResourcesForAllStages.bindslots = new UInt32[totalResourcesPerStage[0].bindslots.Length]; for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++) { FetchFrameResourceBindStats perStage = totalResourcesPerStage[s]; totalResourcesForAllStages.calls += perStage.calls; totalResourcesForAllStages.sets += perStage.sets; totalResourcesForAllStages.nulls += perStage.nulls; for (var t = 0; t < perStage.types.Length; t++) { totalResourcesForAllStages.types[t] += perStage.types[t]; } for (var l = 0; l < perStage.bindslots.Length; l++) { totalResourcesForAllStages.bindslots[l] += perStage.bindslots[l]; } } statisticsLog.AppendText("\n*** Resource Bind Statistics ***\n\n"); for (var s = (int)ShaderStageType.First; s < (int)ShaderStageType.Count; s++) { statisticsLog.AppendText(String.Format("{0} calls: {1} non-null resource sets: {2} null resource sets: {3}\n", m_Core.CurPipelineState.Abbrev((ShaderStageType)s), totalResourcesPerStage[s].calls, totalResourcesPerStage[s].sets, totalResourcesPerStage[s].nulls)); } statisticsLog.AppendText(String.Format("Total calls: {0} non-null resource sets: {1} null resource sets: {2}\n", totalResourcesForAllStages.calls, totalResourcesForAllStages.sets, totalResourcesForAllStages.nulls)); UInt32 maxCount = 0; int maxWithCount = 0; statisticsLog.AppendText("\nResource types across all stages:\n"); for (var s = 0; s < totalResourcesForAllStages.types.Length; s++) { UInt32 count = totalResourcesForAllStages.types[s]; if (count > 0) { maxWithCount = s; } maxCount = Math.Max(maxCount, count); } for (var s = 0; s <= maxWithCount; s++) { UInt32 count = totalResourcesForAllStages.types[s]; int slice = SliceForString(Stars, count, maxCount); ShaderResourceType type = (ShaderResourceType)s; statisticsLog.AppendText(String.Format("{0,16}: {1} {2}\n", type.ToString(), Stars.Substring(0, slice), CountOrEmpty(count))); } statisticsLog.AppendText(CreateSimpleIntegerHistogram("Aggregate slot counts per invocation across all stages", totalResourcesForAllStages.bindslots)); }
public ShaderResourceDeclaration(ShaderResourceType type, string name, int count = 1) { Type = type; Name = name; Count = count; }
public ResourceBinding(int register, string name, ShaderResourceType resourceType) { this.Register = register; this.Name = name; this.ResourceType = resourceType; }
/// <summary>To initialize this structure with default value, use this constructor. The argument value is ignored.</summary> /// <remarks>This is only here because C# doesn’t support parameterless constructors for structures.</remarks> public ShaderResourceDesc(bool unused) { Name = IntPtr.Zero; Type = ShaderResourceType.Unknown; ArraySize = 0; }