| 4269 | } |
| 4270 | |
| 4271 | static HRenderTarget VulkanNewRenderTarget(HContext _context, uint32_t buffer_type_flags, const RenderTargetCreationParams params) |
| 4272 | { |
| 4273 | VulkanContext* context = (VulkanContext*)_context; |
| 4274 | VulkanRenderTarget* rt = new VulkanRenderTarget(GetNextRenderTargetId()); |
| 4275 | |
| 4276 | memcpy(rt->m_Base.m_ColorTextureParams, params.m_ColorBufferParams, sizeof(TextureParams) * MAX_BUFFER_COLOR_ATTACHMENTS); |
| 4277 | memcpy(rt->m_ColorBufferLoadOps, params.m_ColorBufferLoadOps, sizeof(AttachmentOp) * MAX_BUFFER_COLOR_ATTACHMENTS); |
| 4278 | memcpy(rt->m_ColorBufferStoreOps, params.m_ColorBufferStoreOps, sizeof(AttachmentOp) * MAX_BUFFER_COLOR_ATTACHMENTS); |
| 4279 | |
| 4280 | rt->m_Base.m_DepthStencilTextureParams = (buffer_type_flags & BUFFER_TYPE_DEPTH_BIT) ? |
| 4281 | params.m_DepthBufferParams : |
| 4282 | params.m_StencilBufferParams; |
| 4283 | |
| 4284 | // don't save the data |
| 4285 | for (uint32_t i = 0; i < MAX_BUFFER_TYPE_COUNT; ++i) |
| 4286 | { |
| 4287 | ClearTextureParamsData(rt->m_Base.m_ColorTextureParams[i]); |
| 4288 | } |
| 4289 | ClearTextureParamsData(rt->m_Base.m_DepthStencilTextureParams); |
| 4290 | |
| 4291 | BufferType buffer_types[MAX_BUFFER_COLOR_ATTACHMENTS]; |
| 4292 | HTexture texture_color[MAX_BUFFER_COLOR_ATTACHMENTS]; |
| 4293 | HTexture texture_depth_stencil = 0; |
| 4294 | |
| 4295 | uint8_t has_depth = buffer_type_flags & dmGraphics::BUFFER_TYPE_DEPTH_BIT; |
| 4296 | uint8_t has_stencil = buffer_type_flags & dmGraphics::BUFFER_TYPE_STENCIL_BIT; |
| 4297 | uint8_t color_index = 0; |
| 4298 | |
| 4299 | uint16_t fb_width = 0; |
| 4300 | uint16_t fb_height = 0; |
| 4301 | |
| 4302 | BufferType color_buffer_flags[] = { |
| 4303 | BUFFER_TYPE_COLOR0_BIT, |
| 4304 | BUFFER_TYPE_COLOR1_BIT, |
| 4305 | BUFFER_TYPE_COLOR2_BIT, |
| 4306 | BUFFER_TYPE_COLOR3_BIT, |
| 4307 | }; |
| 4308 | |
| 4309 | for (int i = 0; i < MAX_BUFFER_COLOR_ATTACHMENTS; ++i) |
| 4310 | { |
| 4311 | BufferType buffer_type = color_buffer_flags[i]; |
| 4312 | |
| 4313 | if (buffer_type_flags & buffer_type) |
| 4314 | { |
| 4315 | TextureParams& color_buffer_params = rt->m_Base.m_ColorTextureParams[i]; |
| 4316 | fb_width = color_buffer_params.m_Width; |
| 4317 | fb_height = color_buffer_params.m_Height; |
| 4318 | |
| 4319 | VkFormat vk_color_format; |
| 4320 | |
| 4321 | // Promote format to RGBA if RGB, since it's not supported |
| 4322 | if (color_buffer_params.m_Format == TEXTURE_FORMAT_RGB) |
| 4323 | { |
| 4324 | vk_color_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4325 | color_buffer_params.m_Format = TEXTURE_FORMAT_RGBA; |
| 4326 | } |
| 4327 | else |
| 4328 | { |
nothing calls this directly
no test coverage detected