ExampleShaders compiles outside crafter-build, so it can pass while an example fails to build #174
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#174
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
tests/ExampleShaders(#164) is meant to fail when an example's shader stops compiling the way crafter-build compiles it. It runs whateverglslangexecutable is onPATHwith its own copy of crafter-build's flags. It also finds the shaders by scanning files rather than from the examples' registrations. So it can pass while an example fails to build, and fail where the example builds. Its declaration has two smaller problems on top.Line numbers refer to
6e94cc6.1. Another compiler, other defines
/usr/bin/glslang16.4.0 (the host has 16.6.0), while crafter-build compiles with the glslang it links, built from glslangmain, unpinned.mainalready rejects something neither executable does:layout(constant_id = 1) const uint b = a * 2u;compiles with 16.4.0 and 16.6.0 but fails in crafter-build ("cannot be applied to a constant computed from other specialization constants"). An example shader with that line passesExampleShaderswhile its example fails to build.tests/ExampleShaders/main.cpp:115passes-DCRAFTER_GRAPHICS_DESCRIPTOR_SETS, which glslang defines as empty, while crafter-build emits#define CRAFTER_GRAPHICS_DESCRIPTOR_SETS 1for a define given without a value (Crafter.Build-Shader.cpp:159in Crafter.Build). A shader that tests#if CRAFTER_GRAPHICS_DESCRIPTOR_SETSbuilds in its example and fails here with "preprocessor evaluation: bad expression".2. A file scan instead of the registrations
:89-92compile onlyexamples/<Name>/*.glsl, one level deep, and:107adds the descriptor-set build only when the file's own text mentionsui-shared.glsl. That has three consequences:ui-shared.glslthrough its own header gets no descriptor-set build..glslfails with "no stage known" (:102).The comment's "a new shader is never silently left out" (
:14) does not hold. Today the 16 shaders the examples register are exactly the 16 it finds.3. The declaration
project.cpp:557declares it for every native target,x86_64-w64-mingw32included. There thetool:glslangprobe succeeds on the Linux side, but under Winestd::system("glslang ...")goes through cmd.exe, which cannot run it. All 17 checks fail and the test returnsEXIT_FAILUREinstead of 77.UIFusedShaderandPushConstantRewriteshare the pattern.LibraryTestbuilds a private copy of the whole library for a test that only importsstdand runs glslang. That is 173 MB underbuild/ExampleShaders-*/, rebuilt after every library edit, and the binary links Vulkan, Wayland, xkbcommon and udev. crafter-build's owncfg.AddTest("ExampleShaders").Requires("tool:glslang")buildsmain.cppalone; AGENTS.md would need a note for the exception toLibraryTest.Suggested fix
Have crafter-build compile the shaders. Declare each example's shaders in the test's
config.shadersas the example registers them, with one variant per example so outputs likeraygen.spvdo not collide. That fixes 1 and 2, and leaves the test binary at most checking that the outputs exist. Failing that, move the declaration out of the Windows build (or probe for glslang inside the test and return 77), and declare it withAddTest.Found in a code review of the #163 change.