| 1664 | } |
| 1665 | |
| 1666 | static WGPURenderPassEncoder RenderPassBegin(WebGPUContext* context, const float* clear_color, const float* clear_depth, const uint32_t* clear_stencil) |
| 1667 | { |
| 1668 | #if defined(DM_GRAPHICS_WEBGPU2) |
| 1669 | WGPURenderPassDescriptor desc = WGPU_RENDER_PASS_DESCRIPTOR_INIT; |
| 1670 | #else |
| 1671 | WGPURenderPassDescriptor desc = {}; |
| 1672 | #endif |
| 1673 | |
| 1674 | // color |
| 1675 | WGPURenderPassColorAttachment colorAttachments[MAX_BUFFER_COLOR_ATTACHMENTS]; |
| 1676 | for (int i = 0; i < context->m_CurrentRenderPass.m_Target->m_Base.m_ColorAttachmentCount; ++i) |
| 1677 | { |
| 1678 | #if defined(DM_GRAPHICS_WEBGPU2) |
| 1679 | colorAttachments[i] = WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT; |
| 1680 | #else |
| 1681 | colorAttachments[i] = {}; |
| 1682 | #endif |
| 1683 | colorAttachments[i].depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; |
| 1684 | { |
| 1685 | WebGPUTexture* texture = GetAssetFromContainer<WebGPUTexture>(g_WebGPUContext->m_BaseContext.m_AssetHandleContainer, context->m_CurrentRenderPass.m_Target->m_Base.m_TextureColor[i]); |
| 1686 | colorAttachments[i].view = texture->m_TextureView; |
| 1687 | } |
| 1688 | if (context->m_CurrentRenderPass.m_Target->m_TextureResolve[i]) |
| 1689 | { |
| 1690 | WebGPUTexture* texture = GetAssetFromContainer<WebGPUTexture>(g_WebGPUContext->m_BaseContext.m_AssetHandleContainer, context->m_CurrentRenderPass.m_Target->m_TextureResolve[i]); |
| 1691 | colorAttachments[i].resolveTarget = texture->m_TextureView; |
| 1692 | } |
| 1693 | switch (context->m_CurrentRenderPass.m_Target->m_ColorBufferStoreOps[i]) |
| 1694 | { |
| 1695 | case ATTACHMENT_OP_STORE: |
| 1696 | colorAttachments[i].storeOp = WGPUStoreOp_Store; |
| 1697 | break; |
| 1698 | default: |
| 1699 | colorAttachments[i].storeOp = WGPUStoreOp_Undefined; |
| 1700 | break; |
| 1701 | } |
| 1702 | if (clear_color) |
| 1703 | { |
| 1704 | colorAttachments[i].loadOp = WGPULoadOp_Clear; |
| 1705 | colorAttachments[i].clearValue.r = clear_color[0]; |
| 1706 | colorAttachments[i].clearValue.g = clear_color[1]; |
| 1707 | colorAttachments[i].clearValue.b = clear_color[2]; |
| 1708 | colorAttachments[i].clearValue.a = clear_color[3]; |
| 1709 | } |
| 1710 | else |
| 1711 | { |
| 1712 | switch (context->m_CurrentRenderPass.m_Target->m_ColorBufferLoadOps[i]) |
| 1713 | { |
| 1714 | case ATTACHMENT_OP_DONT_CARE: |
| 1715 | case ATTACHMENT_OP_LOAD: |
| 1716 | colorAttachments[i].loadOp = WGPULoadOp_Load; |
| 1717 | break; |
| 1718 | case ATTACHMENT_OP_CLEAR: |
| 1719 | colorAttachments[i].loadOp = WGPULoadOp_Clear; |
| 1720 | colorAttachments[i].clearValue.r = context->m_CurrentRenderPass.m_Target->m_ColorBufferClearValue[i][0]; |
| 1721 | colorAttachments[i].clearValue.g = context->m_CurrentRenderPass.m_Target->m_ColorBufferClearValue[i][1]; |
| 1722 | colorAttachments[i].clearValue.b = context->m_CurrentRenderPass.m_Target->m_ColorBufferClearValue[i][2]; |
| 1723 | colorAttachments[i].clearValue.a = context->m_CurrentRenderPass.m_Target->m_ColorBufferClearValue[i][3]; |
no outgoing calls
no test coverage detected