Skip to content

Commit 51a565a

Browse files
committed
make hlsl and glsl outputs similar
1 parent b670683 commit 51a565a

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

source/slang/slang-ir-translate-global-varying-var.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ struct GlobalVarTranslationContext
153153
builder.addLayoutDecoration(inputParam, paramLayout);
154154

155155
// Initialize all global variables.
156-
for (Index i = 0; i < inputVars.getCount(); i++)
156+
// for (Index i = 0; i < inputVars.getCount(); i++)
157+
for (Index i = inputVars.getCount() - 1; i >= 0; i--)
157158
{
158159
auto input = inputVars[i];
159160
setInsertBeforeOrdinaryInst(&builder, firstBlock->getFirstOrdinaryInst());

tests/glsl-intrinsic/shader-subgroup/shader-subgroup-builtin-variables-2.slang

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
99
buffer MyBlockName2
1010
{
11-
uint data[];
11+
int data[];
1212
} outputBuffer;
1313

1414
layout(local_size_x = 4) in;
1515

16-
void computeMain()
16+
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
1717
{
18-
int idx = gl_GlobalInvocationID.x;
18+
// There may be some issues with structure padding for global context containing
19+
// global builtin variables.
20+
// int idx = gl_GlobalInvocationID.x;
21+
int idx = dispatchThreadID.x;
22+
1923
uint laneId = gl_SubgroupInvocationID;
2024
// The laneCount will be dependent on target hardware. It seems a count of 1 is valid in spec.
2125
// For now we'll just check it's not 0.

tests/glsl-intrinsic/shader-subgroup/shader-subgroup-builtin-variables.slang

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void computeMain()
3131
// Warp/wave size is not Metal devices is not (consistently) 32.
3232
#if defined(TARGET_METAL)
3333
&& (gl_SubgroupSize > 0U)
34-
&& (gl_subgroupInvocationID > 0U)
34+
&& (gl_SubgroupInvocationID > 0U)
3535
#else
3636
&& gl_SubgroupSize == 32
3737
&& gl_SubgroupInvocationID == 3

0 commit comments

Comments
 (0)