Skip to content

Commit a7c3c69

Browse files
committed
feat: introduce RGB9E5 converter tool and HDR format support
- Added a new executable `rgb9e5_converter` for converting HDR images to and from RGB9E5 format, enhancing texture processing capabilities. - Implemented unit tests for RGB9E5 format to ensure conversion accuracy and integrity. - Introduced documentation for the RGB9E5 HDR image format, detailing specifications and usage. - Added a new CI workflow for performance benchmarking, integrating enhanced metrics collection and reporting. - Updated CMake configuration to include new tools and tests, improving build structure and maintainability. These changes enhance the engine's support for HDR textures and streamline the benchmarking process, contributing to overall performance and usability improvements.
1 parent 19d3a50 commit a7c3c69

21 files changed

Lines changed: 3437 additions & 464 deletions

.github/workflows/benchmark.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Performance Benchmark
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
benchmark:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.9'
22+
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y cmake ninja-build clang-18 gcc-13 python3-matplotlib python3-seaborn python3-pandas python3-numpy jq
27+
28+
- name: Configure CMake
29+
run: |
30+
mkdir -p build
31+
cd build
32+
cmake .. -G Ninja \
33+
-DCMAKE_C_COMPILER=clang-18 \
34+
-DCMAKE_CXX_COMPILER=clang++-18 \
35+
-DBUILD_BENCHMARKS=ON \
36+
-DBUILD_TESTS=OFF \
37+
-DBUILD_SERVER=OFF \
38+
-DBUILD_RADIANT=OFF
39+
40+
- name: Build benchmarks
41+
run: |
42+
cd build
43+
ninja renderer_bench
44+
45+
- name: Run enhanced benchmarks
46+
run: |
47+
./scripts/ci_benchmark.sh
48+
49+
- name: Upload benchmark results
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: benchmark-results-${{ github.run_number }}
53+
path: |
54+
tests/benchmarks/
55+
bench_reports/
56+
bench_results.json
57+
retention-days: 30
58+
59+
- name: Upload benchmark report
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: benchmark-report-${{ github.run_number }}
63+
path: bench_reports/benchmark_report.html
64+
retention-days: 30
65+
66+
- name: Comment PR with benchmark results
67+
if: github.event_name == 'pull_request'
68+
uses: actions/github-script@v7
69+
with:
70+
script: |
71+
const fs = require('fs');
72+
const path = require('path');
73+
74+
// Read benchmark summary
75+
let summary = {};
76+
try {
77+
const summaryPath = path.join(process.cwd(), 'bench_results.json');
78+
if (fs.existsSync(summaryPath)) {
79+
summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8'));
80+
}
81+
} catch (e) {
82+
console.log('Could not read benchmark results:', e);
83+
}
84+
85+
// Generate comment
86+
let comment = '## 🚀 Performance Benchmark Results\n\n';
87+
88+
if (summary.summary) {
89+
const data = summary.summary;
90+
comment += `**Duration:** ${data.duration_seconds?.toFixed(2) || 'N/A'}s\n`;
91+
comment += `**Peak Memory:** ${data.memory_end_mb?.toFixed(1) || 'N/A'}MB\n\n`;
92+
93+
const operations = ['pathTracer', 'rtx', 'denoiser', 'fsr'];
94+
comment += '| Operation | Avg Time | Min | Max | P95 | Stability |\n';
95+
comment += '|-----------|----------|-----|-----|-----|-----------|\n';
96+
97+
operations.forEach(op => {
98+
if (data[op]) {
99+
const opData = data[op];
100+
const avg = opData.avg_ms?.toFixed(3) || 'N/A';
101+
const min = opData.min_ms?.toFixed(3) || 'N/A';
102+
const max = opData.max_ms?.toFixed(3) || 'N/A';
103+
const p95 = opData.p95_ms?.toFixed(3) || 'N/A';
104+
const stddev = opData.stddev_ms || 0;
105+
const cv = avg !== 'N/A' ? ((stddev / parseFloat(avg)) * 100).toFixed(1) : 'N/A';
106+
const stability = cv !== 'N/A' ? (parseFloat(cv) < 10 ? '🟢' : parseFloat(cv) < 25 ? '🟡' : '🔴') : '❓';
107+
108+
comment += `| ${op} | ${avg}ms | ${min}ms | ${max}ms | ${p95}ms | ${stability} ${cv}% |\n`;
109+
}
110+
});
111+
}
112+
113+
if (summary.regressions && summary.regressions.length > 0) {
114+
comment += '\n### ⚠️ Performance Regressions Detected\n\n';
115+
summary.regressions.forEach(reg => {
116+
comment += `🔴 **${reg.operation}**: +${reg.regression_percent?.toFixed(1) || 'N/A'}% slower\n`;
117+
});
118+
} else {
119+
comment += '\n✅ **No performance regressions detected**\n';
120+
}
121+
122+
comment += '\n📊 [Detailed Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) (download artifacts)\n';
123+
124+
// Post comment
125+
github.rest.issues.createComment({
126+
issue_number: context.issue.number,
127+
owner: context.repo.owner,
128+
repo: context.repo.repo,
129+
body: comment
130+
});
131+
132+
- name: Fail on performance regression
133+
if: github.event_name == 'pull_request'
134+
run: |
135+
if [ -f "bench_results.json" ]; then
136+
if jq -e '.regressions | length > 0' bench_results.json > /dev/null; then
137+
echo "Performance regression detected!"
138+
jq '.regressions' bench_results.json
139+
exit 1
140+
else
141+
echo "No performance regressions detected."
142+
fi
143+
fi

CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4634,6 +4634,28 @@ ADD_EXECUTABLE(test_rtx_switchmode
46344634
ADD_EXECUTABLE(test_wayland_toggle
46354635
src/tests/test_wayland_toggle.cpp
46364636
)
4637+
4638+
# RGB9E5 converter tool for HDR texture processing
4639+
ADD_EXECUTABLE(rgb9e5_converter
4640+
tools/rgb9e5_converter.c
4641+
)
4642+
TARGET_INCLUDE_DIRECTORIES(rgb9e5_converter PRIVATE
4643+
${CMAKE_SOURCE_DIR}/src
4644+
)
4645+
TARGET_LINK_LIBRARIES(rgb9e5_converter PRIVATE m)
4646+
SET_TARGET_PROPERTIES(rgb9e5_converter PROPERTIES
4647+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tools"
4648+
)
4649+
4650+
# RGB9E5 format unit tests
4651+
ADD_EXECUTABLE(test_rgb9e5
4652+
src/tests/test_rgb9e5.c
4653+
)
4654+
target_compile_definitions(test_rgb9e5 PRIVATE UNIT_TEST)
4655+
SET_TARGET_PROPERTIES(test_rgb9e5 PROPERTIES
4656+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
4657+
)
4658+
ADD_TEST(NAME test_rgb9e5 COMMAND test_rgb9e5)
46374659
ADD_EXECUTABLE(test_profiler_integration
46384660
src/tests/test_profiler_integration.c
46394661
src/unix/unix_shared.c

0 commit comments

Comments
 (0)