Skip to content

Make vertex-shader-missing-sv-position pedantic and off by default#11893

Open
expipiplus1 wants to merge 14 commits into
shader-slang:masterfrom
expipiplus1:push-zykknlllqkkv
Open

Make vertex-shader-missing-sv-position pedantic and off by default#11893
expipiplus1 wants to merge 14 commits into
shader-slang:masterfrom
expipiplus1:push-zykknlllqkkv

Conversation

@expipiplus1

Copy link
Copy Markdown
Collaborator

Fixes #11884. Stacked on #11812 — review/merge that first; the diff here will show #11812's commits until it lands.

Motivation

E38052 (vertex-shader-missing-sv-position) warns whenever a vertex shader has outputs but none carry SV_Position. That is a false positive whenever the vertex shader legitimately omits the position because its output feeds a geometry/tessellation/mesh stage that supplies it — which the compiler cannot distinguish from a real missing-position bug at VS-compile time. The reporter hit it on a GS_INPUT MainVs(...) vertex shader feeding a geometry shader.

Proposed solution

Use the warning-group mechanism added in #11812:

  • Flip the default enabled groups so extra is on by default and pedantic is off by default (clang/gcc-style, independent groups). Add diagnostic warning levels (-Wall/-Wextra/-Wpedantic) #11812 shipped pedantic on-by-default only as a staging step; this is the promised follow-up that turns it off.
  • Tag vertex-shader-missing-sv-position (E38052) as pedantic. It now fires only under -Wpedantic (or -Wvertex-shader-missing-sv-position), so the default build is quiet.
  • Reclassify keyword-used-as-name (E20103) from pedantic to extra so it keeps firing by default (it still points at a real, if benign, footgun). This makes E38052 the canonical pedantic example — a warning that genuinely should be off by default.
  • Drop the stale -warnings-disable 38052 suggestion from the E38052 message; the warning is opt-in now.

Change summary

File Change
source/compiler-core/slang-diagnostic-sink.h Default enabled-groups bitmask: Extra on, Pedantic off.
source/slang/slang-diagnostics.lua Tag E38052 pedantic (and reword its message); retag E20103 extra; bind the extra sentinel.
tests/diagnostics/warning-levels.slang Rewrote to test the extra group (E20103): on by default, unaffected by -Wall/-Wpedantic, suppressible by -Wno.
tests/diagnostics/vertex-missing-sv-position.slang Now the pedantic regression test: off by default, on under -Wpedantic or per-id -W<name>, re-suppressed by -Wno.
docs/user-guide/08-compiling.md Update the WarningLevel note for the new defaults.

Process report

Positive and negative cases are covered by exhaustive diag buffers: a buffer with annotations asserts the warning IS emitted (and nothing else is), and a buffer with no annotations asserts NOTHING is emitted. E38052: diag=OFF with no flags (silent), diag=ON under -Wpedantic and under -Wvertex-shader-missing-sv-position, diag=OFF under -Wpedantic -Wno-.... E20103: diag=WARN by default / -Wextra / -Wall / -Wpedantic (independent groups leave it on), diag=OFF under -Wno-....

The change sits at the right layer: the diagnostic itself is correct (a VS with no SV_Position may indeed drop positions), it is only its default visibility that was wrong for the VS→GS case, which is exactly what the warning-group gating controls.

Add clang/gcc-style warning groups to the diagnostic system. Each group is
enabled independently: a warning tagged with a group is emitted only when that
group is enabled, while untagged warnings stay in the always-on default group.

Warnings are tagged in slang-diagnostics.lua by passing an `all`/`extra`/
`pedantic` sentinel positionally to warning(); the level rides on DiagnosticInfo
and is gated in DiagnosticSink::getEffectiveMessageSeverity. Explicit per-id
overrides (-W<name>/-Wno-<name>) still take precedence over group gating.

Exposed via the -Wall/-Wextra/-Wpedantic CLI flags and the WarningLevel compiler
API option (SlangWarningLevel). As an example, implicit-conversion-to-double
(E30082), a purely advisory performance hint, is moved to the pedantic group.

Fixes shader-slang#11012.
… default

Switch the example pedantic warning from implicit-conversion-to-double to
keyword-used-as-name (E20103): using a type keyword as a name is legal and
usually works, so it is a style/portability hint rather than a likely bug.

Enable the pedantic group by default for now so this grouping does not change
any current output; a follow-up will flip pedantic to off-by-default and assign
groups to the rest of the catalog.
…s/docs

- Bounds-check the bit shift in enableWarningLevel/isWarningLevelEnabled and
  validate the WarningLevel int at the applySettingsToDiagnosticSink boundary, so
  a bogus value cast in through the public option cannot cause an out-of-range
  shift (undefined behavior).
- Add CompilerOptionName::WarningLevel to allowDuplicate() so -Wall/-Wextra/
  -Wpedantic accumulate instead of collapsing to one stored group.
- Drop the unused all/extra Lua aliases (keep pedantic).
- Document WarningLevel and the -Wall/-Wextra/-Wpedantic flags in the user guide.
- Add a DiagnosticSink unit test covering off-by-default group gating, per-id
  override precedence, the warnings-as-errors interaction, and out-of-range
  safety; exercise -Wall/-Wextra in the end-to-end test.
- Note in the user guide that the pedantic group is enabled by default today
  (so -Wpedantic is currently a no-op), pending the follow-up that makes it opt-in.
- Use a direct include path (compiler-core/slang-diagnostic-sink.h) in the new
  unit test instead of relative traversal.
The parent-sink constructor forwarded flags/color/unicode but not the enabled
warning-group bitmask, so a child sink lost the group configuration. Add
get/setEnabledWarningLevels (mirroring getFlags/setFlags) and copy it too.
Exercises the additive allowDuplicate handling and the exact-match-wins
disambiguation against the -W<id> prefix in a single slangc run.
The check-cmdline-ref CI step compares docs/command-line-slangc-reference.md
against `slangc -help-style markdown -h`; the new warning-level flags need the
generated reference updated.
Fixes shader-slang#11884.

E38052 fires on any vertex shader whose output lacks SV_Position, but a
vertex shader may legitimately omit it when its output feeds a
geometry/tessellation/mesh stage rather than the rasterizer, which the
compiler cannot tell apart at VS-compile time. Move it into the pedantic
warning group and flip the group defaults so pedantic is off by default
(opt in with -Wpedantic) and extra is on by default. Reclassify
keyword-used-as-name (E20103) from pedantic to extra so it keeps firing
by default.

Builds on shader-slang#11812.
@expipiplus1 expipiplus1 requested a review from a team as a code owner July 2, 2026 01:38
@expipiplus1 expipiplus1 requested review from bmillsNV and Copilot and removed request for a team July 2, 2026 01:38
@expipiplus1 expipiplus1 added the pr: non-breaking PRs without breaking changes label Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1395c74-5f3a-4e89-933e-dc574b8ccb03

📥 Commits

Reviewing files that changed from the base of the PR and between 6fdcdcb and 66d1302.

⛔ Files ignored due to path filters (1)
  • docs/generated/tests/design/cross-cutting/diagnostics-catalog/38052-vertex-shader-missing-sv-position.slang is excluded by !**/generated/**
📒 Files selected for processing (2)
  • source/slang/slang-diagnostics.lua
  • tests/diagnostics/vertex-missing-sv-position.slang

📝 Walkthrough

Walkthrough

Adds opt-in warning groups for diagnostics, with public warning-level types and compiler options, sink-side gating and override handling, CLI/Lua wiring, updated diagnostic metadata, and coverage/docs for the new warning flags.

Changes

Opt-in warning group system

Layer / File(s) Summary
Public warning-level contracts
include/slang.h
Adds SlangWarningLevel and CompilerOptionName::WarningLevel = 155.
DiagnosticSink warning-group gating
source/compiler-core/slang-diagnostic-sink.h, source/compiler-core/slang-diagnostic-sink.cpp
Adds warning-level state to diagnostics, bitmask-based enable/query APIs, parent copying, default Extra enablement, and severity/override handling that respects warning groups.
Compiler option parsing and sink application
source/slang/slang-compiler-options.cpp, source/slang/slang-options.cpp
Allows repeated WarningLevel options, parses -Wall/-Wextra/-Wpedantic, and enables the corresponding groups on the sink.
Diagnostic Lua grouping and generated rich diagnostics
source/slang/slang-diagnostics-helpers.lua, source/slang/slang-diagnostics.lua, source/slang/slang-rich-diagnostics.cpp, source/slang/slang-rich-diagnostics.h.lua
Adds warning-group sentinels, tags diagnostics with levels, and extends rich-diagnostic generation with warning-level mapping.
Tests and documentation
tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp, tests/diagnostics/*, docs/command-line-slangc-reference.md, docs/user-guide/08-compiling.md
Adds unit and regression tests for warning-group behavior and documents the new CLI flags and compiler option.

Suggested reviewers: bmillsNV

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: making vertex-shader-missing-sv-position pedantic and off by default.
Description check ✅ Passed The description is directly related to the changeset and explains the motivation, approach, and affected files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adjusts Slang’s diagnostic warning-group defaults to be clang/gcc-like (independent -Wall/-Wextra/-Wpedantic, with extra enabled and pedantic disabled by default) and reclassifies selected warnings so noisy/false-positive diagnostics become opt-in.

Changes:

  • Flip default enabled warning groups so extra is on by default and pedantic is off by default, while preserving per-id override precedence.
  • Retag diagnostics: move vertex-shader-missing-sv-position (E38052) to pedantic, and keyword-used-as-name (E20103) to extra; update the E38052 message to remove stale suppression advice.
  • Update tests and docs to reflect the new warning-group behavior and flags.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp Adds unit tests for DiagnosticSink warning-level gating and override interactions (needs updates to match new defaults).
tests/diagnostics/warning-levels.slang End-to-end test for the extra warning group behavior via E20103.
tests/diagnostics/vertex-missing-sv-position.slang Updates regression coverage so E38052 is off by default and enabled via -Wpedantic / per-id -W....
source/slang/slang-rich-diagnostics.h.lua Adds mapping from Lua warning-level strings to C++ WarningLevel enum values.
source/slang/slang-rich-diagnostics.cpp Emits DiagnosticInfo entries including the new level field.
source/slang/slang-options.cpp Registers and parses -Wall/-Wextra/-Wpedantic as additive warning-group enables.
source/slang/slang-diagnostics.lua Binds warning-level sentinels and retags E20103/E38052 with updated messaging/comments.
source/slang/slang-diagnostics-helpers.lua Introduces and plumbs all/extra/pedantic sentinels through diagnostic processing.
source/slang/slang-compiler-options.cpp Applies the repeatable WarningLevel compiler option to the sink with validation.
source/compiler-core/slang-diagnostic-sink.h Defines WarningLevel, adds the DiagnosticInfo::level field, and implements group enable/query with default extra enabled.
source/compiler-core/slang-diagnostic-sink.cpp Implements warning-group gating in getEffectiveMessageSeverity and preserves meaningful per-id enables for grouped warnings.
include/slang.h Adds public SlangWarningLevel and exposes CompilerOptionName::WarningLevel.
docs/user-guide/08-compiling.md Documents the new WarningLevel compiler option and the default group behavior.
docs/command-line-slangc-reference.md Adds CLI reference entries for -Wall/-Wextra/-Wpedantic.

Comment thread tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp Outdated
Comment thread tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp Outdated
Comment thread tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp
Comment thread tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp Outdated
Comment thread source/compiler-core/slang-diagnostic-sink.h
Comment thread tests/diagnostics/warning-levels.slang Outdated
github-actions[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b5259967-454e-44d3-828a-43ddefe474f0

📥 Commits

Reviewing files that changed from the base of the PR and between 16a1114 and 97684a4.

📒 Files selected for processing (14)
  • docs/command-line-slangc-reference.md
  • docs/user-guide/08-compiling.md
  • include/slang.h
  • source/compiler-core/slang-diagnostic-sink.cpp
  • source/compiler-core/slang-diagnostic-sink.h
  • source/slang/slang-compiler-options.cpp
  • source/slang/slang-diagnostics-helpers.lua
  • source/slang/slang-diagnostics.lua
  • source/slang/slang-options.cpp
  • source/slang/slang-rich-diagnostics.cpp
  • source/slang/slang-rich-diagnostics.h.lua
  • tests/diagnostics/vertex-missing-sv-position.slang
  • tests/diagnostics/warning-levels.slang
  • tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp

Comment thread source/compiler-core/slang-diagnostic-sink.h
Comment thread source/slang/slang-diagnostics-helpers.lua
Update unit-test-diagnostic-warning-level.cpp for the new group defaults
(Extra on, Pedantic/All off): default-gating, additive-enable and
per-id-override tests now use off-by-default groups where they need one
and an on-by-default group (Extra) to show -Wno winning over an enabled
group. Refresh the DiagnosticInfo::level doc and fix a stale test-file
reference.
github-actions[bot]

This comment was marked as outdated.

Add negative cases pinning the independent-groups invariant: the pedantic
vertex-shader-missing-sv-position warning must stay silent when only the
other groups (-Wall/-Wextra) are enabled.
github-actions[bot]

This comment was marked as outdated.

Document the fourth SlangWarningLevel enumerator (DEFAULT) as the
always-on group that is a no-op for the WarningLevel option.
github-actions[bot]

This comment was marked as outdated.

The auto-generated 38052 catalog regression compiled a VS without
SV_Position and asserted W38052 with no flags; since E38052 is now a
pedantic (off-by-default) warning, add -Wpedantic so the nightly catalog
test keeps firing it.
github-actions[bot]

This comment was marked as outdated.

Keep only the functional -Wpedantic addition in the generated catalog
regression; drop the hand-written prose so a future regeneration has
less to reconcile.
github-actions[bot]

This comment was marked as outdated.

Add a comma after "if it feeds the rasterizer directly" so the message
no longer runs "directly the rasterizer" together; update the two test
annotations that quote the secondary span.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: 🟡 Has issues — 4 gap(s)

Retags E38052 (vertex-shader-missing-sv-position) as pedantic (off by default) and E20103 (keyword-used-as-name) as extra (on by default), flipping the default enabled-groups bitmask so Pedantic requires opt-in via -Wpedantic. Findings are two hand-edits to auto-generated files and two coverage gaps for the added public API / child-sink propagation paths.

Changes Overview

Warning-group infrastructure (include/slang.h, source/compiler-core/slang-diagnostic-sink.{h,cpp}, source/slang/slang-compiler-options.cpp, source/slang/slang-options.cpp)

  • Adds SlangWarningLevel enum and CompilerOptionName::WarningLevel = 155 to the public API, and a WarningLevel field on DiagnosticInfo with a Default default so aggregate-initialized diagnostics still compile.
  • DiagnosticSink gains a uint32_t m_enabledWarningLevels bitmask (initialized with Extra on, Pedantic/All off), enable/is-enabled/get/set accessors with a bit < 32 guard against shift UB, gating in getEffectiveMessageSeverity after per-id overrides, and parent-copy propagation in the child constructor.
  • overrideDiagnosticSeverity no longer removes a severity==overrideSeverity override when the diagnostic's group is not Default, so -W<name> on a grouped warning force-enables it.
  • CLI adds -Wall/-Wextra/-Wpedantic under OptionKind::WarningLevel; applySettingsToDiagnosticSink filters intValue at the API boundary.

Diagnostic retagging (source/slang/slang-diagnostics.lua, source/slang/slang-diagnostics-helpers.lua, source/slang/slang-rich-diagnostics.{cpp,h.lua})

  • Adds all/extra/pedantic positional sentinels to the Lua diagnostic DSL; add_diagnostic records diag.level and process_diagnostics propagates it; getWarningLevelEnum maps to WarningLevel::*.
  • E38052 gets pedantic tag and its message drops the stale -warnings-disable 38052 suffix; E20103 gets extra tag.

Tests (tests/diagnostics/vertex-missing-sv-position.slang, tests/diagnostics/warning-levels.slang, tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp)

  • E38052 test rewritten to cover off-by-default, -Wall/-Wextra non-effect, -Wpedantic, per-id -Wno-, and per-id -W<name> cases.
  • New warning-levels.slang covers the extra group via E20103 (default/-Wextra/-Wall/-Wpedantic/-Wno-).
  • Unit tests cover default gating, additive enable, per-id override precedence, warnings-as-errors interaction, and out-of-range enum safety.

Docs (include/slang.h, docs/user-guide/08-compiling.md, docs/command-line-slangc-reference.md, docs/generated/tests/design/cross-cutting/diagnostics-catalog/38052-vertex-shader-missing-sv-position.slang)

  • New WarningLevel row in the CompilerOptionValue table; new -Wall,-Wextra,-Wpedantic section in the CLI reference; the generated catalog test for E38052 adds -Wpedantic to its directive.
Findings (4 total)
Severity Location Finding
🟡 Gap docs/generated/tests/.../38052-vertex-shader-missing-sv-position.slang:16 Hand-edit to a file whose header says "Do not edit by hand"; regenerate via docs/generated/tests/_meta/regenerate.py.
🟡 Gap docs/command-line-slangc-reference.md:261-268 Hand-edit to a file generated by slangc -help-style markdown -h; regenerate after the CLI option is registered.
🟡 Gap source/slang/slang-compiler-options.cpp:434-449 No test exercises the public CompilerOptionName::WarningLevel path through applySettingsToDiagnosticSink.
🟡 Gap source/compiler-core/slang-diagnostic-sink.h:425 No test covers propagation of m_enabledWarningLevels to child sinks.

Comment thread docs/command-line-slangc-reference.md
Comment thread source/slang/slang-compiler-options.cpp
Comment thread source/compiler-core/slang-diagnostic-sink.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid warning when a VS doesn't write SV_Position because the geometry shader is going to do so

2 participants