Skip to content

fix: X4500 overlapping registers for FACEGEN + TRUE_PBR - #2030

Merged
alandtse merged 3 commits into
devfrom
copilot/fix-shader-define-errors
Mar 30, 2026
Merged

fix: X4500 overlapping registers for FACEGEN + TRUE_PBR#2030
alandtse merged 3 commits into
devfrom
copilot/fix-shader-define-errors

Conversation

Copilot AI commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

When FACEGEN and TRUE_PBR are both defined, the HLSL compiler throws error X4500: overlapping register semantics because both feature blocks unconditionally claim registers s4/t4FACEGEN for detail sampler/texture, TRUE_PBR for parallax sampler/texture.

Changes

  • Register declarations (s4/t4): Guard SampParallaxSampler/TexParallaxSampler with !defined(FACEGEN). Split the TRUE_PBR block so SampRMAOSSampler/TexRMAOSSampler (s5/t5) remain declared for FACEGEN+TRUE_PBR — those registers are free when FACEGEN is active (the ENVMAP block already has the same !defined(FACEGEN) guard).
// Before — both claim s4/t4 when FACEGEN+TRUE_PBR:
#        if defined(TRUE_PBR)
SamplerState SampParallaxSampler : register(s4);
SamplerState SampRMAOSSampler    : register(s5);
#        endif

// After — parallax guarded, RMAOS kept for FACEGEN+TRUE_PBR:
#        if defined(TRUE_PBR) && !defined(FACEGEN)
SamplerState SampParallaxSampler : register(s4);
#        endif
#        if defined(TRUE_PBR)
SamplerState SampRMAOSSampler    : register(s5);
#        endif
  • Parallax displacement block (EMAT/TRUE_PBR section): Wrap the HasDisplacement parallax path with #if !defined(FACEGEN) — face geometry doesn't use parallax displacement, and TexParallaxSampler/SampParallaxSampler are undeclared for this combination. PBRParallax stays declared (remains false) so downstream code compiles correctly.

  • Shadow multiplier blocks (directional + point light): Add !defined(FACEGEN) to the #elif defined(TRUE_PBR) && !defined(LODLANDSCAPE) branches that pass TexParallaxSampler/SampParallaxSampler to GetParallaxSoftShadowMultiplier — those resources are not declared for FACEGEN+TRUE_PBR.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI linked an issue Mar 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix shader define compilation errors for pixel shader Fix X4500 overlapping register semantics for FACEGEN + TRUE_PBR shader combination Mar 29, 2026
Copilot AI requested a review from alandtse March 29, 2026 19:09
@alandtse alandtse changed the title Fix X4500 overlapping register semantics for FACEGEN + TRUE_PBR shader combination fix: X4500 overlapping registers for FACEGEN + TRUE_PBR Mar 29, 2026
@github-actions

github-actions Bot commented Mar 29, 2026

Copy link
Copy Markdown

Actionable Suggestions

  • Weather Editor (Dlizzio): Needs version bump to 1-2-0

@alandtse
alandtse marked this pull request as ready for review March 29, 2026 20:03
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions

Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse 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.

@copilot please review comments critically and address or explain why not.

# if defined(TRUE_PBR) && !defined(FACEGEN)
SamplerState SampParallaxSampler : register(s4);
# endif
# if defined(TRUE_PBR)

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.

@copilot shouldn't this be an elseif?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No — using #elif here would be incorrect. When TRUE_PBR && !FACEGEN, we need both SampParallaxSampler and SampRMAOSSampler declared. If the second block were #elif defined(TRUE_PBR) instead of a fresh #if, SampRMAOSSampler would only be declared in the TRUE_PBR + FACEGEN case, not in the normal TRUE_PBR (non-FACEGEN) case — breaking the RMAOS sample at line 1794 (rawRMAOS = TexRMAOSSampler.SampleBias(SampRMAOSSampler, ...)) which has no FACEGEN guard of its own. The two separate #if blocks are necessary.

# if defined(TRUE_PBR) && !defined(FACEGEN)
Texture2D<float4> TexParallaxSampler : register(t4);
# endif
# if defined(TRUE_PBR)

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.

Same question about elseif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same reasoning as the sampler block above — TexRMAOSSampler is sampled at line 1794 inside a plain #if defined(TRUE_PBR) block (no FACEGEN exclusion), so it must be declared for all TRUE_PBR variants. An #elif would make TexRMAOSSampler only visible when TRUE_PBR && FACEGEN, breaking the non-FACEGEN path. Two separate #if blocks are required.

Copilot AI commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please review comments critically and address or explain why not.

Both review comments have been addressed. The two separate #if defined(TRUE_PBR) blocks (instead of #elif) are intentional — SampRMAOSSampler/TexRMAOSSampler must be declared for all TRUE_PBR variants because they are sampled at line 1794 with no FACEGEN guard. Using #elif would omit those declarations for the non-FACEGEN path and break RMAOS sampling there.

Copilot AI requested a review from alandtse March 29, 2026 21:48
@alandtse
alandtse merged commit d2c620a into dev Mar 30, 2026
16 of 17 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
…aders#2030)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alandtse <7086117+alandtse@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit d2c620a)
doodlum pushed a commit to doodlum/skyrim-community-shaders that referenced this pull request Aug 26, 2026
…aders#2030)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alandtse <7086117+alandtse@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

x4500

3 participants