Ejemplo n.º 1
0
        private static VectorFormat AddVectorFormat(SurfaceFormat surfaceFormat, params Type[] vectorTypes)
        {
            var vectorInfos  = vectorTypes.Select(x => VectorType.Get(x));
            var vectorFormat = new VectorFormat(surfaceFormat, vectorInfos);

            if (!VectorFormatBySurface.TryGetValue(surfaceFormat, out var bySurfaceSet))
            {
                bySurfaceSet = new HashSet <VectorFormat>();
                VectorFormatBySurface.TryAdd(surfaceFormat, bySurfaceSet);
                VectorFormatBySurfaceRO.TryAdd(surfaceFormat, bySurfaceSet.AsReadOnly());
            }
            bySurfaceSet.Add(vectorFormat);

            foreach (var vectorType in vectorTypes)
            {
                if (!VectorFormatsByType.TryGetValue(vectorType, out var byTypeSet))
                {
                    byTypeSet = new HashSet <VectorFormat>();
                    VectorFormatsByType.TryAdd(vectorType, byTypeSet);
                    VectorFormatsByTypeRO.TryAdd(vectorType, byTypeSet.AsReadOnly());
                }
                byTypeSet.Add(vectorFormat);
            }

            return(vectorFormat);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Tries to map a surface format to a vector format.
 /// </summary>
 /// <exception cref="ArgumentException">Compressed texture formats are not supported.</exception>
 /// <returns>A set of vector formats the represent the surface format.</returns>
 public static ReadOnlySet <VectorFormat> GetVectorFormats(SurfaceFormat surfaceFormat)
 {
     if (!VectorFormatBySurfaceRO.TryGetValue(surfaceFormat, out var formatSet))
     {
         throw GetUnsupportedSurfaceFormatException(surfaceFormat, nameof(surfaceFormat));
     }
     return(formatSet);
 }