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

◆ create_2d_uninitialized()

std::shared_ptr< Core::VKImage > MayaFlux::Portal::Graphics::TextureLoom::create_2d_uninitialized ( uint32_t  width,
uint32_t  height,
ImageFormat  format = ImageFormat::RGBA8,
uint32_t  mip_levels = 1 
)

Allocate a 2D texture without uploading data or transitioning its layout - left VK_IMAGE_LAYOUT_UNDEFINED.

Every create_2d*() overload above performs (and blocks on) an initial layout transition or upload of its own, even when called with no data - create_2d(w, h, format, nullptr) still does a blocking transition to eShaderReadOnlyOptimal before returning. Use this instead when the caller is about to record its own upload right after (e.g. upload_data(image, data, size, staging, true) with deferred=true), so the whole undefined -> transfer-dst -> copy -> shader-read sequence is recorded once into a deferred command batch instead of paying for a separate blocking queue.waitIdle() first.

Parameters
widthWidth in pixels.
heightHeight in pixels.
formatImage format (default RGBA8).
mip_levelsNumber of mipmap levels (1 = no mipmaps).
Returns
VKImage with device memory allocated, still in VK_IMAGE_LAYOUT_UNDEFINED, or nullptr on failure. The caller owns transitioning it before use.

Definition at line 141 of file TextureLoom.cpp.

144{
145 if (!is_initialized()) {
147 "TextureLoom not initialized");
148 return nullptr;
149 }
150
151 auto vk_format = to_vulkan_format(format);
152 auto image = std::make_shared<Core::VKImage>(
153 width, height, 1, vk_format,
156 mip_levels, 1,
158
160
161 if (!image->is_initialized()) {
163 "Failed to initialize VKImage");
164 return nullptr;
165 }
166
167 m_textures.push_back(image);
169 "Created 2D texture (uninitialized): {}x{}, format: {}, mips: {}",
170 width, height, vk::to_string(vk_format), mip_levels);
171 return image;
172}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:47
bool format
uint32_t width
uint32_t height
void initialize_image(const std::shared_ptr< VKImage > &image)
Initialize a VKImage (allocate VkImage, memory, and create image view)
@ TEXTURE_2D
Sampled texture (shader read)
static vk::Format to_vulkan_format(ImageFormat format)
Convert Portal ImageFormat to Vulkan format.
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_COLOR
2D RGB/RGBA image

References format, height, image, MayaFlux::Kakshya::IMAGE_COLOR, MayaFlux::Journal::ImageProcessing, MayaFlux::Core::BackendResourceManager::initialize_image(), is_initialized(), m_resource_manager, m_textures, MF_ERROR, MF_INFO, MayaFlux::Journal::Portal, MayaFlux::Core::VKImage::TEXTURE_2D, to_vulkan_format(), MayaFlux::Core::VKImage::TYPE_2D, and width.

+ Here is the call graph for this function: