Пример #1
0
        protected virtual void CreateRenderTargets()
        {
            Debug.Assert(RenderPass != null);

            if (renderTargetCreator != null)
            {
                renderTarget = renderTargetCreator();
                foreach (var rt in renderTarget.Attachments)
                {
                    if (!rt.id.IsNullOrEmpty)
                    {
                        Renderer.RegResource(rt.id, rt);
                    }
                }
            }
            else
            {
                if (renderTextureInfos.Count > 0)
                {
                    renderTarget = new RenderTarget(Graphics.Width, Graphics.Height);

                    Array.Resize(ref clearValues, renderTextureInfos.Count);
                    for (int i = 0; i < renderTextureInfos.Count; i++)
                    {
                        var info = renderTextureInfos[i];
                        if (info.RTType == RTType.ColorOutput)
                        {
                            renderTarget.Add(Renderer.ColorTexture);
                        }
                        else if (info.RTType == RTType.DepthOutput)
                        {
                            renderTarget.Add(Renderer.DepthTexture);
                        }
                        else
                        {
                            var rt = renderTarget.Add(info);
                            if (!rt.id.IsNullOrEmpty)
                            {
                                Renderer.RegResource(rt.id, rt);
                            }
                        }

                        clearValues[i] = renderTextureInfos[i].ClearValue;
                    }
                }
            }

            if (renderTarget == null)
            {
                renderTarget = Renderer.RenderTarget;
            }

            framebuffers = new Framebuffer[Swapchain.IMAGE_COUNT];
            for (int i = 0; i < framebuffers.Length; i++)
            {
                var attachments = renderTarget.GetViews(i);
                framebuffers[i] = new Framebuffer(RenderPass, renderTarget.Extent.width, renderTarget.Extent.height, 1, attachments);
            }
        }