Example #1
0
        public void BeginRenderPassSecondaryCommandBuffers(Framebuffer framebuffer, float r, float g, float b, float a)
        {
            VkClearValue *clearValues = stackalloc VkClearValue[2];

            clearValues[0].color        = new(r, g, b, a);
            clearValues[1].depthStencil = new(1, 0);

            int h = framebuffer.SwapChain.Height;
            int w = framebuffer.SwapChain.Width;
            int x = 0;
            int y = 0;

            VkRenderPassBeginInfo renderPassBeginInfo = new()
            {
                sType      = VkStructureType.RenderPassBeginInfo,
                renderArea = new(x, y, w, h),

                renderPass      = framebuffer.renderPass,
                clearValueCount = 2,
                pClearValues    = clearValues,
                framebuffer     = framebuffer.framebuffers[imageIndex], // Set target frame buffer
            };

            vkCmdBeginRenderPass(handle, &renderPassBeginInfo, VkSubpassContents.SecondaryCommandBuffers);
            set_render_pass = true;
        }
Example #2
0
        public void Set(params VkClearValue[] value)
        {
            IntPtr ptr = (IntPtr)this.pointer;

            value.Set(ref ptr, ref this.count);
            this.pointer = (VkClearValue *)ptr;
        }
Example #3
0
 public VkClearValueGroup(params VkClearValue[] value)
 {
     this.count   = 0;
     this.pointer = null;
     if (value != null)
     {
         IntPtr ptr = IntPtr.Zero;
         value.Set(ref ptr, ref this.count);
         this.pointer = (VkClearValue *)ptr;
     }
 }
        protected override void RecordCommandBuffer(VkCommandBuffer cmdBuffer, int imageIndex)
        {
            VkClearValue *clearValues = stackalloc VkClearValue[2];

            clearValues[0] =
                new VkClearValue
            {
                color = new VkClearColorValue(0.39f, 0.58f, 0.93f, 1.0f)
            };
            clearValues[1]
                = new VkClearValue
                {
                depthStencil = new VkClearDepthStencilValue(1.0f, 0)
                };
            VkRenderPassBeginInfo renderPassBeginInfo = new VkRenderPassBeginInfo
            {
                sType           = VkStructureType.RenderPassBeginInfo,
                pNext           = null,
                framebuffer     = _framebuffers[imageIndex],
                renderArea      = new Vortice.Mathematics.Rectangle(0, 0, Host.Width, Host.Height),
                clearValueCount = 2,
                pClearValues    = clearValues,
                renderPass      = _renderPass
            };

            vkCmdBeginRenderPass(cmdBuffer, &renderPassBeginInfo, VkSubpassContents.Inline);

            VkDescriptorSet descriptorSet = _descriptorSet;

            vkCmdBindDescriptorSets(cmdBuffer, VkPipelineBindPoint.Graphics, _pipelineLayout, 0, 1, &descriptorSet);

            ulong *offsets = stackalloc ulong[1]
            {
                0
            };

            vkCmdBindPipeline(cmdBuffer, VkPipelineBindPoint.Graphics, _pipeline);
            VkBuffer buffer = _cubeVertices.Buffer;

            vkCmdBindVertexBuffers(cmdBuffer, 0, 1, &buffer, offsets);
            vkCmdBindIndexBuffer(cmdBuffer, _cubeIndices.Buffer, 0, VkIndexType.Uint32);
            vkCmdDrawIndexed(cmdBuffer, (uint)_cubeIndices.Count, 1, 0, 0, 0);
            vkCmdEndRenderPass(cmdBuffer);
        }