texture.h

cross platform rendering playground

src/asset/texture.h

1.23 KB
#pragma once

#include "backend/rhi.h"
#include "core/globals.h"

enum struct ImageColorSpace {
    SRGB,
    Linear,
};

struct Arena;
struct QuickSubmit;

bool load_texture_from_memory(
    rhi::Device &device,
    QuickSubmit &qs,
    Arena &staging,
    rhi::Image &out_image,
    rhi::ImageView &out_view,
    const u8 *data,
    usize size,
    ImageColorSpace color_space,
    const char *name = nullptr
);

bool load_texture_ktx2_from_memory(
    rhi::Device &device,
    QuickSubmit &qs,
    Arena &staging,
    rhi::Image &out_image,
    rhi::ImageView &out_view,
    const u8 *data,
    usize size,
    ImageColorSpace color_space,
    const char *name = nullptr
);

bool create_texture_from_raw_rgba(
    rhi::Device &device,
    QuickSubmit &qs,
    Arena &staging,
    rhi::Image &out_image,
    rhi::ImageView &out_view,
    const void *pixels,
    u32 width,
    u32 height,
    u32 pixel_stride,
    rhi::ImageFormat cs,
    const char *name = nullptr
);

bool load_texture(
    rhi::Device &device,
    QuickSubmit &qs,
    Arena &staging,
    const char *path,
    rhi::Image &out_image,
    rhi::ImageView &out_view,
    ImageColorSpace color_space
);

void destroy_texture(rhi::Device &device, rhi::Image &image, rhi::ImageView &view);