microsoft / microsoft/DirectXShaderCompiler

fxc.exe vs dxc.exe: "static const int" use as compile time constant

Open
#2,188 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This code construct used to work with fxc.exe but doesn't compile with dxc.
Is this expected?

static const uint2	c2Thread= uint2(8, 8);
static const uint       cThread = c2Thread.x*c2Thread.y;
groupshared float4      S1[cThread];
[numthreads(c2Thread.x, c2Thread.y, 1)]
void csMain() ....

note: inlining the numerical constants does work fine:

static const uint2	c2Thread= uint2(8, 8);
static const uint       cThread = c2Thread.x*c2Thread.y;
groupshared float4      S1[64];
[numthreads(8, 8, 1)]
void csMain() ....

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

Reproduce the shown HLSL with both fxc.exe and dxc.exe, comparing the constant-expression and inlined forms. Trace the compiler behavior for groupshared array sizes and numthreads arguments; done means establishing whether the difference is expected and documenting or correcting the confirmed behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.