microsoft / microsoft/DirectXShaderCompiler
Rewriter remove used static global variable which is used for other static global variable definition used by entryPoint
Open
Nobody has claimed this yet.
bug
rewriter
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
dxr test.hlsl -E VSMain -remove-unused-globals
static const float POINT_SIZE = 3.0f;
static const float3 POINT_SIZE_3 = float3(1.0f, 1.0f, 1.0f) * POINT_SIZE;
struct PSInput
{
float4 position : POSITION;
};
PSInput VSMain(float3 position : POSITION)
{
PSInput psInput;
psInput.position = float4(position, 1.0f);
psInput.position.xyz *= POINT_SIZE_3;
return psInput;
}
In the above test case, EntryPoint is using POINT_SIZE_3 and thus it is not optimized out by rewriter. That POINT_SIZE_3 need POINT_SIZE for variable definition, but rewriter remove POINT_SIZE. It leads to compile error
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 by reproducing the issue with the shown test.hlsl and dxr test.hlsl -E VSMain -remove-unused-globals, then trace the rewriter's unused-global handling. Done means POINT_SIZE is retained when POINT_SIZE_3 is used by VSMain, and the rewritten shader compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100