microsoft / microsoft/DirectXShaderCompiler
Validation error on switches having 8 cases: "I8 can only used as immediate value for intrinsic"
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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