24efee80e2
Dos primitivas del pipeline de shaders_lab que ya estaban en uso pero sin indexar al registry: - code_to_generator_cpp_gfx (function, pure) Traduce un fragment shader GLSL escrito a mano (modo Code, con void main() + fragColor = ...) en un body de DAG Gen + DagControl[]. Cada uniform anotado se convierte en un control; el body usa el parametro uv y reemplaza fragColor= por return. Empaqueta uniforms en vec4 (4 x n_uniforms). - shaderlab_db_cpp_gfx (function, impure) CRUD persistente para generators custom de shaders_lab via sqlite3. Guarda el GLSL original, el body traducido para el DAG, los DagControl y los param_defaults en una BD local (shaders_lab.db). Soporta open(:memory:) para tests. Ambas se indexan ahora en registry.db y son reusables fuera de shaders_lab si en el futuro hay otra app que componga DAGs de shaders.
51 lines
2.1 KiB
C++
51 lines
2.1 KiB
C++
#pragma once
|
|
#include "gfx/dag_types.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct sqlite3; // fwd decl
|
|
|
|
namespace fn::gfx {
|
|
|
|
// Persistent record for a user-saved generator (Code → DAG Gen).
|
|
struct GeneratorRecord {
|
|
std::string id; // snake_case unique
|
|
std::string label; // visible name in palette
|
|
std::string description; // free text
|
|
std::string source_glsl; // original Code (with fragColor, uniforms)
|
|
std::string body_glsl; // translated DAG Gen body (with return)
|
|
int param_count = 0; // number of floats in u_params block
|
|
std::vector<float> param_defaults;
|
|
std::vector<std::string> param_names;
|
|
std::vector<DagControl> controls;
|
|
std::string tags; // CSV
|
|
std::string created_at; // ISO-8601 (set by save if empty)
|
|
std::string updated_at; // ISO-8601 (set by save)
|
|
};
|
|
|
|
// Open the database at `path` (created if missing). ":memory:" is supported for tests.
|
|
// Returns true on success. Idempotent: calling open() again with the same path is a no-op.
|
|
bool shaderlab_db_open(const std::string& path);
|
|
|
|
// Close the active connection (no-op if not open).
|
|
void shaderlab_db_close();
|
|
|
|
// Insert or replace a generator. Sets gen.created_at if empty and updated_at unconditionally
|
|
// (caller's struct is updated in place too). Returns false on SQL error.
|
|
bool shaderlab_db_save_generator(GeneratorRecord& gen, std::string* err = nullptr);
|
|
|
|
// Load all generators ordered by label.
|
|
std::vector<GeneratorRecord> shaderlab_db_list_generators();
|
|
|
|
// Load a single generator by id. Returns false if not found.
|
|
bool shaderlab_db_get_generator(const std::string& id, GeneratorRecord& out);
|
|
|
|
// Remove a generator by id. Returns true if a row was deleted.
|
|
bool shaderlab_db_delete_generator(const std::string& id);
|
|
|
|
// Returns the underlying sqlite3* handle (or nullptr if not open).
|
|
// For composing additional tables (e.g. ui_layouts) on the same connection.
|
|
sqlite3* shaderlab_db_handle();
|
|
|
|
} // namespace fn::gfx
|