Example #1
0
        private void BeginSubpass(SoftwareExecutionContext context)
        {
            SoftwareFramebuffer frameBuffer = (SoftwareFramebuffer)m_renderPassBeginInfo.framebuffer;

            for (int i = 0; i < context.m_CurrentSubpass.colorAttachmentCount; i++)
            {
                var attachmentRef         = context.m_CurrentSubpass.pColorAttachments[i];
                int attachmentIndex       = attachmentRef.attachment;
                var attachmentDescription = context.m_CurrentRenderPass.pAttachments[attachmentIndex];

                if (attachmentDescription.loadOp == VkAttachmentLoadOp.VK_ATTACHMENT_LOAD_OP_CLEAR)
                {
                    SoftwareImageView imageView = frameBuffer.m_createInfo.pAttachments[attachmentIndex] as SoftwareImageView;
                    var clearColor = m_renderPassBeginInfo.pClearValues[attachmentIndex];

                    m_ExecuteAction.Add(() => imageView.ClearColor(clearColor));
                }
            }

            if (context.m_CurrentSubpass.pDepthStencilAttachment != null)
            {
                int attachmentIndex       = context.m_CurrentSubpass.pDepthStencilAttachment[0].attachment;
                var attachmentDescription = context.m_CurrentRenderPass.pAttachments[attachmentIndex];

                if (attachmentDescription.loadOp == VkAttachmentLoadOp.VK_ATTACHMENT_LOAD_OP_CLEAR)
                {
                    SoftwareImageView depthBufferImageView = frameBuffer.m_createInfo.pAttachments[attachmentIndex] as SoftwareImageView;
                    var clearColor = m_renderPassBeginInfo.pClearValues[attachmentIndex];

                    m_ExecuteAction.Add(() => depthBufferImageView.ClearDepth(clearColor));
                }
            }
        }
Example #2
0
 public override void Prepare(SoftwareExecutionContext context)
 {
     for (int i = 0; i < this.descriptorSetCount; i++)
     {
         context.m_DescriptorSets[i + this.firstSet] = (SoftwareDescriptorSet)this.pDescriptorSets[i];
     }
 }
Example #3
0
        internal void BeginRenderPass(SoftwareExecutionContext context)
        {
            context.m_SubpassIndex      = 0;
            context.m_CurrentRenderPass = ((SoftwareRenderPass)m_renderPassBeginInfo.renderPass).m_createInfo;
            context.m_CurrentSubpass    = context.m_CurrentRenderPass.pSubpasses[context.m_SubpassIndex];

            BeginSubpass(context);
        }
Example #4
0
 public override VkResult Parse(SoftwareExecutionContext context)
 {
     for (int i = 0; i < this.descriptorSetCount; i++)
     {
         context.m_DescriptorSets[i + this.firstSet] = (SoftwareDescriptorSet)this.pDescriptorSets[i];
     }
     return(VkResult.VK_SUCCESS);
 }
        public override VkResult Parse(SoftwareExecutionContext context)
        {
            context.m_IndexBuffer       = buffer;
            context.m_IndexBufferOffset = offset;
            context.m_IndexBufferType   = indexType;

            return(VkResult.VK_SUCCESS);
        }
Example #6
0
 public override VkResult Parse(SoftwareExecutionContext context)
 {
     if (context.RenderPassScope == RenderPassScopeEnum.Inside)
     {
         return(context.CommandBufferCompilationError("Missing EndRenderPass on final of the buffer"));
     }
     return(VkResult.VK_SUCCESS);
 }
 public override void Prepare(SoftwareExecutionContext context)
 {
     for (int i = 0; i < bindingCount; i++)
     {
         context.m_VertexBuffers[i + firstBinding]        = pBuffers[i];
         context.m_VertexBuffersOffsets[i + firstBinding] = pOffsets[i];
     }
 }
Example #8
0
 public override void Execute(SoftwareExecutionContext context)
 {
     // context.m_GraphicsContext = new SoftwareGraphicsContext(context.m_Device, context.m_CommandBuffer);
     // context.m_GraphicsContext.m_RenderPassBeginInfo = m_renderPassBeginInfo;
     // context.m_GraphicsContext.BeginRenderPass();
     foreach (var item in m_ExecuteAction)
     {
         item.Invoke();
     }
 }
        public override VkResult Parse(SoftwareExecutionContext context)
        {
            for (int i = 0; i < bindingCount; i++)
            {
                context.m_VertexBuffers[i + firstBinding]        = pBuffers[i];
                context.m_VertexBuffersOffsets[i + firstBinding] = pOffsets[i];
            }

            return(VkResult.VK_SUCCESS);
        }
Example #10
0
 public override void Prepare(SoftwareExecutionContext context)
 {
     if (m_pipelineBindPoint == VkPipelineBindPoint.VK_PIPELINE_BIND_POINT_GRAPHICS)
     {
         context.m_GraphicsPipeline = (SoftwareGraphicsPipeline)m_pipeline;
     }
     else if (m_pipelineBindPoint == VkPipelineBindPoint.VK_PIPELINE_BIND_POINT_COMPUTE)
     {
         context.m_ComputePipeline = m_pipeline;
     }
 }
Example #11
0
        public override VkResult Parse(SoftwareExecutionContext context)
        {
            if (context.RenderPassScope != RenderPassScopeEnum.Inside)
            {
                return(context.CommandBufferCompilationError("Found EndRenderPass but missing BeginRenderPass"));
            }

            context.RenderPassScope = RenderPassScopeEnum.Outside;

            return(VkResult.VK_SUCCESS);
        }
Example #12
0
        public override VkResult Parse(SoftwareExecutionContext context)
        {
            if (context.RenderPassScope == RenderPassScopeEnum.Inside)
            {
                return(context.CommandBufferCompilationError("Found BeginRenderPass without finalizing previous RenderPass"));
            }

            context.RenderPassScope       = RenderPassScopeEnum.Inside;
            context.m_RenderPassBeginInfo = m_renderPassBeginInfo;

            return(VkResult.VK_SUCCESS);
        }
Example #13
0
        public override void Execute(SoftwareExecutionContext context)
        {
            SoftwareDeviceMemory srcMem = srcBuffer.m_deviceMemory;
            SoftwareDeviceMemory dstMem = dstBuffer.m_deviceMemory;

            for (int i = 0; i < regionCount; i++)
            {
                int srcOffset = srcBuffer.m_memoryOffset + pRegions[i].srcOffset;
                int dstOffset = dstBuffer.m_memoryOffset + pRegions[i].dstOffset;
                Buffer.BlockCopy(srcMem.m_bytes, srcOffset, dstMem.m_bytes, dstOffset, pRegions[i].size);
            }
        }
Example #14
0
        public override VkResult Parse(SoftwareExecutionContext context)
        {
            if (context.RenderPassScope != RenderPassScopeEnum.Inside)
            {
                return(context.CommandBufferCompilationError("Found Draw command but missing BeginRenderPass"));
            }

            if (context.m_GraphicsPipeline == null)
            {
                return(context.CommandBufferCompilationError("Found Draw command but missing BindPipeline"));
            }

            return(VkResult.VK_SUCCESS);
        }
Example #15
0
        public override VkResult Parse(SoftwareExecutionContext context)
        {
            if (m_pipelineBindPoint == VkPipelineBindPoint.VK_PIPELINE_BIND_POINT_GRAPHICS)
            {
                SoftwareGraphicsPipeline pipeline = m_pipeline as SoftwareGraphicsPipeline;

                if (pipeline == null)
                {
                    return(context.CommandBufferCompilationError("Informed VkPipelineBindPoint.VK_PIPELINE_BIND_POINT_GRAPHICS without a graphical pipeline"));
                }

                context.m_GraphicsPipeline = pipeline;

                return(VkResult.VK_SUCCESS);
            }
            else if (m_pipelineBindPoint == VkPipelineBindPoint.VK_PIPELINE_BIND_POINT_COMPUTE)
            {
                context.m_ComputePipeline = m_pipeline;

                return(VkResult.VK_SUCCESS);
            }
            throw new NotImplementedException();
        }
Example #16
0
        internal static ISoftwareDepthBuffer Create(SoftwareExecutionContext context)
        {
            VkPipelineDepthStencilStateCreateInfo pDepthStencilState = context.m_GraphicsPipeline.m_graphicsPipelineCreateInfo.pDepthStencilState;

            if (pDepthStencilState.sType != VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO)
            {
                return(new DisabledSoftwareDepthBuffer());
            }

            var frameBufferObj  = (SoftwareFramebuffer)context.m_RenderPassBeginInfo.framebuffer;
            var frameBuffer     = frameBufferObj.m_createInfo;
            int attachmentIndex = -1;
            var subpass         = context.m_CurrentSubpass;

            if (subpass.pDepthStencilAttachment == null)
            {
                context.CommandBufferCompilationError($"WARNING: depth buffer not configured for subpass {context.m_SubpassIndex}");
                return(new DisabledSoftwareDepthBuffer());
            }

            attachmentIndex = subpass.pDepthStencilAttachment[0].attachment;

            if (attachmentIndex < 0 || attachmentIndex >= frameBuffer.attachmentCount)
            {
                context.CommandBufferCompilationError("ERROR: missing or invalid depth buffer attachment index");
                return(new DisabledSoftwareDepthBuffer());
            }

            SoftwareImageView depthBufferImageView = (SoftwareImageView)frameBuffer.pAttachments[attachmentIndex];

            if (depthBufferImageView == null)
            {
                context.CommandBufferCompilationError($"ERROR: missing image view for depth buffer for attachment {attachmentIndex}");
                return(new DisabledSoftwareDepthBuffer());
            }
            return(new SoftwareDepthBuffer(pDepthStencilState, depthBufferImageView));
        }
Example #17
0
 public override void Execute(SoftwareExecutionContext context)
 {
     rasterizer.Draw(vertexCount, instanceCount, firstVertex, firstInstance);
 }
Example #18
0
 public override void Prepare(SoftwareExecutionContext context)
 {
 }
Example #19
0
 public override VkResult Parse(SoftwareExecutionContext context)
 {
     return(VkResult.VK_SUCCESS);
 }
Example #20
0
 public override void Prepare(SoftwareExecutionContext context)
 {
     context.RenderPassScope = RenderPassScopeEnum.Outside;
 }
 public override void Execute(SoftwareExecutionContext context)
 {
     m_dstImage.CopyBufferToImage(m_srcBuffer, m_dstImageLayout, m_regionCount, m_pRegions);
 }
 public abstract void Execute(SoftwareExecutionContext context);
 public abstract VkResult Parse(SoftwareExecutionContext context);
Example #24
0
 public override void Execute(SoftwareExecutionContext context)
 {
     rasterizer.DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
 }
Example #25
0
 public override void Execute(SoftwareExecutionContext context)
 {
     // TODO: Cmd_PipelineBarrier.Execute()
 }
 public override void Prepare(SoftwareExecutionContext context)
 {
     context.m_IndexBuffer       = buffer;
     context.m_IndexBufferOffset = offset;
     context.m_IndexBufferType   = indexType;
 }
Example #27
0
 public override void Prepare(SoftwareExecutionContext context)
 {
     context.RenderPassScope       = RenderPassScopeEnum.Inside;
     context.m_RenderPassBeginInfo = m_renderPassBeginInfo;
     BeginRenderPass(context);
 }
Example #28
0
 public override void Prepare(SoftwareExecutionContext context)
 {
     rasterizer           = new SoftwareRasterizer();
     rasterizer.m_context = context;
     rasterizer.Prepare();
 }