Merge commit 'b191ae0' into feat/p1-p3-integration
Native and manual checks / native (ubuntu-24.04) (push) Failing after 31s
Windows editor and software Vulkan / windows-graphics (push) Canceled after 0s
Native and manual checks / manual (push) Successful in 28s
Native and manual checks / native (windows-2025) (push) Canceled after 0s

This commit is contained in:
Emil
2026-09-24 03:01:51 +03:00
28 changed files with 3042 additions and 121 deletions
+76
View File
@@ -0,0 +1,76 @@
#pragma once
#include <faset/render/visibility.hpp>
#include <cstddef>
#include <cstdint>
#include <span>
#include <string>
#include <vector>
namespace faset::render {
enum class ShadowDropReason { None, Unavailable, TileBudget, CasterBudget };
enum class ShadowRedrawReason { EveryFrame };
struct ShadowBudget {
std::uint32_t max_sun_views{4};
std::uint32_t max_local_faces{16};
std::uint32_t max_caster_draws{4096};
std::uint32_t max_local_lights{128};
std::uint32_t sun_atlas_size{2048};
std::uint32_t local_atlas_size{2048};
float max_shadow_distance{80};
bool sun_atlas_available{true};
bool local_atlas_available{true};
};
struct ShadowCasterBounds {
Bounds world;
std::uint32_t draw_index{}; // Index of the original source LOD-0 DrawItem.
};
struct ShadowView {
enum class Kind { Sun, Spot, Point };
Kind kind{Kind::Sun};
std::string light_id;
std::uint32_t face_index{};
std::uint32_t tile_index{};
std::uint32_t tile_origin_x{}, tile_origin_y{}, tile_size{}, usable_size{};
Mat4 view_projection{identity};
std::array<float, 4> atlas_scale_offset{};
std::array<float, 4> guarded_clamp{};
float split_near{}, split_far{};
float snapped_center_x{}, snapped_center_y{};
std::vector<std::uint32_t> caster_indices;
bool valid{};
ShadowDropReason reason{ShadowDropReason::None};
ShadowRedrawReason redraw_reason{ShadowRedrawReason::EveryFrame};
};
struct LocalShadowAssignment {
std::size_t source_index{};
std::uint32_t first_view{};
std::uint32_t face_count{};
bool valid{};
ShadowDropReason reason{ShadowDropReason::None};
};
struct ShadowPlan {
std::vector<ShadowView> sun_views; // Requested slots, including explicitly invalid ones.
std::vector<ShadowView> local_views; // Only complete, valid spot/point allocations.
std::vector<std::size_t> submitted_local_indices; // Priority/influence/stable-ID order.
std::vector<LocalShadowAssignment> local_assignments;
std::uint32_t requested_sun_cascades{}, effective_sun_cascades{};
std::uint32_t local_faces_requested{}, local_faces_used{};
std::uint32_t dropped_sun_views{}, dropped_local_faces{}, dropped_point_faces{};
std::uint32_t omitted_local_lights{}, caster_draws{};
std::uint32_t sun_atlas_size{}, local_atlas_size{};
};
// Stateless: every scheduled tile is cleared/redrawn; no prior-frame depth or
// ownership is reused. Shadow casters are source LOD-0 world bounds, independent
// of the camera/P2 visibility decision. This function performs no Vulkan work.
ShadowPlan build_shadow_plan(const Snapshot& frame,
std::span<const ShadowCasterBounds> casters,
const ShadowBudget& budget = {});
} // namespace faset::render
+45
View File
@@ -80,6 +80,34 @@ struct Text {
Color color{0.85f, 0.87f, 0.90f, 1};
float size{14};
};
struct SunLight {
std::string stable_id;
Vec3 direction{-0.5f, -1, -0.3f};
Color color{1, 1, 1, 1};
float intensity{1};
bool casts_shadow{true};
};
struct LocalLight {
enum class Kind { Point, Spot };
Kind kind{Kind::Point};
std::string stable_id;
Vec3 position{};
Vec3 direction{0, 0, -1};
Color color{1, 1, 1, 1};
float intensity{1};
float range{10};
float inner_angle{0.35f};
float outer_angle{0.7f};
bool casts_shadow{true};
int shadow_priority{};
};
struct CameraFrustum {
Mat4 view{identity};
Mat4 projection{identity};
float near_plane{0.1f};
float far_plane{1000};
bool perspective{true};
};
struct Snapshot {
// Optional scene viewport in drawable pixels (x, y, width, height); zero size uses the full
// target.
@@ -100,6 +128,12 @@ struct Snapshot {
// Distinguishes temporal histories when one Renderer displays different views.
std::string view_id{};
bool camera_cut{};
// Empty legacy scenes may use the renderer's compatibility sun. Any authored light
// component, including an explicitly disabled or opaque future one, suppresses it.
bool authored_lights_present{};
std::optional<SunLight> sun{};
std::vector<LocalLight> local_lights;
std::optional<CameraFrustum> camera_frustum{};
};
enum class VisibilityMode { Direct, GpuFrustum, GpuOcclusion };
// CPU-only validation used before publishing a game or creating Vulkan pipelines.
@@ -149,6 +183,15 @@ struct FrameStats {
std::uint64_t gpu_allocated_bytes{};
std::uint32_t texture_count{};
std::uint32_t vertices{}, draw_calls{}, culled_meshes{}, validation_errors{};
std::uint32_t submitted_local_lights{}, omitted_local_lights{};
std::uint32_t requested_sun_cascades{}, effective_sun_cascades{};
std::uint32_t sun_shadow_caster_draws{};
std::uint64_t sun_shadow_atlas_bytes{};
std::uint32_t requested_local_shadow_faces{}, local_shadow_faces{}, local_shadow_tiles{};
std::uint32_t dropped_shadow_faces{}, dropped_point_shadow_faces{};
std::uint32_t shadow_atlas_full_drops{}, shadow_caster_budget_drops{};
std::uint32_t shadow_unavailable_drops{}, shadow_caster_draws{};
std::uint64_t local_shadow_atlas_bytes{};
bool gpu_visibility_active{}, hzb_valid{};
// Requested and actual paths for the last frame; actual may be less capable.
VisibilityMode requested_visibility_mode{VisibilityMode::Direct};
@@ -160,6 +203,8 @@ struct FrameStats {
double cpu_ms{}, gpu_ms{}, readback_cpu_ms{};
double gpu_main_cull_ms{}, gpu_main_raster_ms{}, gpu_hzb_ms{};
double gpu_post_cull_ms{}, gpu_post_raster_ms{};
double gpu_sun_shadow_ms{}, gpu_local_shadow_ms{};
std::string effective_lighting_path{"forward"};
std::string device;
};
struct HzbDebugImage {