Create a depth buffer.
253{
256 "TextureLoom not initialized");
257 return nullptr;
258 }
259
260 vk::Format vk_format = with_stencil
261 ? vk::Format::eD24UnormS8Uint
262 : vk::Format::eD32Sfloat;
263
264 auto image = std::make_shared<Core::VKImage>(
265 width, height, 1, vk_format,
269
271
272 if (!
image->is_initialized()) {
274 "Failed to initialize depth buffer VKImage");
275 return nullptr;
276 }
277
278 vk::ImageAspectFlags aspect = with_stencil
279 ? (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil)
280 : vk::ImageAspectFlagBits::eDepth;
281
284 vk::ImageLayout::eUndefined,
285 vk::ImageLayout::eDepthStencilAttachmentOptimal,
286 1, 1, aspect);
287 image->set_current_layout(vk::ImageLayout::eDepthStencilAttachmentOptimal);
288
291 "Created depth buffer: {}x{}, format: {}, stencil: {}",
292 width, height, vk::to_string(vk_format), with_stencil);
294}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
void initialize_image(const std::shared_ptr< VKImage > &image)
Initialize a VKImage (allocate VkImage, memory, and create image view)
void transition_image_layout(vk::Image image, vk::ImageLayout old_layout, vk::ImageLayout new_layout, uint32_t mip_levels=1, uint32_t array_layers=1, vk::ImageAspectFlags aspect_flags=vk::ImageAspectFlagBits::eColor)
Transition image layout using a pipeline barrier.
@ DEPTH_STENCIL
Depth/stencil attachment.
Core::BackendResourceManager * m_resource_manager
std::vector< std::shared_ptr< Core::VKImage > > m_textures
bool is_initialized() const
Check if manager is initialized.
@ ImageProcessing
Image processing tasks (filters, transformations)
@ Portal
High-level user-facing API layer.
@ IMAGE_2D
2D image (grayscale or single channel)