microsoft / microsoft/DirectXShaderCompiler

Validation error on switches having 8 cases: "I8 can only used as immediate value for intrinsic"

Open
#5,165 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Hello,
I hit this validation issue when compiling a switch with 8 cases. Removing or adding a case fixed the issue. It may be that the validator is confusing i8 as a type with something else.

Hlsl code reproducing the issue: https://shader-playground.timjones.io/6953c16efbd7c9eac2aa77def27b78e4

error: validation errors
D:\local\Temp\cdb50d40-be4c-454a-83de-dc5763aaf698.hlsl:8:2: error: I8 can only be used as immediate value for intrinsic or as i8* via bitcast by lifetime intrinsics.
note: at '%4 = trunc i32 %3 to i8' in block '#0' of function 'ShaderDomain_Cs'.
Validation failed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Shader Playground HLSL reproducer and the validator diagnostic at %4 = trunc i32 %3 to i8 in ShaderDomain_Cs. Trace why the validator rejects this generated i8 value when the switch has eight cases; done means the reproducer validates without the reported error while retaining correct validation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.