chg: set fixed rnd seed for captures

main
Dominik Madarász 2024-04-17 11:47:15 +02:00
parent f13e6dc4ac
commit b5fd58d69b
76 changed files with 60 additions and 25 deletions

View File

@ -685,7 +685,7 @@ if "%1"=="addons[" (
if "%1"=="hello" set "hello=yes" && goto loop
if "%1"=="editor" set "editor=yes" && set "v4k=yes" && set "hello=no"&& goto loop
if "%1"=="run" set "run=yes" && goto loop
if "%1"=="all" set "v4k=yes" && set "demos=yes" && set "lab=yes" && set "editor=yes" && set "hello=yes" && goto loop
if "%1"=="all" set "v4k=yes" && set "demos=yes" && set "lab=yes" && set "hello=yes" && goto loop
if "%1"=="tcc" set "cc=%1" && goto loop
if "%1"=="cl" set "cc=%1" && goto loop

View File

@ -1,12 +1,13 @@
@echo off
set WORKDIR=%~dp0
cd /d "%~dp0\."
call make cook
mkdir %WORKDIR%\tests > nul 2> nul
mkdir %WORKDIR%\tests\out > nul 2> nul
mkdir %WORKDIR%\tests\ref > nul 2> nul
mkdir %WORKDIR%\tests\diff > nul 2> nul
mkdir tests > nul 2> nul
mkdir tests\out > nul 2> nul
mkdir tests\ref > nul 2> nul
mkdir tests\diff > nul 2> nul
where gm > nul 2> nul
if errorlevel 1 (
@ -16,16 +17,19 @@ if errorlevel 1 (
)
for %%x in (*.exe) do (
echo Running %%x...
@REM echo Running %%x...
start /wait "" "%%x" --nocook --capture=50
if not exist %WORKDIR%\tests\ref\%%~nx.exe.png (
echo Reference image not found. Copying %%~nx.exe.png ...
copy %WORKDIR%\tests\out\%%~nx.exe.png %WORKDIR%\tests\ref\%%~nx.exe.png
if not exist "tests\ref\%%~nx.png" (
echo [pass] reference image not found. Copying %%~nx.png ...
copy "tests\out\%%~nx.png" "tests\ref\%%~nx.png"
) else (
call gm compare -metric MSE -maximum-error 0.02 %WORKDIR%\tests\ref\%%~nx.exe.png %WORKDIR%\tests\out\%%~nx.exe.png -file %WORKDIR%\tests\diff\%%~nx.exe.png > nul 2> nul
call gm compare -metric MSE -maximum-error 0.005 "tests\ref\%%~nx.png" "tests\out\%%~nx.png" -file "tests\diff\%%~nx.png"
if errorlevel 1 (
echo Images differ too much. Check %WORKDIR%\tests\diff\%%~nx.exe.png
echo [fail] %%~nx.exe! Check "tests\diff\%%~nx.png"
) else (
echo [pass] %%~nx.exe
del "tests\diff\%%~nx.png"
)
)
)

View File

@ -38,8 +38,8 @@ int main() {
// load model
model_t m1 = model("suzanne.obj", MODEL_NO_ANIMATIONS);
model_t m2 = model("suzanne.obj", MODEL_NO_ANIMATIONS|MODEL_MATCAPS);
// model_t m3 = model("damagedhelmet.gltf", MODEL_NO_ANIMATIONS|MODEL_PBR);
model_t m3 = model("Scutum_low.fbx", MODEL_NO_ANIMATIONS|MODEL_PBR);
model_t m3 = model("damagedhelmet.gltf", MODEL_NO_ANIMATIONS|MODEL_PBR);
// model_t m3 = model("Scutum_low.fbx", MODEL_NO_ANIMATIONS|MODEL_PBR);
model_t m4 = model("cube.obj", MODEL_NO_ANIMATIONS);
// model_t m4 = model("avp/scene.gltf", MODEL_NO_ANIMATIONS|MODEL_PBR);
// model_t m3 = model("Cerberus_LP.FBX", MODEL_NO_ANIMATIONS|MODEL_PBR);
@ -83,9 +83,10 @@ int main() {
object_model(obj4, m3);
object_scale(obj4, vec3(3,3,3));
object_move(obj4, vec3(-10+6*3,0,-10));
object_pivot(obj4, vec3(0,0,90));
// object_pivot(obj4, vec3(0,0,90));
object_pivot(obj4, vec3(0,90,0));
// spawn object5 (pbr)
// spawn object5 (shadertoy)
object_t* obj5 = scene_spawn();
object_model(obj5, m4);
object_diffuse(obj5, sh.tx);

View File

@ -392983,10 +392983,15 @@ int window_swap() {
}
static uint64_t capture_frame = 0;
if (cook_done && optioni("--capture", 0) && capture_frame++ == optioni("--capture", 0)) {
void *rgb = screenshot(3);
static uint64_t capture_target; do_once capture_target = optioni("--capture", 0);
if( cook_done && ++capture_frame == capture_target ) {
mkdir( "tests/out", 0777 );
const char *screenshot_file = va("tests/out/%s.png", app_name());
int n = 3;
void *rgb = screenshot(n);
stbi_flip_vertically_on_write(true);
if(!stbi_write_png(va("tests/out/%s.png", argv(0)), w, h, 3, rgb, 3 * w) ) {
if(!stbi_write_png(screenshot_file, w, h, n, rgb, n * w) ) {
PANIC("!could not write screenshot file `%s`\n", screenshot_file);
}
return 0;
@ -395721,6 +395726,11 @@ static void v4k_post_init(float refresh_rate) {
// preload brdf LUT early
(void)brdf_lut();
static uint64_t capture_target; do_once capture_target = optioni("--capture", 0);
if (capture_target) {
randset(capture_target);
}
}
// ----------------------------------------------------------------------------

View File

@ -51,6 +51,11 @@ static void v4k_post_init(float refresh_rate) {
// preload brdf LUT early
(void)brdf_lut();
static uint64_t capture_target; do_once capture_target = optioni("--capture", 0);
if (capture_target) {
randset(capture_target);
}
}
// ----------------------------------------------------------------------------

View File

@ -660,10 +660,15 @@ int window_swap() {
}
static uint64_t capture_frame = 0;
if (cook_done && optioni("--capture", 0) && capture_frame++ == optioni("--capture", 0)) {
void *rgb = screenshot(3);
static uint64_t capture_target; do_once capture_target = optioni("--capture", 0);
if( cook_done && ++capture_frame == capture_target ) {
mkdir( "tests/out", 0777 );
const char *screenshot_file = va("tests/out/%s.png", app_name());
int n = 3;
void *rgb = screenshot(n);
stbi_flip_vertically_on_write(true);
if(!stbi_write_png(va("tests/out/%s.png", argv(0)), w, h, 3, rgb, 3 * w) ) {
if(!stbi_write_png(screenshot_file, w, h, n, rgb, n * w) ) {
PANIC("!could not write screenshot file `%s`\n", screenshot_file);
}
return 0;

View File

@ -27523,10 +27523,15 @@ int window_swap() {
}
static uint64_t capture_frame = 0;
if (cook_done && optioni("--capture", 0) && capture_frame++ == optioni("--capture", 0)) {
void *rgb = screenshot(3);
static uint64_t capture_target; do_once capture_target = optioni("--capture", 0);
if( cook_done && ++capture_frame == capture_target ) {
mkdir( "tests/out", 0777 );
const char *screenshot_file = va("tests/out/%s.png", app_name());
int n = 3;
void *rgb = screenshot(n);
stbi_flip_vertically_on_write(true);
if(!stbi_write_png(va("tests/out/%s.png", argv(0)), w, h, 3, rgb, 3 * w) ) {
if(!stbi_write_png(screenshot_file, w, h, n, rgb, n * w) ) {
PANIC("!could not write screenshot file `%s`\n", screenshot_file);
}
return 0;
@ -30261,6 +30266,11 @@ static void v4k_post_init(float refresh_rate) {
// preload brdf LUT early
(void)brdf_lut();
static uint64_t capture_target; do_once capture_target = optioni("--capture", 0);
if (capture_target) {
randset(capture_target);
}
}
// ----------------------------------------------------------------------------

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View File

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

Before

Width:  |  Height:  |  Size: 326 KiB

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 KiB

BIN
tests/ref/01-ui.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 1017 KiB

After

Width:  |  Height:  |  Size: 1017 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 KiB

BIN
tests/ref/hello.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 KiB