| 1812 | } |
| 1813 | |
| 1814 | static void WebGPUBeginFrame(HContext _context) |
| 1815 | { |
| 1816 | TRACE_CALL; |
| 1817 | WebGPUContext* context = (WebGPUContext*)_context; |
| 1818 | { |
| 1819 | const uint32_t window_width = GetWindowWidth(_context); |
| 1820 | const uint32_t window_height = GetWindowHeight(_context); |
| 1821 | if (!context->m_MainRenderTarget || window_width != context->m_BaseContext.m_Width || window_height != context->m_BaseContext.m_Height) // (re)create |
| 1822 | WebGPUConfigure(context, window_width, window_height); |
| 1823 | WebGPUTexture* textureDepthStencil = GetAssetFromContainer<WebGPUTexture>(context->m_BaseContext.m_AssetHandleContainer, context->m_MainRenderTarget->m_Base.m_TextureDepthStencil); |
| 1824 | #if defined(DM_GRAPHICS_WEBGPU2) |
| 1825 | WGPUSurfaceTexture surfaceColorTexture = WGPU_SURFACE_TEXTURE_INIT; |
| 1826 | #else |
| 1827 | WGPUSurfaceTexture surfaceColorTexture = {}; |
| 1828 | #endif |
| 1829 | wgpuSurfaceGetCurrentTexture(context->m_Surface, &surfaceColorTexture); |
| 1830 | |
| 1831 | WGPUTexture currentColorTexture = surfaceColorTexture.texture; |
| 1832 | const uint32_t currentWidth = wgpuTextureGetWidth(currentColorTexture), |
| 1833 | currentHeight = wgpuTextureGetHeight(currentColorTexture); |
| 1834 | WGPUTextureView currentColorTextureView; |
| 1835 | { |
| 1836 | #if defined(DM_GRAPHICS_WEBGPU2) |
| 1837 | WGPUTextureViewDescriptor textureViewDesc = WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT; |
| 1838 | #else |
| 1839 | WGPUTextureViewDescriptor textureViewDesc = {}; |
| 1840 | #endif |
| 1841 | textureViewDesc.aspect = WGPUTextureAspect_All; |
| 1842 | textureViewDesc.format = context->m_Format; |
| 1843 | textureViewDesc.dimension = WGPUTextureViewDimension_2D; |
| 1844 | textureViewDesc.arrayLayerCount = 1; |
| 1845 | textureViewDesc.mipLevelCount = 1; |
| 1846 | currentColorTextureView = wgpuTextureCreateView(currentColorTexture, &textureViewDesc); |
| 1847 | } |
| 1848 | |
| 1849 | if (context->m_MainRenderTarget->m_Multisample == 1) { |
| 1850 | WebGPUTexture* textureColor = GetAssetFromContainer<WebGPUTexture>(context->m_BaseContext.m_AssetHandleContainer, context->m_MainRenderTarget->m_Base.m_TextureColor[0]); |
| 1851 | textureColor->m_Texture = currentColorTexture; |
| 1852 | textureColor->m_TextureView = currentColorTextureView; |
| 1853 | textureColor->m_Base.m_Width = (uint16_t) dmMath::Min(currentWidth, 0xFFFFu); |
| 1854 | textureColor->m_Base.m_Height = (uint16_t) dmMath::Min(currentHeight, 0xFFFFu); |
| 1855 | #if defined(DM_GRAPHICS_WEBGPU_WAGYU_USE_DEPTHSTENCIL) |
| 1856 | if (WGPUTexture currentDepthStencilTexture = wgpuWagyuSurfaceGetCurrentDepthStencilTexture(context->m_Surface)) { |
| 1857 | WGPUTextureFormat currentDepthStencilFormat = wgpuTextureGetFormat(currentDepthStencilTexture); |
| 1858 | WGPUTextureView currentDepthStencilTextureView; |
| 1859 | { |
| 1860 | WGPUTextureViewDescriptor textureViewDesc = WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT; |
| 1861 | textureViewDesc.aspect = WGPUTextureAspect_All; |
| 1862 | textureViewDesc.format = currentDepthStencilFormat; |
| 1863 | textureViewDesc.dimension = WGPUTextureViewDimension_2D; |
| 1864 | textureViewDesc.arrayLayerCount = 1; |
| 1865 | textureViewDesc.mipLevelCount = 1; |
| 1866 | currentDepthStencilTextureView = wgpuTextureCreateView(currentDepthStencilTexture, &textureViewDesc); |
| 1867 | } |
| 1868 | textureDepthStencil->m_Format = currentDepthStencilFormat; |
| 1869 | assert(!textureDepthStencil->m_Texture); |
| 1870 | textureDepthStencil->m_Texture = currentDepthStencilTexture; |
| 1871 | assert(!textureDepthStencil->m_TextureView); |
nothing calls this directly
no test coverage detected