Example #1
0
        internal Framebuffer(
            FramebufferAttachmentDescription?depthTargetDesc,
            IReadOnlyList <FramebufferAttachmentDescription> colorTargetDescs)
        {
            if (depthTargetDesc != null)
            {
                FramebufferAttachmentDescription depthAttachment = depthTargetDesc.Value;
                DepthTarget = new FramebufferAttachment(depthAttachment.Target, depthAttachment.ArrayLayer);
            }
            FramebufferAttachment[] colorTargets = new FramebufferAttachment[colorTargetDescs.Count];
            for (int i = 0; i < colorTargets.Length; i++)
            {
                colorTargets[i] = new FramebufferAttachment(colorTargetDescs[i].Target, colorTargetDescs[i].ArrayLayer);
            }

            ColorTargets = colorTargets;

            if (ColorTargets.Count > 0)
            {
                Width  = ColorTargets[0].Target.Width;
                Height = ColorTargets[0].Target.Height;
            }
            else if (DepthTarget != null)
            {
                Width  = DepthTarget.Value.Target.Width;
                Height = DepthTarget.Value.Target.Height;
            }

            OutputDescription = OutputDescription.CreateFromFramebuffer(this);
        }
 /// <summary>
 /// Constructs a new <see cref="FramebufferDescription"/>.
 /// </summary>
 /// <param name="depthTarget">The depth texture, which must have been created with
 /// <see cref="TextureUsage.DepthStencil"/> usage flags. May be null.</param>
 /// <param name="colorTargets">An array of color textures, all of which must have been created with
 /// <see cref="TextureUsage.RenderTarget"/> usage flags. May be null or empty.</param>
 public FramebufferDescription(Texture depthTarget, params Texture[] colorTargets)
 {
     if (depthTarget != null)
     {
         DepthTarget = new FramebufferAttachmentDescription(depthTarget, 0);
     }
     else
     {
         DepthTarget = null;
     }
     ColorTargets = new FramebufferAttachmentDescription[colorTargets.Length];
     for (int i = 0; i < colorTargets.Length; i++)
     {
         ColorTargets[i] = new FramebufferAttachmentDescription(colorTargets[i], 0);
     }
 }
Example #3
0
        internal Framebuffer(
            FramebufferAttachmentDescription?depthTargetDesc,
            IReadOnlyList <FramebufferAttachmentDescription> colorTargetDescs)
        {
            if (depthTargetDesc != null)
            {
                FramebufferAttachmentDescription depthAttachment = depthTargetDesc.Value;
                DepthTarget = new FramebufferAttachment(
                    depthAttachment.Target,
                    depthAttachment.ArrayLayer,
                    depthAttachment.MipLevel);
            }
            FramebufferAttachment[] colorTargets = new FramebufferAttachment[colorTargetDescs.Count];
            for (int i = 0; i < colorTargets.Length; i++)
            {
                colorTargets[i] = new FramebufferAttachment(
                    colorTargetDescs[i].Target,
                    colorTargetDescs[i].ArrayLayer,
                    colorTargetDescs[i].MipLevel);
            }

            ColorTargets = colorTargets;

            Texture dimTex;
            uint    mipLevel;

            if (ColorTargets.Count > 0)
            {
                dimTex   = ColorTargets[0].Target;
                mipLevel = ColorTargets[0].MipLevel;
            }
            else
            {
                Debug.Assert(DepthTarget != null);
                dimTex   = DepthTarget.Value.Target;
                mipLevel = DepthTarget.Value.MipLevel;
            }

            Util.GetMipDimensions(dimTex, mipLevel, out uint mipWidth, out uint mipHeight, out _);
            Width  = mipWidth;
            Height = mipHeight;


            OutputDescription = OutputDescription.CreateFromFramebuffer(this);
        }