Ejemplo n.º 1
0
        /// <summary>
        /// Begin a renderpass without clearing color or depth.
        /// </summary>
        public void BeginRenderPass(RenderPass renderPass, FrameBuffer frameBuffer, bool useSecondaryCommandBuffers)
        {
            CheckBegun();
            CheckNotInRenderPass();
            //FixedArray2<VkClearValue> clearValues = new FixedArray2<VkClearValue>();
            //clearValues.First.color = new VkClearColorValue(0, 0, 0);
            //clearValues.Second.depthStencil = new VkClearDepthStencilValue() { depth = 1.0f, stencil = 0 };

            VkRenderPassBeginInfo renderPassBeginInfo = Initializers.renderPassBeginInfo();

            renderPassBeginInfo.renderPass               = renderPass.vkRenderPass;
            renderPassBeginInfo.renderArea.offset.x      = 0;
            renderPassBeginInfo.renderArea.offset.y      = 0;
            renderPassBeginInfo.renderArea.extent.width  = frameBuffer.swapchain.width;
            renderPassBeginInfo.renderArea.extent.height = frameBuffer.swapchain.height;
            //renderPassBeginInfo.clearValueCount = 2;
            //renderPassBeginInfo.pClearValues = &clearValues.First;
            renderPassBeginInfo.framebuffer = frameBuffer.vkFrameBuffer;

            renderPassUseSecondaryBuffers = useSecondaryCommandBuffers;
            VkSubpassContents subPassContents = useSecondaryCommandBuffers
                                ? VkSubpassContents.SecondaryCommandBuffers
                                : VkSubpassContents.Inline;

            vkCmdBeginRenderPass(vkCmd, &renderPassBeginInfo, subPassContents);

            VkViewport viewport = Initializers.viewport((float)frameBuffer.swapchain.width, (float)frameBuffer.swapchain.height, 0.0f, 1.0f);

            vkCmdSetViewport(vkCmd, 0, 1, &viewport);

            VkRect2D scissor = Initializers.rect2D(frameBuffer.swapchain.width, frameBuffer.swapchain.height, 0, 0);

            vkCmdSetScissor(vkCmd, 0, 1, &scissor);
            inRenderPass = true;
        }
Ejemplo n.º 2
0
        public void BeginRenderPass(RenderPass pass, Framebuffer framebuffer,
                                    Span <VkClearValue> clearValues,
                                    VkSubpassContents subpass,
                                    VkRect2D?renderArea = null)
        {
            framebuffer.AssertValid();
            pass.AssertValid();
            unsafe
            {
                fixed(VkClearValue *clearPtr = &clearValues.DangerousGetPinnableReference())
                {
                    var info = new VkRenderPassBeginInfo()
                    {
                        SType      = VkStructureType.RenderPassBeginInfo,
                        PNext      = IntPtr.Zero,
                        RenderArea = renderArea ?? new VkRect2D()
                        {
                            Offset = new VkOffset2D()
                            {
                                X = 0, Y = 0
                            },
                            Extent = framebuffer.Size
                        },
                        ClearValueCount = (uint)clearValues.Length,
                        PClearValues    = clearPtr,
                        Framebuffer     = framebuffer.Handle,
                        RenderPass      = pass.Handle
                    };

                    Handle.BeginRenderPass(&info, subpass);
                }
            }
        }
Ejemplo n.º 3
0
 public void BeginRenderPass(RenderPassBeginInfo info, VkSubpassContents contents)
 {
     using (var marshalled = new DisposableList <IDisposable>()) {
         var infoNative = info.GetNative(marshalled);
         Device.Commands.cmdBeginRenderPass(commandBuffer, ref infoNative, contents);
     }
 }
Ejemplo n.º 4
0
        public void CmdNextSubpass(VkSubpassContents contents)
        {
            var _commandBuffer = Handle;
            var _contents      = contents;

            Direct.CmdNextSubpass(_commandBuffer, _contents);
        }
Ejemplo n.º 5
0
        public void CmdBeginRenderPass(VkRenderPassBeginInfo renderPassBeginInfo, VkSubpassContents contents)
        {
            if (m_State != CommandBufferState.Recording)
            {
                return;
            }

            m_Commands.Add(new Cmd_BeginRenderPass(renderPassBeginInfo, contents));
        }
Ejemplo n.º 6
0
        public void NextSubPass(bool useSecondaryCommandBuffers, ref RenderContext graphicsContext)
        {
            CheckInRenderPass();
            renderPassUseSecondaryBuffers = useSecondaryCommandBuffers;
            VkSubpassContents subPassContents = useSecondaryCommandBuffers
                                ? VkSubpassContents.SecondaryCommandBuffers
                                : VkSubpassContents.Inline;

            vkCmdNextSubpass(vkCmd, subPassContents);
            graphicsContext.currentSubPassIndex++;
        }
Ejemplo n.º 7
0
        public void CmdBeginRenderPass(VkRenderPassBeginInfo renderPassBegin, VkSubpassContents contents)
        {
            var unmanagedSize =
                renderPassBegin.SizeOfMarshalIndirect();
            var unmanagedArray = new byte[unmanagedSize];

            fixed(byte *unmanagedStart = unmanagedArray)
            {
                var unmanaged         = unmanagedStart;
                var _commandBuffer    = Handle;
                var _pRenderPassBegin = renderPassBegin.MarshalIndirect(ref unmanaged);
                var _contents         = contents;

                Direct.CmdBeginRenderPass(_commandBuffer, _pRenderPassBegin, _contents);
            }
        }
Ejemplo n.º 8
0
 public static extern void CmdBeginRenderPass(
     VkCommandBuffer commandBuffer,
     ref VkRenderPassBeginInfo pRenderPassBegin,
     VkSubpassContents contents
     );
Ejemplo n.º 9
0
 public void NextSubpass(VkSubpassContents contents)
 {
     Device.Commands.cmdNextSubpass(commandBuffer, contents);
 }
Ejemplo n.º 10
0
 public void CmdBeginRenderPass(VkRenderPassBeginInfo renderPassBegin, VkSubpassContents contents)
 {
     var unmanagedSize =
         renderPassBegin.SizeOfMarshalIndirect();
     var unmanagedArray = new byte[unmanagedSize];
     fixed (byte* unmanagedStart = unmanagedArray)
     {
         var unmanaged = unmanagedStart;
         var _commandBuffer = Handle;
         var _pRenderPassBegin = renderPassBegin.MarshalIndirect(ref unmanaged);
         var _contents = contents;
         Direct.CmdBeginRenderPass(_commandBuffer, _pRenderPassBegin, _contents);
     }
 }
Ejemplo n.º 11
0
 public void CmdNextSubpass(
     [FromProperty("this")] GenCommandBuffer commandBuffer,
     VkSubpassContents contents)
 {
 }
Ejemplo n.º 12
0
        public unsafe void BeginRenderPass(
            Framebuffer framebuffer,
            VkSubpassContents subpassContents
            )
        {
            var renderPass  = framebuffer.RenderPass;
            var clearValues = new NativeList <VkClearValue>();

            foreach (var attachment in renderPass.Attachments)
            {
                if (attachment.Format == RenderPassAttachment.Default.Format)
                {
                    clearValues.Add(new VkClearValue()
                    {
                        color = new VkClearColorValue(
                            0.0f,
                            0.0f,
                            0.0f,
                            0.0f
                            )
                    });
                }
                else if (attachment.Format == RenderPassAttachment.DefaultDepth.Format)
                {
                    clearValues.Add(new VkClearValue()
                    {
                        depthStencil = new VkClearDepthStencilValue(
                            1.0f,
                            0
                            )
                    });
                }
            }

            var renderPassBeginInfo = new VkRenderPassBeginInfo
            {
                sType           = VkStructureType.RenderPassBeginInfo,
                clearValueCount = clearValues.Count,
                pClearValues    = (VkClearValue *)clearValues.Data.ToPointer(),
                framebuffer     = framebuffer.Handle,
                renderPass      = renderPass.Handle,
                renderArea      = new VkRect2D
                {
                    offset = new VkOffset2D
                    {
                        x = 0,
                        y = 0
                    },
                    extent = new VkExtent2D
                    {
                        width  = framebuffer.Width,
                        height = framebuffer.Height
                    }
                }
            };

            VulkanNative.vkCmdBeginRenderPass(
                _handle,
                &renderPassBeginInfo,
                subpassContents
                );
            // update the layout for images
            for (int i = 0; i < framebuffer.Images.Count; i++)
            {
                Array.Fill(framebuffer.Images[i].Layout, framebuffer.RenderPass.Attachments[i].FinalLayout);
            }
        }
Ejemplo n.º 13
0
 internal extern static void vkCmdBeginRenderPass(IntPtr commandBuffer, ref VkRenderPassBeginInfo pRenderPassBegin, VkSubpassContents contents);
Ejemplo n.º 14
0
        public unsafe void CmdBeginRenderPass(VkRenderPass renderPass, VkRect2D renderArea, VkFramebuffer frameBuffer, VkClearValue[] clearValues, VkSubpassContents contents)
        {
            VkRenderPassBeginInfo renderPassBegin = new VkRenderPassBeginInfo();

            renderPassBegin.renderPass  = renderPass;
            renderPassBegin.renderArea  = renderArea;
            renderPassBegin.framebuffer = frameBuffer;
            renderPassBegin.clearValues = clearValues;
            CmdBeginRenderPass(ref renderPassBegin, contents);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Switch to next subpass
 /// </summary>
 public void BeginSubPass(CommandBuffer cmd, VkSubpassContents subpassContents = VkSubpassContents.Inline)
 {
     vkCmdNextSubpass(cmd.Handle, subpassContents);
 }
Ejemplo n.º 16
0
 public void CmdNextSubpass(VkSubpassContents contents)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
 public void BeginRenderPass(ref RenderPassBeginInfo renderPassBeginInfo, VkSubpassContents contents)
 {
     vkCmdBeginRenderPass(commandBuffer, Utilities.AsPtr(ref renderPassBeginInfo.native), contents);
     renderPass = renderPassBeginInfo.renderPass;
     ClearDescriptorSets();
 }
Ejemplo n.º 18
0
 public void CmdNextSubpass(
     [FromProperty("this")] GenCommandBuffer commandBuffer,
     VkSubpassContents contents)
 { }
Ejemplo n.º 19
0
 public void CmdBeginRenderPass(
     [FromProperty("this")] GenCommandBuffer commandBuffer,
     GenRenderPassBeginInfo* pRenderPassBegin,
     VkSubpassContents contents)
 { }
Ejemplo n.º 20
0
 internal void CmdBeginRenderPass(VkRenderPassBeginInfo renderPassBeginInfo, VkSubpassContents contents)
 {
 }
Ejemplo n.º 21
0
 public static extern void CmdNextSubpass(
     VkCommandBuffer commandBuffer,
     VkSubpassContents contents
     );
Ejemplo n.º 22
0
        /// <summary>
        /// Begin Render pass with custom render area
        /// </summary>
        public void Begin(PrimaryCommandBuffer cmd, FrameBuffer frameBuffer, uint width, uint height, VkSubpassContents contents = VkSubpassContents.Inline)
        {
            VkRenderPassBeginInfo info = VkRenderPassBeginInfo.New();

            info.renderPass = handle;
            info.renderArea.extent.width  = width;
            info.renderArea.extent.height = height;
            info.clearValueCount          = (uint)ClearValues.Count;
            info.pClearValues             = ClearValues.Pin();
            info.framebuffer = frameBuffer.handle;

            vkCmdBeginRenderPass(cmd.Handle, ref info, contents);

            ClearValues.Unpin();
        }
Ejemplo n.º 23
0
        public unsafe void CmdBeginRenderPass(ref VkRenderPassBeginInfo renderPassBegin, VkSubpassContents contents)
        {
            VkRenderPassBeginInfo_Native renderPassBegin_native = new VkRenderPassBeginInfo_Native();

            renderPassBegin_native.pNext = new IntPtr(0);
            renderPassBegin_native.sType = VkStructureType.VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
            if (renderPassBegin.clearValues == null || renderPassBegin.clearValues.Length == 0)
            {
                renderPassBegin_native.clearValueCount = 0;
            }
            else
            {
                renderPassBegin_native.clearValueCount = (uint)renderPassBegin.clearValues.Length;
                renderPassBegin_native.pClearValues    = System.Runtime.InteropServices.Marshal.AllocHGlobal(new IntPtr(sizeof(UInt32) * 4 * renderPassBegin_native.clearValueCount));
            }
            renderPassBegin_native.framebufferHandle = renderPassBegin.framebuffer._Handle;
            renderPassBegin_native.renderArea        = renderPassBegin.renderArea;
            renderPassBegin_native.renderPassHandle  = renderPassBegin.renderPass._Handle;

            for (int n = 0; n < renderPassBegin_native.clearValueCount; n++)
            {
                if (renderPassBegin.clearValues[n] is VkClearValue.VkClearColorValue.Float)
                {
                    VkClearValue.VkClearColorValue.Float value = renderPassBegin.clearValues[n] as VkClearValue.VkClearColorValue.Float;
                    float *pValue = ((float *)(renderPassBegin_native.pClearValues.ToPointer()) + (n * 4));
                    pValue[0] = value.float32[0];
                    pValue[1] = value.float32[1];
                    pValue[2] = value.float32[2];
                    pValue[3] = value.float32[3];
                }
                else if (renderPassBegin.clearValues[n] is VkClearValue.VkClearColorValue.Int32_t)
                {
                    VkClearValue.VkClearColorValue.Int32_t value = renderPassBegin.clearValues[n] as VkClearValue.VkClearColorValue.Int32_t;
                    Int32 *pValue = ((Int32 *)(renderPassBegin_native.pClearValues.ToPointer()) + (n * 4));
                    pValue[0] = value.int32[0];
                    pValue[1] = value.int32[1];
                    pValue[2] = value.int32[2];
                    pValue[3] = value.int32[3];
                }
                else if (renderPassBegin.clearValues[n] is VkClearValue.VkClearColorValue.UInt32_t)
                {
                    VkClearValue.VkClearColorValue.UInt32_t value = renderPassBegin.clearValues[n] as VkClearValue.VkClearColorValue.UInt32_t;
                    UInt32 *pValue = ((UInt32 *)(renderPassBegin_native.pClearValues.ToPointer()) + (n * 4));
                    pValue[0] = value.uint32[0];
                    pValue[1] = value.uint32[1];
                    pValue[2] = value.uint32[2];
                    pValue[3] = value.uint32[3];
                }
                else if (renderPassBegin.clearValues[n] is VkClearValue.VkClearDepthStencilValue.VkClearDepthStencilValue)
                {
                    VkClearValue.VkClearDepthStencilValue.VkClearDepthStencilValue value = renderPassBegin.clearValues[n] as VkClearValue.VkClearDepthStencilValue.VkClearDepthStencilValue;
                    *((float *)(renderPassBegin_native.pClearValues.ToPointer()) + (n * 4))      = value.depth;
                    *((UInt32 *)(renderPassBegin_native.pClearValues.ToPointer()) + (n * 4 + 1)) = value.stencil;
                }
            }

            _Parent.Device.vkCmdBeginRenderPass(_Handle, new IntPtr(&renderPassBegin_native), contents);

            System.Runtime.InteropServices.Marshal.FreeHGlobal(renderPassBegin_native.pClearValues);
        }
Ejemplo n.º 24
0
 public void CmdNextSubpass(VkSubpassContents contents)
 {
     var _commandBuffer = Handle;
     var _contents = contents;
     Direct.CmdNextSubpass(_commandBuffer, _contents);
 }
Ejemplo n.º 25
0
        public static void vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, VkRenderPassBeginInfo renderPassBeginInfo, VkSubpassContents contents)
        {
            VkPreconditions.CheckNull(commandBuffer, nameof(commandBuffer));

            GetCommandBuffer(commandBuffer).CmdBeginRenderPass(renderPassBeginInfo, contents);
        }
Ejemplo n.º 26
0
 public void CmdBeginRenderPass(
     [FromProperty("this")] GenCommandBuffer commandBuffer,
     GenRenderPassBeginInfo *pRenderPassBegin,
     VkSubpassContents contents)
 {
 }
Ejemplo n.º 27
0
 internal extern static void vkCmdNextSubpass(IntPtr commandBuffer, VkSubpassContents contents);
Ejemplo n.º 28
0
 public Cmd_BeginRenderPass(VkRenderPassBeginInfo renderPassBeginInfo, VkSubpassContents contents)
 {
     this.m_renderPassBeginInfo = renderPassBeginInfo;
     this.m_contents            = contents;
     this.m_ExecuteAction       = new List <Action>();
 }
Ejemplo n.º 29
0
 /// <summary>
 /// To transition to the next subpass in the render pass instance after recording the commands for a subpass, call:
 /// </summary>
 /// <param name="contents">specifies how the commands in the next subpass will be provided, in the same fashion as the corresponding parameter of <see cref="VkCommandBuffer.vkCmdBeginRenderPass"/>.</param>
 public void NextSubpass(VkSubpassContents contents)
 {
     Handle.NextSubpass(contents);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Begin Render pass with framebuffer extent dimensions
 /// </summary>
 public void Begin(PrimaryCommandBuffer cmd, FrameBuffer frameBuffer, VkSubpassContents contents = VkSubpassContents.Inline)
 {
     Begin(cmd, frameBuffer, frameBuffer.Width, frameBuffer.Height, contents);
 }