Exemple #1
0
        public DeferredShadingConfiguration(RenderTargetDescriptionCollection renderTargetDescriptions, int layerCount)
        {
            if (renderTargetDescriptions.Count == 0 || renderTargetDescriptions.Count > maxRenderTargetCount)
            {
                throw new ArgumentException(string.Format("There can be from 1 to {0} render targets simultaneously.",
                                                          maxRenderTargetCount), "renderTargetDescriptions");
            }
            if (layerCount < 1 || layerCount > maxLayerCount)
            {
                throw new ArgumentOutOfRangeException("layerCount", string.Format("There can be from 1 to {0} layers.", layerCount));
            }

            foreach (RenderTargetDescription description1 in renderTargetDescriptions)
            {
                foreach (RenderTargetDescription description2 in renderTargetDescriptions)
                {
                    if (description1 != description2 && description1.LayerType == description2.LayerType)
                    {
                        throw new ArgumentException("Deferred renderer should use only one render target for each usage.",
                                                    "renderTargetDescriptions");
                    }
                }
            }

            LayerCount = layerCount;

            // Create copy of given render target configuration
            var descriptions = new List <RenderTargetDescription>();

            descriptions.AddRange(renderTargetDescriptions);
            // And use this copy to initialize internal RT description holder
            RenderTargets = new RenderTargetDescriptionReadOnlyCollection(descriptions);
        }
        public DeferredShadingConfiguration(RenderTargetDescriptionCollection renderTargetDescriptions, int layerCount)
        {
            if (renderTargetDescriptions.Count == 0 || renderTargetDescriptions.Count > maxRenderTargetCount)
                throw new ArgumentException(string.Format("There can be from 1 to {0} render targets simultaneously.",
                                                          maxRenderTargetCount), "renderTargetDescriptions");
            if (layerCount < 1 || layerCount > maxLayerCount)
                throw new ArgumentOutOfRangeException("layerCount", string.Format("There can be from 1 to {0} layers.", layerCount));

            foreach (RenderTargetDescription description1 in renderTargetDescriptions)
                foreach (RenderTargetDescription description2 in renderTargetDescriptions)
                    if (description1 != description2 && description1.LayerType == description2.LayerType)
                        throw new ArgumentException("Deferred renderer should use only one render target for each usage.",
                            "renderTargetDescriptions");

            LayerCount = layerCount;

            // Create copy of given render target configuration
            var descriptions = new List<RenderTargetDescription>();
            descriptions.AddRange(renderTargetDescriptions);
            // And use this copy to initialize internal RT description holder
            RenderTargets = new RenderTargetDescriptionReadOnlyCollection(descriptions);
        }