| 992 | } |
| 993 | |
| 994 | static void WebGPUConfigure(WebGPUContext* context, uint32_t width, uint32_t height) |
| 995 | { |
| 996 | // configure |
| 997 | { |
| 998 | #if defined(DM_GRAPHICS_WEBGPU2) |
| 999 | WGPUSurfaceConfiguration surface_conf = WGPU_SURFACE_CONFIGURATION_INIT; |
| 1000 | #else |
| 1001 | WGPUSurfaceConfiguration surface_conf = {}; |
| 1002 | #endif |
| 1003 | surface_conf.device = context->m_Device; |
| 1004 | surface_conf.usage = g_rendertarget_usage; |
| 1005 | surface_conf.format = context->m_Format; |
| 1006 | surface_conf.width = width; |
| 1007 | surface_conf.height = height; |
| 1008 | surface_conf.presentMode = WGPUPresentMode_Fifo; |
| 1009 | wgpuSurfaceConfigure(context->m_Surface, &surface_conf); |
| 1010 | } |
| 1011 | |
| 1012 | // rendertarget |
| 1013 | if (!context->m_MainRenderTarget) |
| 1014 | { |
| 1015 | context->m_MainRenderTarget = new WebGPURenderTarget(); |
| 1016 | context->m_MainRenderTarget->m_Multisample = dmPlatform::GetWindowStateParam(context->m_BaseContext.m_Window, WINDOW_STATE_SAMPLE_COUNT); |
| 1017 | if (!context->m_MainRenderTarget->m_Multisample) |
| 1018 | context->m_MainRenderTarget->m_Multisample = 1; |
| 1019 | else if (context->m_MainRenderTarget->m_Multisample != 1) |
| 1020 | context->m_MainRenderTarget->m_Multisample = 4; // only 1 and 4 are supported |
| 1021 | context->m_MainRenderTarget->m_Base.m_ColorAttachmentCount = 1; |
| 1022 | context->m_MainRenderTarget->m_ColorBufferStoreOps[0] = ATTACHMENT_OP_STORE; |
| 1023 | context->m_MainRenderTarget->m_ColorBufferLoadOps[0] = ATTACHMENT_OP_LOAD; |
| 1024 | } |
| 1025 | context->m_MainRenderTarget->m_Width = context->m_BaseContext.m_Width = width; |
| 1026 | context->m_MainRenderTarget->m_Height = context->m_BaseContext.m_Height = height; |
| 1027 | // colorbuffer |
| 1028 | if (context->m_MainRenderTarget->m_Multisample == 1) |
| 1029 | { |
| 1030 | WebGPUTexture* textureColor = GetAssetFromContainer<WebGPUTexture>(context->m_BaseContext.m_AssetHandleContainer, context->m_MainRenderTarget->m_Base.m_TextureColor[0]); |
| 1031 | if (!textureColor) |
| 1032 | { |
| 1033 | textureColor = new WebGPUTexture(); |
| 1034 | context->m_MainRenderTarget->m_Base.m_TextureColor[0] = StoreAssetInContainer(context->m_BaseContext.m_AssetHandleContainer, textureColor, ASSET_TYPE_TEXTURE); |
| 1035 | } |
| 1036 | textureColor->m_Base.m_Width = (uint16_t) dmMath::Min(width, 0xFFFFu); |
| 1037 | textureColor->m_Base.m_Height = (uint16_t) dmMath::Min(height, 0xFFFFu); |
| 1038 | textureColor->m_Format = context->m_Format; |
| 1039 | } |
| 1040 | else |
| 1041 | { |
| 1042 | WebGPUTexture* textureColor = GetAssetFromContainer<WebGPUTexture>(context->m_BaseContext.m_AssetHandleContainer, context->m_MainRenderTarget->m_Base.m_TextureColor[0]); |
| 1043 | if (textureColor) |
| 1044 | { |
| 1045 | delete textureColor; |
| 1046 | context->m_BaseContext.m_AssetHandleContainer.Release(context->m_MainRenderTarget->m_Base.m_TextureColor[0]); |
| 1047 | } |
| 1048 | { |
| 1049 | TextureCreationParams params; |
| 1050 | params.m_Width = 0; |
| 1051 | params.m_Height = 0; |
no test coverage detected