diff options
author | Andrew Marshall <andrew@johnandrewmarshall.com> | 2023-09-27 00:13:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-27 00:13:56 -0400 |
commit | 0c101e7a04f04ee97aa273f59a67284322d6f535 (patch) | |
tree | 2dd30d596e40c6538abe544d83d1dacd7573cf62 /pkgs/applications/misc | |
parent | 9e69bdb431d5e5db29de818323bc0a600166ff64 (diff) |
blender: Add pkg test for rendering (#245613)
Basic headless render test for Eevee and Cycles CPU. Did this because I got a bit tired of testing render manually for both renderers (though it’s not that much work). Note that `render.threads` config is used only by Cycles. Using 1 thread chosen because it’s not meaningfully slower than more for this render, and it simplifies things to just pick 1 instead of making it dynamic. Have chosen 32 samples since it’s not meaningfully slower than 1 (even with `--cores 1`), and it’s not so small that maybe it’s not representative, and too-low a number and there are artifacts that may make it appear like something is broken. Cycles denoising needs openimagedenoise and is not currently included in aarch64 build.
Diffstat (limited to 'pkgs/applications/misc')
-rw-r--r-- | pkgs/applications/misc/blender/default.nix | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index b0dddb974115f..24797b0602c8f 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -15,6 +15,8 @@ , potrace , openxr-loader , embree, gmp, libharu +, mesa +, runCommand }: let @@ -26,7 +28,7 @@ let }; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: rec { pname = "blender"; version = "3.6.3"; @@ -184,7 +186,45 @@ stdenv.mkDerivation rec { done ''; - passthru = { inherit python; }; + passthru = { + inherit python; + + tests = { + render = runCommand "${pname}-test" { } '' + set -euo pipefail + + export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib/dri + export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json + + cat <<'PYTHON' > scene-config.py + import bpy + bpy.context.scene.eevee.taa_render_samples = 32 + bpy.context.scene.cycles.samples = 32 + if ${if stdenv.isAarch64 then "True" else "False"}: + bpy.context.scene.cycles.use_denoising = False + bpy.context.scene.render.resolution_x = 100 + bpy.context.scene.render.resolution_y = 100 + bpy.context.scene.render.threads_mode = 'FIXED' + bpy.context.scene.render.threads = 1 + PYTHON + + mkdir $out + for engine in BLENDER_EEVEE CYCLES; do + echo "Rendering with $engine..." + # Beware that argument order matters + ${finalAttrs.finalPackage}/bin/blender \ + --background \ + -noaudio \ + --factory-startup \ + --python-exit-code 1 \ + --python scene-config.py \ + --engine "$engine" \ + --render-output "$out/$engine" \ + --render-frame 1 + done + ''; + }; + }; meta = with lib; { description = "3D Creation/Animation/Publishing System"; @@ -198,4 +238,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ goibhniu veprbl ]; mainProgram = "blender"; }; -} +}) |