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)); } } }
internal SoftwareSampler2D(VkImageLayout imageLayout, SoftwareImageView imageView, SoftwareSampler sampler) { this.imageLayout = imageLayout; this.imageView = imageView; this.sampler = sampler; this.m_Width = imageView.GetWidth(); this.m_Height = imageView.GetHeight(); }
internal SoftwareDepthBuffer(VkPipelineDepthStencilStateCreateInfo state, SoftwareImageView depthBufferImageView) { m_State = state; if (m_State.depthTestEnable == VkBool32.VK_TRUE) { m_CompareOp = GetCompareOp(state.depthCompareOp); } else { m_CompareOp = GetCompareOp(VkCompareOp.VK_COMPARE_OP_ALWAYS); } m_depthBufferImageView = depthBufferImageView; }
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)); }