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

◆ create_2d() [1/2]

std::shared_ptr< Core::VKImage > MayaFlux::Portal::Graphics::TextureLoom::create_2d ( const Kakshya::DataVariant variant,
uint32_t  width,
uint32_t  height,
ImageFormat  format = ImageFormat::RGBA32F 
)

Create a 2D texture from a DataVariant in one shot.

Parameters
variantSource data. Conversion and validation delegated to Kakshya::as_texture_access(): vec3 is promoted to vec4 with W=0 (warned); complex<double> and mat4 are rejected.
widthTexture width in texels.
heightTexture height in texels.
formatTarget image format (default: RGBA32F).
Returns
Initialised VKImage in shader-read layout, or nullptr on failure.

Validates byte count against width * height * bpp(format) before upload. Throws std::invalid_argument on mismatch.

Definition at line 334 of file TextureLoom.cpp.

339{
340 if (!is_initialized()) {
342 "TextureLoom not initialized");
343 return nullptr;
344 }
345
346 const auto access = Kakshya::as_texture_access(variant);
347 if (!access) {
348 return nullptr;
349 }
350
351 const size_t expected = calculate_image_size(width, height, 1, format);
352 if (access->byte_count != expected) {
353 error<std::invalid_argument>(
356 std::source_location::current(),
357 "create_2d: byte count mismatch — {} bytes supplied, "
358 "{}x{} format {} requires {}",
359 access->byte_count, width, height, static_cast<int>(format), expected);
360 }
361
362 return create_2d(width, height, format, access->data_ptr, 1);
363}
#define MF_ERROR(comp, ctx,...)
uint32_t width
static size_t calculate_image_size(uint32_t width, uint32_t height, uint32_t depth, ImageFormat format)
Calculate image data size.
std::shared_ptr< Core::VKImage > create_2d(uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr, uint32_t mip_levels=1)
Create a 2D texture.
bool is_initialized() const
Check if manager is initialized.
@ ImageProcessing
Image processing tasks (filters, transformations)
@ Portal
High-level user-facing API layer.
std::optional< TextureAccess > as_texture_access(const DataVariant &variant)
Extract a TextureAccess from a DataVariant.

References MayaFlux::Kakshya::as_texture_access(), calculate_image_size(), create_2d(), MayaFlux::Journal::ImageProcessing, is_initialized(), MF_ERROR, MayaFlux::Journal::Portal, and width.

+ Here is the call graph for this function: