Checkpoint 2: integrate native Editor, MCP, gameplay builds and standalone export
This commit is contained in:
@@ -6,15 +6,21 @@ namespace faset::render {
|
||||
// Ordered single-queue graph. Reads must be imported or produced by an earlier pass.
|
||||
// The Vulkan executor performs barriers at each resource state transition.
|
||||
class RenderGraph {
|
||||
public:
|
||||
public:
|
||||
using Callback = std::function<void()>;
|
||||
void import(std::string resource);
|
||||
void add(std::string name, std::vector<std::string> reads, std::vector<std::string> writes, Callback execute);
|
||||
void add(std::string name, std::vector<std::string> reads, std::vector<std::string> writes,
|
||||
Callback execute);
|
||||
void execute() const;
|
||||
std::vector<std::string> pass_names() const;
|
||||
private:
|
||||
struct Pass {std::string name; std::vector<std::string> reads, writes; Callback callback;};
|
||||
|
||||
private:
|
||||
struct Pass {
|
||||
std::string name;
|
||||
std::vector<std::string> reads, writes;
|
||||
Callback callback;
|
||||
};
|
||||
std::vector<std::string> imports_;
|
||||
std::vector<Pass> passes_;
|
||||
};
|
||||
}
|
||||
} // namespace faset::render
|
||||
|
||||
@@ -11,37 +11,68 @@ using Vec2 = std::array<float, 2>;
|
||||
using Vec3 = std::array<float, 3>;
|
||||
using Color = std::array<float, 4>;
|
||||
using Mat4 = std::array<float, 16>;
|
||||
inline constexpr Mat4 identity{1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
|
||||
inline constexpr Mat4 identity{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
|
||||
// Matrices are column-major, vectors are columns; clip depth is Vulkan's [0,1].
|
||||
Mat4 multiply(const Mat4&, const Mat4&);
|
||||
Mat4 transform(Vec3 position, Vec3 rotation = {}, Vec3 scale = {1,1,1});
|
||||
Mat4 transform(Vec3 position, Vec3 rotation = {}, Vec3 scale = {1, 1, 1});
|
||||
Mat4 perspective(float vertical_fov_radians, float aspect, float near_plane, float far_plane);
|
||||
Mat4 orthographic(float left, float right, float bottom, float top, float near_plane, float far_plane);
|
||||
Mat4 look_at(Vec3 eye, Vec3 target, Vec3 up = {0,1,0});
|
||||
struct Vertex { Vec3 position{}; Vec3 normal{0,0,1}; Color color{1,1,1,1}; Vec2 uv{}; };
|
||||
struct Mesh { std::vector<Vertex> vertices; std::vector<std::uint32_t> indices; };
|
||||
Mat4 orthographic(float left, float right, float bottom, float top, float near_plane,
|
||||
float far_plane);
|
||||
Mat4 look_at(Vec3 eye, Vec3 target, Vec3 up = {0, 1, 0});
|
||||
struct Vertex {
|
||||
Vec3 position{};
|
||||
Vec3 normal{0, 0, 1};
|
||||
Color color{1, 1, 1, 1};
|
||||
Vec2 uv{};
|
||||
};
|
||||
struct Mesh {
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<std::uint32_t> indices;
|
||||
};
|
||||
std::shared_ptr<const Mesh> cube_mesh();
|
||||
struct Texture;
|
||||
struct DrawItem {
|
||||
std::shared_ptr<const Mesh> mesh;
|
||||
Mat4 model{identity};
|
||||
Color color{1,1,1,1};
|
||||
Color color{1, 1, 1, 1};
|
||||
float roughness{0.65f};
|
||||
float metallic{0.0f};
|
||||
bool cast_shadow{true};
|
||||
std::shared_ptr<const Texture> texture;
|
||||
};
|
||||
struct Sprite { Vec3 position{}; Vec2 size{1,1}; Color color{1,1,1,1}; float rotation{}; std::shared_ptr<const Texture> texture; };
|
||||
struct Texture { std::uint32_t width{}, height{}; std::vector<std::uint8_t> rgba; std::uint64_t revision{}; bool srgb{false}; };
|
||||
struct Quad { float x{}, y{}, width{}, height{}; Color color{1,1,1,1}; std::shared_ptr<const Texture> texture; std::array<float,4> uv_rect{0,0,1,1}; };
|
||||
struct Text { float x{}, y{}; std::string value; Color color{0.85f,0.87f,0.90f,1}; float size{14}; };
|
||||
struct Sprite {
|
||||
Vec3 position{};
|
||||
Vec2 size{1, 1};
|
||||
Color color{1, 1, 1, 1};
|
||||
float rotation{};
|
||||
std::shared_ptr<const Texture> texture;
|
||||
};
|
||||
struct Texture {
|
||||
std::uint32_t width{}, height{};
|
||||
std::vector<std::uint8_t> rgba;
|
||||
std::uint64_t revision{};
|
||||
bool srgb{false};
|
||||
};
|
||||
struct Quad {
|
||||
float x{}, y{}, width{}, height{};
|
||||
Color color{1, 1, 1, 1};
|
||||
std::shared_ptr<const Texture> texture;
|
||||
std::array<float, 4> uv_rect{0, 0, 1, 1};
|
||||
};
|
||||
struct Text {
|
||||
float x{}, y{};
|
||||
std::string value;
|
||||
Color color{0.85f, 0.87f, 0.90f, 1};
|
||||
float size{14};
|
||||
};
|
||||
struct Snapshot {
|
||||
// Optional scene viewport in drawable pixels (x, y, width, height); zero size uses the full target.
|
||||
std::array<float,4> scene_rect{};
|
||||
// Optional scene viewport in drawable pixels (x, y, width, height); zero size uses the full
|
||||
// target.
|
||||
std::array<float, 4> scene_rect{};
|
||||
Mat4 view_projection{identity};
|
||||
Vec3 eye{4,3,5};
|
||||
Vec3 light_direction{-0.5f,-1,-0.3f};
|
||||
Color clear_color{0.055f,0.065f,0.085f,1};
|
||||
Vec3 eye{4, 3, 5};
|
||||
Vec3 light_direction{-0.5f, -1, -0.3f};
|
||||
Color clear_color{0.055f, 0.065f, 0.085f, 1};
|
||||
std::vector<DrawItem> draws;
|
||||
std::vector<Sprite> sprites;
|
||||
// UI coordinates are drawable pixels, top-left origin. Order is preserved per list.
|
||||
@@ -55,7 +86,20 @@ struct RendererConfig {
|
||||
bool validation{true};
|
||||
};
|
||||
struct Event {
|
||||
enum class Type { Quit, Resize, FocusGained, FocusLost, MouseMove, MouseDown, MouseUp, Wheel, KeyDown, KeyUp, TextInput, TextEditing };
|
||||
enum class Type {
|
||||
Quit,
|
||||
Resize,
|
||||
FocusGained,
|
||||
FocusLost,
|
||||
MouseMove,
|
||||
MouseDown,
|
||||
MouseUp,
|
||||
Wheel,
|
||||
KeyDown,
|
||||
KeyUp,
|
||||
TextInput,
|
||||
TextEditing
|
||||
};
|
||||
Type type{};
|
||||
float x{}, y{};
|
||||
int button{};
|
||||
@@ -71,7 +115,7 @@ struct FrameStats {
|
||||
std::string device;
|
||||
};
|
||||
class Renderer {
|
||||
public:
|
||||
public:
|
||||
explicit Renderer(const RendererConfig& = {});
|
||||
~Renderer();
|
||||
Renderer(Renderer&&) noexcept;
|
||||
@@ -95,8 +139,9 @@ public:
|
||||
void set_text_input_area(float x, float y, float width, float height);
|
||||
void set_clipboard(const std::string&);
|
||||
std::string clipboard() const;
|
||||
private:
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
}
|
||||
} // namespace faset::render
|
||||
|
||||
Reference in New Issue
Block a user