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

◆ TextureBuffer()

MayaFlux::Buffers::TextureBuffer::TextureBuffer ( uint32_t  width,
uint32_t  height,
Portal::Graphics::ImageFormat  format,
const void *  initial_pixel_data = nullptr 
)

Create texture buffer with dimensions.

Parameters
widthTexture width in pixels
heightTexture height in pixels
formatPixel format
initial_pixel_dataOptional initial pixel data (nullptr = uninitialized)

The VKBuffer itself contains fullscreen quad vertices. The texture pixels are stored separately and uploaded to VKImage.

Definition at line 12 of file TextureBuffer.cpp.

17 : VKBuffer(
19 Usage::VERTEX,
21 , m_width(width)
24{
25 RenderConfig default_config;
26 default_config.vertex_shader = "texture.vert.spv";
27 default_config.fragment_shader = "texture.frag.spv";
28 if (format == Portal::Graphics::ImageFormat::R8) {
29 default_config.fragment_shader = "texture_gray.frag.spv";
30 } else if (format == Portal::Graphics::ImageFormat::RG8) {
31 default_config.fragment_shader = "texture_gray_alpha.frag.spv";
32 }
33 default_config.default_texture_binding = "texSampler";
35 set_default_render_config(default_config);
36
37 if (initial_pixel_data) {
38 size_t pixel_bytes = static_cast<size_t>(width) * height * Portal::Graphics::TextureLoom::get_bytes_per_pixel(format);
39 m_pixel_data.resize(pixel_bytes);
40 std::memcpy(m_pixel_data.data(), initial_pixel_data, pixel_bytes);
41 }
42
44
46 "Created TextureBuffer: {}x{} ({} pixel bytes, {} vertex bytes)",
48}
#define MF_INFO(comp, ctx,...)
bool format
uint32_t width
uint32_t height
std::vector< uint8_t > m_pixel_data
Portal::Graphics::ImageFormat m_format
std::vector< uint8_t > m_vertex_bytes
Portal::Graphics::RenderConfig RenderConfig
Definition VKBuffer.hpp:78
void set_default_render_config(const RenderConfig &config)
Called by derived classes to set their context-specific defaults.
Definition VKBuffer.hpp:631
static size_t get_bytes_per_pixel(ImageFormat format)
Get bytes per pixel for a format.
@ Init
Engine/subsystem initialization.
@ Buffers
Buffers, Managers, processors and processing chains.
@ IMAGE_COLOR
2D RGB/RGBA image

References MayaFlux::Portal::Graphics::RenderConfig::default_texture_binding, format, MayaFlux::Portal::Graphics::RenderConfig::fragment_shader, generate_default_quad(), MayaFlux::Portal::Graphics::TextureLoom::get_bytes_per_pixel(), height, m_pixel_data, MayaFlux::Buffers::VKBuffer::set_default_render_config(), MayaFlux::Portal::Graphics::RenderConfig::topology, MayaFlux::Portal::Graphics::TRIANGLE_STRIP, MayaFlux::Portal::Graphics::RenderConfig::vertex_shader, and width.

+ Here is the call graph for this function: