| 7834 | } |
| 7835 | |
| 7836 | VkResult SwapChainVK::createAttachments(VkCommandBuffer _commandBuffer) |
| 7837 | { |
| 7838 | BGFX_PROFILER_SCOPE("SwapChainVK::createAttachments", kColorFrame); |
| 7839 | |
| 7840 | VkResult result = VK_SUCCESS; |
| 7841 | |
| 7842 | const uint32_t samplerIndex = (m_resolution.reset & BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT; |
| 7843 | const uint64_t textureFlags = (uint64_t(samplerIndex + 1) << BGFX_TEXTURE_RT_MSAA_SHIFT) | BGFX_TEXTURE_RT | BGFX_TEXTURE_RT_WRITE_ONLY; |
| 7844 | m_sampler = s_msaa[samplerIndex]; |
| 7845 | |
| 7846 | const uint16_t requiredCaps = m_sampler.Count > 1 |
| 7847 | ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA |
| 7848 | : BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER |
| 7849 | ; |
| 7850 | |
| 7851 | if (bimg::isDepth(bimg::TextureFormat::Enum(m_resolution.formatDepthStencil) ) ) |
| 7852 | { |
| 7853 | // the spec guarantees that at least one of D24S8 and D32FS8 is supported |
| 7854 | VkFormat depthFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 7855 | |
| 7856 | if (g_caps.formats[m_resolution.formatDepthStencil] & requiredCaps) |
| 7857 | { |
| 7858 | depthFormat = s_textureFormat[m_resolution.formatDepthStencil].m_fmtDsv; |
| 7859 | } |
| 7860 | else if (g_caps.formats[TextureFormat::D24S8] & requiredCaps) |
| 7861 | { |
| 7862 | depthFormat = s_textureFormat[TextureFormat::D24S8].m_fmtDsv; |
| 7863 | } |
| 7864 | |
| 7865 | result = m_backBufferDepthStencil.create( |
| 7866 | _commandBuffer |
| 7867 | , m_sci.imageExtent.width |
| 7868 | , m_sci.imageExtent.height |
| 7869 | , textureFlags |
| 7870 | , depthFormat |
| 7871 | ); |
| 7872 | |
| 7873 | if (VK_SUCCESS != result) |
| 7874 | { |
| 7875 | BX_TRACE("Create swapchain error: creating depth stencil image failed %d: %s.", result, getName(result) ); |
| 7876 | return result; |
| 7877 | } |
| 7878 | |
| 7879 | result = m_backBufferDepthStencil.createView(0, 1, 0, 1 |
| 7880 | , VK_IMAGE_VIEW_TYPE_2D |
| 7881 | , m_backBufferDepthStencil.m_aspectFlags |
| 7882 | , true |
| 7883 | , &m_backBufferDepthStencilImageView |
| 7884 | ); |
| 7885 | |
| 7886 | if (VK_SUCCESS != result) |
| 7887 | { |
| 7888 | BX_TRACE("Create swapchain error: creating depth stencil image view failed %d: %s.", result, getName(result) ); |
| 7889 | return result; |
| 7890 | } |
| 7891 | |
| 7892 | if (m_sampler.Count > 1) |
| 7893 | { |
nothing calls this directly
no test coverage detected