MayaFlux 0.1.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 244 of file TextureLoom.cpp.

246{
247 if (!is_initialized()) {
249 "TextureLoom not initialized");
250 return nullptr;
251 }
252
253 vk::Format vk_format = with_stencil
254 ? vk::Format::eD24UnormS8Uint
255 : vk::Format::eD32Sfloat;
256
257 auto image = std::make_shared<Core::VKImage>(
258 width, height, 1, vk_format,
262
264
265 if (!image->is_initialized()) {
267 "Failed to initialize depth buffer VKImage");
268 return nullptr;
269 }
270
271 vk::ImageAspectFlags aspect = with_stencil
272 ? (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil)
273 : vk::ImageAspectFlagBits::eDepth;
274
276 image->get_image(),
277 vk::ImageLayout::eUndefined,
278 vk::ImageLayout::eDepthStencilAttachmentOptimal,
279 1, 1, aspect);
280 image->set_current_layout(vk::ImageLayout::eDepthStencilAttachmentOptimal);
281
282 m_textures.push_back(image);
284 "Created depth buffer: {}x{}, format: {}, stencil: {}",
285 width, height, vk::to_string(vk_format), with_stencil);
286 return image;
287}
#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)

References MayaFlux::Core::VKImage::DEPTH_STENCIL, 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(), and MayaFlux::Core::VKImage::TYPE_2D.

+ Here is the call graph for this function: