diff options
| author | Yong He <yonghe@outlook.com> | 2024-11-02 20:35:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-02 20:35:22 -0700 |
| commit | f4d5aa73fb72a483f04bb6b014e80192331504ea (patch) | |
| tree | 6b3143b85f05ccba735beb7b98531104e8445053 | |
| parent | 61cddbee405935fa8391a757a08bcbe4ea7ac98f (diff) | |
Revert uint<->int implicit cast cost to prefer promotion to unsigned. (#5480)
4 files changed, 25 insertions, 4 deletions
diff --git a/source/slang/slang-ast-support-types.h b/source/slang/slang-ast-support-types.h index beacbaebe..0a2dbe78d 100644 --- a/source/slang/slang-ast-support-types.h +++ b/source/slang/slang-ast-support-types.h @@ -127,10 +127,10 @@ enum : ConversionCost // Same-size size unsigned->signed conversions are potentially lossy, but they are commonly // allowed silently. - kConversionCost_SameSizeUnsignedToSignedConversion = 250, + kConversionCost_SameSizeUnsignedToSignedConversion = 300, // Conversion from signed->unsigned integer of same or greater size - kConversionCost_SignedToUnsignedConversion = 300, + kConversionCost_SignedToUnsignedConversion = 250, // Cost of converting an integer to a floating-point type kConversionCost_IntegerToFloatConversion = 400, diff --git a/tests/compute/unbounded-array-of-array-syntax.slang b/tests/compute/unbounded-array-of-array-syntax.slang index 10c4d277f..c0508894a 100644 --- a/tests/compute/unbounded-array-of-array-syntax.slang +++ b/tests/compute/unbounded-array-of-array-syntax.slang @@ -1,6 +1,6 @@ //IGNORE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp //DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -//TEST:CROSS_COMPILE:-target dxbc-assembly -entry computeMain -profile cs_5_1 +//TEST:SIMPLE(filecheck=DXIL):-target dxbc-assembly -entry computeMain -profile cs_5_1 //TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry computeMain -profile cs_5_1 -emit-spirv-via-glsl //DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute @@ -16,6 +16,7 @@ RWStructuredBuffer<int> g_aoa[]; [numthreads(8, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { + // DXIL: cs_5_1 // CHECK: OpCapability {{(ShaderNonUniform|StorageBufferArrayNonUniformIndexing)}} // CHECK: OpCapability {{(ShaderNonUniform|StorageBufferArrayNonUniformIndexing)}} // CHECK-DAG: OpDecorate %[[N1:[a-zA-Z0-9_]+]] NonUniform diff --git a/tests/language-feature/overload-resolution-signed-unsigned.slang b/tests/language-feature/overload-resolution-signed-unsigned.slang new file mode 100644 index 000000000..f8de85810 --- /dev/null +++ b/tests/language-feature/overload-resolution-signed-unsigned.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry main +RWStructuredBuffer<float> result; +// CHECK-NOT: result{{.*}}[int(0)] = 1 +// CHECK: result{{.*}}[int(0)] = 2 +// CHECK-NOT: result{{.*}}[int(0)] = 1 +[numthreads(1,1,1)] +void main() +{ + int ic = -1; + uint a = 2; + if (ic < a) + { + result[0] = 1; + } + else + { + // Should pick this branch according to C spec. + result[0] = 2; + } +}
\ No newline at end of file diff --git a/tests/metal/atomic-texture-texture1d.slang b/tests/metal/atomic-texture-texture1d.slang index 70f639cb5..8a47af8ee 100644 --- a/tests/metal/atomic-texture-texture1d.slang +++ b/tests/metal/atomic-texture-texture1d.slang @@ -128,7 +128,7 @@ void test() InterlockedOr(intTexture1DArray[0], valInt, originalValueInt); InterlockedXor(intTexture1DArray[0], valInt, originalValueInt); InterlockedExchange(intTexture1DArray[0], valInt, originalValueInt); - InterlockedCompareExchange(intTexture1DArray[0], valInt, compareValueInt, originalValueUInt); + InterlockedCompareExchange(intTexture1DArray[0], valInt, compareValueInt, originalValueInt); InterlockedCompareStore(intTexture1DArray[0], valUInt, compareValueUInt); InterlockedAdd(uintTexture1DArray[0], valUInt); |
