MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create_depth_buffer()

std::shared_ptr< Core::VKImage > MayaFlux::Portal::Graphics::TextureLoom::create_depth_buffer ( uint32_t  width,
uint32_t  height,
bool  with_stencil = false 
)

Create a depth buffer.

Parameters
widthWidth in pixels
heightHeight in pixels
with_stencilWhether to include stencil component
Returns
Initialized VKImage configured as depth/stencil attachment

Definition at line 303 of file TextureLoom.cpp.

305{
306 if (!is_initialized()) {
308 "TextureLoom not initialized");
309 return nullptr;
310 }
311
312 vk::Format vk_format = with_stencil
313 ? vk::Format::eD24UnormS8Uint
314 : vk::Format::eD32Sfloat;
315
316 auto image = std::make_shared<Core::VKImage>(
317 width, height, 1, vk_format,
321
323
324 if (!image->is_initialized()) {
326 "Failed to initialize depth buffer VKImage");
327 return nullptr;
328 }
329
330 vk::ImageAspectFlags aspect = with_stencil
331 ? (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil)
332 : vk::ImageAspectFlagBits::eDepth;
333
335 image->get_image(),
336 vk::ImageLayout::eUndefined,
337 vk::ImageLayout::eDepthStencilAttachmentOptimal,
338 1, 1, aspect);
339 image->set_current_layout(vk::ImageLayout::eDepthStencilAttachmentOptimal);
340
341 m_textures.push_back(image);
343 "Created depth buffer: {}x{}, format: {}, stencil: {}",
344 width, height, vk::to_string(vk_format), with_stencil);
345 return image;
346}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:64
uint32_t width
Definition Decoder.cpp:66
uint32_t height
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)

References MayaFlux::Core::VKImage::DEPTH_STENCIL, height, image, MayaFlux::Kakshya::IMAGE_2D, MayaFlux::Journal::ImageProcessing, MayaFlux::Core::BackendResourceManager::initialize_image(), is_initialized(), m_resource_manager, m_textures, MF_ERROR, MF_INFO, MayaFlux::Journal::Portal, MayaFlux::Core::BackendResourceManager::transition_image_layout(), MayaFlux::Core::VKImage::TYPE_2D, and width.

+ Here is the call graph for this function: