Example #1
0
 /// <summary>
 /// Generates a unique identifier from location.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <returns>Guid.</returns>
 public static AssetId GenerateIdFromLocation(string packageName, string location)
 {
     if (location == null)
     {
         throw new ArgumentNullException(nameof(location));
     }
     return((AssetId)ObjectId.Combine(ObjectId.FromBytes(Encoding.UTF8.GetBytes(packageName)), ObjectId.FromBytes(Encoding.UTF8.GetBytes(location))).ToGuid());
 }
        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);
        }
Example #3
0
        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);
            }
        }