From 5e26c2315e6ec695a8fcf4662c42c41f55d89618 Mon Sep 17 00:00:00 2001 From: Emil <65846814+emil28092005@users.noreply.github.com> Date: Thu, 24 Sep 2026 02:49:21 +0300 Subject: [PATCH] Record build profile and temporal raster cost in lighting benchmark --- cmake/Renderer.cmake | 2 ++ examples/renderer/p3_lighting_benchmark.cpp | 27 ++++++++++++--------- tests/test_p3_lighting_benchmark.py | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cmake/Renderer.cmake b/cmake/Renderer.cmake index 5b02552..9672f83 100644 --- a/cmake/Renderer.cmake +++ b/cmake/Renderer.cmake @@ -85,6 +85,8 @@ if(BUILD_TESTING) add_executable(faset_p3_lighting_benchmark "${PROJECT_SOURCE_DIR}/examples/renderer/p3_lighting_benchmark.cpp") target_link_libraries(faset_p3_lighting_benchmark PRIVATE faset_render faset_core) + target_compile_definitions(faset_p3_lighting_benchmark PRIVATE + FASET_BENCHMARK_CONFIGURATION="$") add_test(NAME render_lighting_benchmark_schema COMMAND "${Python3_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/tests/test_p3_lighting_benchmark.py") set_tests_properties(render_lighting_benchmark_schema PROPERTIES LABELS "p3" TIMEOUT 90) diff --git a/examples/renderer/p3_lighting_benchmark.cpp b/examples/renderer/p3_lighting_benchmark.cpp index 756da04..13c93c6 100644 --- a/examples/renderer/p3_lighting_benchmark.cpp +++ b/examples/renderer/p3_lighting_benchmark.cpp @@ -62,8 +62,8 @@ Options parse(int argc, char** argv) { else if (name == "--run-index") options.run_index = number(value, name); else if (name == "--commit") options.commit = value; else if (name == "--driver") options.driver = value; - else if (name == "--csv") options.csv = value; - else if (name == "--capture") options.capture = value; + else if (name == "--csv") options.csv = faset::path_from_utf8(value); + else if (name == "--capture") options.capture = faset::path_from_utf8(value); else if (name == "--shadows") { if (value != "on" && value != "off") throw std::invalid_argument("--shadows must be on or off"); @@ -165,14 +165,16 @@ void benchmark(const Options& options) { for (unsigned i = 0; i < options.warmup; ++i) renderer.render(scene); if (!options.csv.parent_path().empty()) - fs::create_directories(options.csv.parent_path()); - std::ofstream csv(options.csv); + fs::create_directories(faset::native_io_path(options.csv.parent_path())); + std::ofstream csv(faset::native_io_path(options.csv)); if (!csv) - throw std::runtime_error("Cannot open benchmark CSV: " + options.csv.string()); - csv << "light_count,shadows,visibility,effective_visibility,lighting_path,run_index,frame," + throw std::runtime_error("Cannot open benchmark CSV: " + faset::path_to_utf8(options.csv)); + csv << "light_count,shadows,visibility,effective_visibility,lighting_path," + "build_configuration,run_index,frame," "device,driver,commit,width,height,validation_enabled,validation_errors," "submitted_local_lights,omitted_local_lights,shadow_tiles,draw_calls,gpu_bytes," - "gpu_main_raster_ms,gpu_shadow_ms,gpu_ms,cpu_ms,readback_cpu_ms\n"; + "gpu_main_raster_ms,gpu_post_raster_ms,gpu_post_visible,visibility_counters_valid," + "gpu_shadow_ms,gpu_ms,cpu_ms,readback_cpu_ms\n"; csv << std::fixed << std::setprecision(6); for (unsigned frame = 0; frame < options.frames; ++frame) { renderer.render(scene); @@ -187,7 +189,8 @@ void benchmark(const Options& options) { throw std::runtime_error("GPU raster or frame timestamp was unavailable"); csv << options.lights << ',' << (options.shadows ? "on" : "off") << ',' << mode_name(options.visibility) << ',' << mode_name(stats.effective_visibility_mode) - << ",forward," << options.run_index << ',' << frame << ','; + << ",forward," << FASET_BENCHMARK_CONFIGURATION << ',' + << options.run_index << ',' << frame << ','; csv_text(csv, stats.device); csv << ','; csv_text(csv, options.driver); @@ -197,13 +200,15 @@ void benchmark(const Options& options) { << (stats.validation_enabled ? 1 : 0) << ',' << stats.validation_errors << ',' << stats.submitted_local_lights << ',' << stats.omitted_local_lights << ",0," << stats.draw_calls << ',' << stats.gpu_allocated_bytes << ',' - << stats.gpu_main_raster_ms << ",0," << stats.gpu_ms << ',' + << stats.gpu_main_raster_ms << ',' << stats.gpu_post_raster_ms << ',' + << stats.gpu_post_visible << ',' << (stats.visibility_counters_valid ? 1 : 0) + << ",0," << stats.gpu_ms << ',' << stats.cpu_ms << ',' << stats.readback_cpu_ms << '\n'; } if (!csv) - throw std::runtime_error("Cannot finish benchmark CSV: " + options.csv.string()); + throw std::runtime_error("Cannot finish benchmark CSV: " + faset::path_to_utf8(options.csv)); if (!options.capture.empty()) - renderer.capture(options.capture); + renderer.capture(faset::native_io_path(options.capture)); } } // namespace diff --git a/tests/test_p3_lighting_benchmark.py b/tests/test_p3_lighting_benchmark.py index 4f7dff4..bdfa443 100644 --- a/tests/test_p3_lighting_benchmark.py +++ b/tests/test_p3_lighting_benchmark.py @@ -204,7 +204,7 @@ def real_executable_smoke(executable: Path) -> None: if declared["lights"] != [0, 4, 16, 32, 64, 128] or len(declared["visibility"]) != 3: raise AssertionError("C++ executable and Python sweep matrix disagree") with tempfile.TemporaryDirectory() as directory: - output = Path(directory) / "smoke.csv" + output = Path(directory) / "café 世界" / "smoke.csv" subprocess.run([executable, "--lights", "4", "--shadows", "off", "--visibility", "direct", "--width", "64", "--height", "64", "--warmup", "0", "--frames", "1", "--validation", "on",