Exemple #1
0
        static MgRenderPassProfileSubpassInfo[] InitializeSubpasses(MgRenderPassCreateInfo createInfo)
        {
            if (createInfo == null || createInfo.Subpasses == null)
            {
                return new MgRenderPassProfileSubpassInfo[] { }
            }
            ;

            var subpasses = new List <MgRenderPassProfileSubpassInfo>();

            foreach (var sp in createInfo.Subpasses)
            {
                var item = new MgRenderPassProfileSubpassInfo
                {
                    Color        = ExtractAttachmentIndices(sp.ColorAttachments),
                    Input        = ExtractAttachmentIndices(sp.InputAttachments),
                    Resolve      = ExtractAttachmentIndices(sp.ResolveAttachments),
                    DepthStencil = sp.DepthStencilAttachment != null
                                                         ? sp.DepthStencilAttachment.Attachment : ~VK_ATTACHMENT_UNUSED,
                };

                subpasses.Add(item);
            }

            return(subpasses.ToArray());
        }
Exemple #2
0
        static MgRenderPassProfileAttachmentInfo[] InitializeAttachments(MgRenderPassCreateInfo createInfo)
        {
            if (createInfo == null || createInfo.Attachments == null)
            {
                return new MgRenderPassProfileAttachmentInfo[] { }
            }
            ;

            var attachments = new List <MgRenderPassProfileAttachmentInfo>();

            foreach (var attach in createInfo.Attachments)
            {
                attachments.Add(new MgRenderPassProfileAttachmentInfo
                {
                    Format  = attach.Format,
                    Samples = attach.Samples,
                });
            }
            return(attachments.ToArray());
        }
    }
Exemple #3
0
        void CreateRenderpass(MgGraphicsDeviceCreateInfo createInfo)
        {
            var attachments = new []
            {
                // Color attachment[0]
                new MgAttachmentDescription {
                    Format = createInfo.Color,
                    // TODO : multisampling
                    Samples        = MgSampleCountFlagBits.COUNT_1_BIT,
                    LoadOp         = MgAttachmentLoadOp.CLEAR,
                    StoreOp        = MgAttachmentStoreOp.STORE,
                    StencilLoadOp  = MgAttachmentLoadOp.DONT_CARE,
                    StencilStoreOp = MgAttachmentStoreOp.DONT_CARE,
                    InitialLayout  = MgImageLayout.COLOR_ATTACHMENT_OPTIMAL,
                    FinalLayout    = MgImageLayout.COLOR_ATTACHMENT_OPTIMAL,
                },
                // Depth attachment[1]
                new MgAttachmentDescription {
                    Format = createInfo.DepthStencil,
                    // TODO : multisampling
                    Samples = MgSampleCountFlagBits.COUNT_1_BIT,
                    LoadOp  = MgAttachmentLoadOp.CLEAR,
                    StoreOp = MgAttachmentStoreOp.STORE,

                    // TODO : activate stencil if needed
                    StencilLoadOp  = MgAttachmentLoadOp.DONT_CARE,
                    StencilStoreOp = MgAttachmentStoreOp.DONT_CARE,

                    InitialLayout = MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
                    FinalLayout   = MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
                }
            };

            var colorReference = new MgAttachmentReference
            {
                Attachment = 0,
                Layout     = MgImageLayout.COLOR_ATTACHMENT_OPTIMAL,
            };

            var depthReference = new MgAttachmentReference {
                Attachment = 1,
                Layout     = MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
            };

            var subpass = new MgSubpassDescription
            {
                PipelineBindPoint      = MgPipelineBindPoint.GRAPHICS,
                Flags                  = 0,
                InputAttachments       = null,
                ColorAttachments       = new [] { colorReference },
                ResolveAttachments     = null,
                DepthStencilAttachment = depthReference,
                PreserveAttachments    = null,
            };

            var renderPassInfo = new MgRenderPassCreateInfo {
                Attachments  = attachments,
                Subpasses    = new [] { subpass },
                Dependencies = null,
            };

            Result err;

            IMgRenderPass renderPass;

            err = mGraphicsConfiguration.Partition.Device.CreateRenderPass(renderPassInfo, null, out renderPass);
            Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
            mRenderpass = renderPass;
        }
Exemple #4
0
 public MgRenderPassProfile(MgRenderPassCreateInfo createInfo)
 {
     mAttachments = InitializeAttachments(createInfo);
     mSubpasses   = InitializeSubpasses(createInfo);
 }