Esempio n. 1
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);
        }
Esempio n. 2
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);
        }