Skip to content

Commit f4d5aa7

Browse files
authored
Revert uint<->int implicit cast cost to prefer promotion to unsigned. (shader-slang#5480)
1 parent 61cddbe commit f4d5aa7

4 files changed

+25
-4
lines changed

source/slang/slang-ast-support-types.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ enum : ConversionCost
127127

128128
// Same-size size unsigned->signed conversions are potentially lossy, but they are commonly
129129
// allowed silently.
130-
kConversionCost_SameSizeUnsignedToSignedConversion = 250,
130+
kConversionCost_SameSizeUnsignedToSignedConversion = 300,
131131

132132
// Conversion from signed->unsigned integer of same or greater size
133-
kConversionCost_SignedToUnsignedConversion = 300,
133+
kConversionCost_SignedToUnsignedConversion = 250,
134134

135135
// Cost of converting an integer to a floating-point type
136136
kConversionCost_IntegerToFloatConversion = 400,

tests/compute/unbounded-array-of-array-syntax.slang

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//IGNORE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp
22
//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
3-
//TEST:CROSS_COMPILE:-target dxbc-assembly -entry computeMain -profile cs_5_1
3+
//TEST:SIMPLE(filecheck=DXIL):-target dxbc-assembly -entry computeMain -profile cs_5_1
44
//TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry computeMain -profile cs_5_1 -emit-spirv-via-glsl
55
//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute
66

@@ -16,6 +16,7 @@ RWStructuredBuffer<int> g_aoa[];
1616
[numthreads(8, 1, 1)]
1717
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
1818
{
19+
// DXIL: cs_5_1
1920
// CHECK: OpCapability {{(ShaderNonUniform|StorageBufferArrayNonUniformIndexing)}}
2021
// CHECK: OpCapability {{(ShaderNonUniform|StorageBufferArrayNonUniformIndexing)}}
2122
// CHECK-DAG: OpDecorate %[[N1:[a-zA-Z0-9_]+]] NonUniform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry main
2+
RWStructuredBuffer<float> result;
3+
// CHECK-NOT: result{{.*}}[int(0)] = 1
4+
// CHECK: result{{.*}}[int(0)] = 2
5+
// CHECK-NOT: result{{.*}}[int(0)] = 1
6+
[numthreads(1,1,1)]
7+
void main()
8+
{
9+
int ic = -1;
10+
uint a = 2;
11+
if (ic < a)
12+
{
13+
result[0] = 1;
14+
}
15+
else
16+
{
17+
// Should pick this branch according to C spec.
18+
result[0] = 2;
19+
}
20+
}

tests/metal/atomic-texture-texture1d.slang

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void test()
128128
InterlockedOr(intTexture1DArray[0], valInt, originalValueInt);
129129
InterlockedXor(intTexture1DArray[0], valInt, originalValueInt);
130130
InterlockedExchange(intTexture1DArray[0], valInt, originalValueInt);
131-
InterlockedCompareExchange(intTexture1DArray[0], valInt, compareValueInt, originalValueUInt);
131+
InterlockedCompareExchange(intTexture1DArray[0], valInt, compareValueInt, originalValueInt);
132132
InterlockedCompareStore(intTexture1DArray[0], valUInt, compareValueUInt);
133133

134134
InterlockedAdd(uintTexture1DArray[0], valUInt);

0 commit comments

Comments
 (0)