Example #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;
        }