Skip to content

Fix shader output directory dependency - #557

Open
dbiswas2808 wants to merge 1 commit into
KhronosGroup:mainfrom
dbiswas2808:fix/shader-directory-dependency
Open

dbiswas2808 wants to merge 1 commit into
KhronosGroup:mainfrom
dbiswas2808:fix/shader-directory-dependency

Conversation

@dbiswas2808

Copy link
Copy Markdown

Issue

Building the tutorial from a clean build directory can fail during shader compilation with Unix Makefiles:

/bin/sh: 1: cd: can't cd to .../09_shader_modules/shaders
gmake[2]: *** [CMakeFiles/09_shader_modules_slang_shader.dir/build.make:76: 09_shader_modules/shaders/slang.spv] Error 2

CMake defines separate custom commands for creating the shader output directory and compiling the shaders. However, the shader compilation commands did not depend on the directory-creation output.

During parallel builds, Make could therefore start shader compilation before creating the output directory. Compilation would then fail when attempting to use the missing directory as its working directory.

Fix

Add ${SHADERS_DIR} to the dependencies of both the GLSL and Slang shader compilation commands.

This gives CMake an explicit ordering relationship:

  1. Create the shader output directory.
  2. Compile the shaders inside that directory.

Users can now follow the documented build instructions without manually creating shader directories.

Testing

Verified by configuring the project and successfully building the previously failing target:

cmake -S attachments -B attachments/build
cmake --build attachments/build --target 09_shader_modules --parallel

@CLAassistant

CLAassistant commented Nov 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Using the output directory as a normal prerequisite can trigger unnecessary shader recompilation on subsequent Make builds; both helpers need a distinct stamp file touched after directory creation.

1 open issue
What changed in this PR

This PR addresses clean-build failures in the tutorial by explicitly ordering shader output-directory creation before compilation.

Changes:

  • Adds ${SHADERS_DIR} as a dependency of both GLSL and Slang compilation commands.
  • Ensures parallel Unix Makefiles builds create the working directory before invoking shader compilers.
File Description
attachments/​CMakeLists.txt Adds output-directory dependencies to both shader compilation helpers.

Review effort: Balanced

ARGS --target-env vulkan1.0 ${SHADER_SOURCES} --quiet
WORKING_DIRECTORY ${SHADERS_DIR}
DEPENDS ${SHADER_SOURCES}
DEPENDS ${SHADER_SOURCES} ${SHADERS_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants