| 1764 | } |
| 1765 | |
| 1766 | static void WebGPUBeginRenderPass(WebGPUContext* context, const float* clear_color, const float* clear_depth, const uint32_t* clear_stencil) |
| 1767 | { |
| 1768 | TRACE_CALL; |
| 1769 | WebGPUEndComputePass(context); |
| 1770 | if (context->m_CurrentRenderPass.m_Target != context->m_CurrentRenderTarget) |
| 1771 | { |
| 1772 | WebGPUEndRenderPass(context); |
| 1773 | WebGPUCreateCommandEncoder(context); |
| 1774 | ++context->m_RenderPasses; |
| 1775 | |
| 1776 | context->m_CurrentRenderPass.m_Target = context->m_CurrentRenderTarget; |
| 1777 | context->m_CurrentRenderPass.m_Encoder = RenderPassBegin(context, clear_color, clear_depth, clear_stencil); |
| 1778 | |
| 1779 | context->m_CurrentRenderPass.m_Target->m_Scissor[0] = 0; |
| 1780 | context->m_CurrentRenderPass.m_Target->m_Scissor[1] = 0; |
| 1781 | context->m_CurrentRenderPass.m_Target->m_Scissor[2] = context->m_CurrentRenderPass.m_Target->m_Width; |
| 1782 | context->m_CurrentRenderPass.m_Target->m_Scissor[3] = context->m_CurrentRenderPass.m_Target->m_Height; |
| 1783 | } |
| 1784 | |
| 1785 | if (context->m_ViewportChanged) |
| 1786 | { |
| 1787 | const int32_t vx1 = dmMath::Clamp(context->m_ViewportRect[0], 0, int32_t(context->m_CurrentRenderPass.m_Target->m_Width)); |
| 1788 | const int32_t vy1 = dmMath::Clamp(context->m_ViewportRect[1], 0, int32_t(context->m_CurrentRenderPass.m_Target->m_Height)); |
| 1789 | const int32_t vx2 = dmMath::Clamp(context->m_ViewportRect[2], 0, int32_t(context->m_CurrentRenderPass.m_Target->m_Width)); |
| 1790 | const int32_t vy2 = dmMath::Clamp(context->m_ViewportRect[3], 0, int32_t(context->m_CurrentRenderPass.m_Target->m_Height)); |
| 1791 | wgpuRenderPassEncoderSetViewport(context->m_CurrentRenderPass.m_Encoder, vx1, vy1, vx2 - vx1, vy2 - vy1, 0.0f, 1.0f); |
| 1792 | wgpuRenderPassEncoderSetScissorRect(context->m_CurrentRenderPass.m_Encoder, context->m_CurrentRenderPass.m_Target->m_Scissor[0], context->m_CurrentRenderPass.m_Target->m_Scissor[1], context->m_CurrentRenderPass.m_Target->m_Scissor[2], context->m_CurrentRenderPass.m_Target->m_Scissor[3]); |
| 1793 | context->m_ViewportChanged = 0; |
| 1794 | } |
| 1795 | if (context->m_CurrentRenderPass.m_Target->m_Base.m_TextureDepthStencil) |
| 1796 | { |
| 1797 | WebGPUTexture* texture = GetAssetFromContainer<WebGPUTexture>(g_WebGPUContext->m_BaseContext.m_AssetHandleContainer, context->m_CurrentRenderPass.m_Target->m_Base.m_TextureDepthStencil); |
| 1798 | if(texture->m_TextureView) |
| 1799 | wgpuRenderPassEncoderSetStencilReference(context->m_CurrentRenderPass.m_Encoder, context->m_CurrentPipelineState.m_StencilReference); |
| 1800 | } |
| 1801 | } |
| 1802 | |
| 1803 | static void WebGPUClear(HContext _context, uint32_t flags, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, float depth, uint32_t stencil) |
| 1804 | { |
no test coverage detected