do not edit — generated by btf.
git.druid.rocksindexmilitantprogrammerastral_canvassrc/render/render.h

src/render/render.h


#ifndef RENDER_H
#define RENDER_H
 
#include "api/canvas.h"
#include "../platform/platform.h"
#include "vk.h"
 
#include <stdbool.h>
#include <stdint.h>
 
enum { HUD_MAX_GLYPHS = 1024 };
enum { CELL_W = 10, CELL_H = 20};
 
/*
 * One HUD character. x/y are logical surface pixels (top-left of the
 * glyph). color is 0xAARRGGBB. character is ASCII; out-of-range maps to '?'.
 */
typedef struct {
    float x, y;
    uint32_t color;
    uint32_t character;
} Glyph;
 
/*
 * Per-frame HUD description. Background, hover cell, grid, and the top bar
 * are drawn by the GPU HUD shader or the CPU fallback. glyphs[] is text
 * on top (atlas on GPU, font_draw on CPU).
 *
 * hudHeight / cellWidth / cellHeight are logical pixels. Colors are 0–1 RGBA.
 */
typedef struct {
    float scale;
    float hudHeight, cellWidth, cellHeight;
    int columns, rows;
    int hoverColumn, hoverRow;
    int hover;
    float background[4];
    float grid[4];
    float hoverColor[4];
    float bar[4];
    const Glyph *glyphs;
    int glyphCount;
} Hud;
 
/*
 * Packed copy of Hud plus swapchain size, matching the std140 Scene UBO.
 * Field order and types must stay in lockstep with the shaders.
 */
typedef struct {
    float resolution[2];
    float scale;
    float hudHeight;
    float cellWidth;
    float cellHeight;
    int32_t columns;
    int32_t rows;
    int32_t hoverColumn;
    int32_t hoverRow;
    int32_t hover;
    int32_t padding;
    float background[4];
    float grid[4];
    float hoverColor[4];
    float bar[4];
} SceneUniform;
 
/*
 * Host-visible instance record for text.vert.
 */
typedef struct {
    float x, y;
    uint32_t rgba;
    uint32_t character;
} GlyphVertex;
 
typedef struct {
    VkBuffer uniformBuffer;
    VkDeviceMemory uniformBufferMemory;
    void *uniformBufferMapped;
    VkBuffer glyphBuffer;
    VkDeviceMemory glyphBufferMemory;
    void *glyphBufferMapped;
    VkDescriptorSet descriptorSet;
} RenderFrame;
 
/*
 * Vulkan renderer. rendererInit() fails if WSI/device/pipelines cannot start.
 */
typedef struct {
    VkContext vulkan;
    bool useVulkan;
 
    VkDescriptorSetLayout descriptorSetLayout;
    VkPipelineLayout pipelineLayout;
    VkPipeline hudPipeline;
    VkPipeline textPipeline;
    VkSampler sampler;
    VkImage fontImage;
    VkDeviceMemory fontMemory;
    VkImageView fontView;
    VkDescriptorPool descriptorPool;
    RenderFrame frames[VK_MAX_FRAMES];
} Renderer;
 
int rendererInit(Renderer *renderer, Platform *platform);
int rendererFrame(Renderer *renderer, Platform *platform, const Hud *hud);
void rendererDestroy(Renderer *renderer);
 
void rendererFillClear(Platform *platform, const Style *theme, Mode mode, Hud *hud);
#endif
powered by btf.