vulkano_tutorial icon indicating copy to clipboard operation
vulkano_tutorial copied to clipboard

Added unused variable to embedded lighting.frag shader in Lesson 7.

Open NEON725 opened this issue 2 years ago • 2 comments

While following the Lesson 7 Tutorial, I encountered a particularly nasty gotcha-moment that relates to the way the GLSL compiler tries to optimize-away unused variables.

In the intermediary stages of the tutorial, the u_normals value in lighting.frag is unused, which results in the following error when attempting to bind attachment buffers to the GraphicsPipeline

DescriptorSetUpdateError(InvalidBinding { binding: 1 })

This error is not present in the final code for that lesson, only in the embedded version in the lesson text.

This error occurs in GLSL version 450 (used in the tutorial series) and 460 (the latest at time of writing), presumed many other versions as well.

Error was only tested with the following versions:

  • Arch Linux 6.1.39-3-lts x86_64
  • amdvlk 2023.Q2.3-1
  • lib32-amdvlk 2023.Q2.3-1
  • xf86-video-amdgpu 23.0.0-1
  • rustc 1.73.0-nightly (a6f8aa5a0 2023-08-11)
  • vulkano 0.33.0
  • vulkano-macros 0.33.0
  • vulkano-shaders 0.33.0

I am not certain that this behavior is specific to a particular installed library on my system.

NEON725 avatar Aug 15 '23 00:08 NEON725

I could theoretically try re-testing this with 0.32.x to see if this is a breaking change in the library, but I left that for now because it would have been onerous. If my understanding of the tech stack is accurate, it's the system drivers performing the compilation anyway. Edited post to include versions for my amdvlk packages.

NEON725 avatar Aug 15 '23 01:08 NEON725

Only just now discovered the following note in Lesson 8:

Side Note: Earlier versions of this tutorial had the ambient shaders taking in the normals buffer as input despite not actually using it. This passed without issue in earlier versions of the Vulkano API, but as of version 0.28.0 only bindings that are actually used will be generated. This leads to an InvalidBinding error. So if you see the same error make sure that you’re actually using all your inputs.

Looks like this is a known issue, and the above text may simply need to be hoisted to Lesson 7.

NEON725 avatar Aug 15 '23 01:08 NEON725

Closing because repository is stale.

NEON725 avatar Aug 08 '24 23:08 NEON725