Skip to content

Commit

Permalink
Support an Upper-case variant of [NumThreads] and [Shader] (#4780)
Browse files Browse the repository at this point in the history
Closes #4746.

This commit adds a support for "NumThreads" and "Shader" attribute keyword, which is in CamelCasing starting with an upper case letter.

The attribute keywords in HLSL are case-insensitive. As an example, one of D3D documents says,

"The attribute name "Shader" is case insensitive."
https://microsoft.github.io/DirectX-Specs/d3d/WorkGraphs.html

Slang, however, doesn't support the case-insensitivity. They should be all lower-case or CamelCasing starting with an upper case.
  • Loading branch information
jkwak-work authored Aug 6, 2024
1 parent d72f9f6 commit aa28f26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions source/slang/core.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,9 @@ attribute_syntax [call] : CallAttribute;
__attributeTarget(FuncDecl)
attribute_syntax [shader(stage)] : EntryPointAttribute;

__attributeTarget(FuncDecl)
attribute_syntax [Shader(stage)] : EntryPointAttribute;

// Hull Shader
__attributeTarget(FuncDecl)
attribute_syntax [maxtessfactor(factor: float)] : MaxTessFactorAttribute;
Expand Down Expand Up @@ -2625,6 +2628,9 @@ attribute_syntax [earlydepthstencil] : EarlyDepthStencilAttribute;
__attributeTarget(FuncDecl)
attribute_syntax [numthreads(x: int, y: int = 1, z: int = 1)] : NumThreadsAttribute;

__attributeTarget(FuncDecl)
attribute_syntax [NumThreads(x: int, y: int = 1, z: int = 1)] : NumThreadsAttribute;

__attributeTarget(FuncDecl)
attribute_syntax [WaveSize(numLanes: int)] : WaveSizeAttribute;

Expand Down
3 changes: 2 additions & 1 deletion tests/compute/frem.slang
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ int test(int inVal)
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;

[numthreads(4, 1, 1)]
[Shader("compute")]
[NumThreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
int tid = dispatchThreadID.x;
Expand Down

0 comments on commit aa28f26

Please sign in to comment.