19

The API has Validation Layers, which need to be explicitly (and correctly) installed and enabled by the user.

What the Validation Layers do is catch incorrect usage of the Vulkan API (if detectable). (BTW the coverage increases over time, so it may apply to past questions too.)

So, some "why my code does not work" questions turn out to be about Validation Layers being disabled (or not enabled properly). The content of the question practically does not matter, and when the Layers are enabled they clearly state the nature of the bug the person experiences.

I am tempted to flag such questions with the "a problem that can no longer be reproduced or a simple typographical error" flag. What do you think? Otherwise, is there an optimal way to deal with this class of questions? Or maybe it does not need solution (luckily Vulkan tag is low frequency and does not experience problems with question spam or searchability yet)?

Not sure if other tags may have similar problem. It is sort of a reverse-duplicate situation. I.e. we have multiple (unique) questions, but the answer is the same.

Furthermore, oftentimes question does not state Validation Layer status, version, and output if any (which repeatedly forces people to fish for that information). On question page there are hints on the right. What about some feture that would show tag-specific hints there?

6
  • Wouldn't a proper MCVE show VK_LAYER_LUNARG_standard_validation being requested during vkCreateInstance()?
    – genpfault
    Commented May 6, 2019 at 19:30
  • 2
    @genpfault Well, no. It is unreasonable to ask for 800+ LOC example. Therefore we ask for only the relevant parts and assume the "boilerplate"\boring initialization code is sane and healthy. So I guess we are left with MVE. Also: layers can be enabled from environment and not programmatically.
    – krOoze
    Commented May 6, 2019 at 19:42
  • How come this is in meta, and not in ordinary stackoverflow? I thought this was for questions about SO itself. Commented May 7, 2019 at 5:04
  • @Len Easily explained: SO is when you want to ask a a programming question. Meta is when you want to ask about those SO-Questions.
    – Lino
    Commented May 7, 2019 at 12:32
  • @Len This is a moderation discussion. Discussions about how we should moderate content belong on Meta, not on the main Q&A.
    – jpmc26
    Commented May 7, 2019 at 22:37
  • Whoops! My bad. I'd have known that if I'd read past the second paragraph... Commented May 9, 2019 at 0:44

2 Answers 2

41

For the uninitiated, allow me to give an analogy for the situation.

Imagine if compilers never emitted compile errors. At all. You could type whatever garbage you wanted, but they'd always generate an executable/whatever. If you run that program, what you get is undefined behavior; sometimes you'll get what you want, and sometimes you won't.

So someone else comes up with a tool that can wrap the compiled executable. It analyzes the "code" as it executes and gives an error when it encounters invalid code.

That's basically the situation with Vulkan and the SDK's validation layers. Vulkan as a specification defines what valid usage of the API is, but Vulkan implementations do nothing to check to see if you're abiding by those rules. There are validation layers that can be added on top of the Vulkan implementation that will check (most) usage to make sure it's being used correctly.

I don't think having a canonical duplicate is appropriate, for two reasons. There's no guarantee that turning on validation layers will find the problem. The layers are not perfect; they do miss some things. But also because getting an error doesn't mean knowing what that error means. We get questions all the time about compiler errors, and some of them are genuinely good because the error in question is particularly cryptic or otherwise difficult to track down the source of. The same is true of Vulkan validation layer messages.

Now, since the validation layer tool is entirely optional, lots of people don't use it simply out of ignorance. But since this tool exists for the expressed purpose of finding these code problems, and since it is a free tool that comes with every Vulkan SDK installation (so the user has access to it unless they are trying to load function pointers for DLLs/SOs on their own), I think there is a better solution.

Instead, let's change the tag's information text to state that we require users to turn on validation layers for any code debugging questions about Vulkan. And they should specify which validation layers they have turned on.

Failure to provide this information should be considered equivalent to failing to provide an MCVE and thus makes the question subject for closure. We can post comments asking them to tell us what validation layers they are using.

5
  • 4
    I like it except the part about tag info. "vulkan" is simple API tag; people would not expect tricks there. Nobody probably reads that info. Might be hard to train mods to do so; this solution seems non-obvious to me. Though I guess current SO feature-set does not offer a better choice...
    – krOoze
    Commented May 5, 2019 at 16:03
  • 1
    PS: Your compiler analogy inspires me though. Tempts me to make a Vulkan GitHub Issue asking to make Validation Layers on by default (if it was possible due to backwards compatibility; maybe for 2.0 if ever?). It is probably problem of bad defaults...
    – krOoze
    Commented May 5, 2019 at 16:05
  • 11
    But tag wikis are meant to guide askers with their question. It is the perfect spot to collect that info and yet another opportunity to give tag wikis more exposure @krOoze. Just use some canned auto-comments.
    – rene
    Commented May 5, 2019 at 16:17
  • 2
    @rene Hm, I guess. Not sure I like autocomments; always feels like fu someone. So: "Your question about debugging help does not contain Validation Layers status. See [vulkan tag link] for question rules. To enable Validation Layers see [canonical Q&A]." + mark as non-MCVE. Any further suggestions?
    – krOoze
    Commented May 5, 2019 at 16:32
  • 2
    "We can help you better if you include which validation layers you have enabled and what their status is. If you need help finding or enabling those, see [tag-wiki]. Ping me if you have edit-ed your question". It might be a matter of wording @krOoze but if you have the time to customize, no one will oppose to that.
    – rene
    Commented May 5, 2019 at 16:58
9

Why not ask and self answer a canonical question about installing and enabling validation layers. You could then use that as a duplicate target assuming there isn't one already.

For instance there are an infinite number of ways to get a Java Null Pointer Exception but if you have such a problem and ask a question about it you'll probably end up being duplicated to this canonical question

6
  • 1
    Perhaps. Should I though mark question like "Why my X crashes in Y?" to "How do I enable validation layers?" as a duplicate. Feels unclean to me. Furthermore there are 100000 ways to violate the API and therefore potentially 100000 unique Questions that lead to Answer of Layers not being enabled, which would catch the bug for the person. Do these questions need to exist at all?
    – krOoze
    Commented May 5, 2019 at 14:29
  • Added note about this in the Q. The questions themselves are not really a duplicate. What is (potentially) a duplicate is the answer. Should that still be flagged a duplicate? I.e. what the problem is is that other user that legitimely experiences "crash" in his code even with layers on is then routed (e.g. via inet search) to answer about enabling layers, which does not help him specifically (because he already has them enabled).
    – krOoze
    Commented May 5, 2019 at 14:43
  • 7
    @krOoze: "Feels unclean to me." That's basically what we do with every "unresolved external" compilation question. We have a single canonical question to which literally thousands of questions have been marked as duplicates. They may all be talking about different functions with different libraries and so on, but the resolution is always the same: you're not linking correctly. Commented May 5, 2019 at 15:30
  • 3
    @NicolBolas Yea, but as you say in your answer-comment. Unresolved external symbol questions are the same; they only differ in the symbol name. The text of such Q would be almost same. They all get the same error code in compiler, and 90 % same error text. Questions caused by violation of the Vulkan API contract are very different and unique. Results in various non-specific behavior. And the Qs are undistinguishable from actual questions of good pupies that do have layers enabled(, except you later find out they were not using layers which would mark the error).
    – krOoze
    Commented May 5, 2019 at 16:11
  • 2
    PS: marking this duplicate of canonical feels to me like if in C++ I marked all questions about compiler and runtime errors to canonical about proper debugging techniques and programmer coding discipline.
    – krOoze
    Commented May 5, 2019 at 16:22
  • 5
    It doesn't have to be a cannonical dupe. People can Simply link it in comment as related to make sure Op has everything properly set before asking for more information. And if it solve the issue then mark it dupe. Give people the Tools, the Community will then decide how to use it. Commented May 6, 2019 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .