-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix constexpr cast involving matrix type (#3593)
- Loading branch information
Showing
4 changed files
with
273 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tools/clang/test/HLSLFileCheck/hlsl/types/cast/constexpr/constexpr_cast_mat_scalar.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s | ||
// RUN: %dxc -E main -T vs_6_2 -enable-16bit-types %s | FileCheck %s | ||
|
||
// This test checks that constexpr truncation cast involving matrix type. | ||
|
||
// CHECK: define void @main() | ||
|
||
|
||
void main() : OUT { | ||
const float v1 = min16float1x1(0); | ||
const int v2 = min16float1x1(-1); | ||
|
||
const uint v3 = int1x2(0, 0); | ||
const double v4 = bool1x2(1, 2); | ||
|
||
const bool v5 = float2x1(0, 0); | ||
const min16int v6 = double2x1(1, 2); | ||
|
||
const uint v7 = int2x2(0, 0, 0, 0); | ||
const int v8 = min16uint2x2(1, 2, 3, 4); | ||
|
||
const uint v9 = double2x3(0, 0, 0, 0, 0, 0); | ||
const min16int v10 = min16float2x3(1, 2, 3, 4, 5, 6); | ||
|
||
const uint v11 = double3x2(0, 0, 0, 0, 0, 0); | ||
const min16int v12 = min16float3x2(1, 2, 3, 4, 5, 6); | ||
|
||
const bool v13 = min16float3x3(0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const uint v14 = min16int3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); | ||
|
||
const bool v15 = min16float4x4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const int v16 = double4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); | ||
|
||
const uint1x1 v17 = int1x2(0, 0); | ||
const double1x1 v18 = bool1x2(1, 2); | ||
|
||
const bool1x1 v19 = float2x1(0, 0); | ||
const min16int1x1 v20 = double2x1(1, 2); | ||
|
||
const uint2x1 v21 = int2x2(0, 0, 0, 0); | ||
const int2x1 v22 = min16uint2x2(1, 2, 3, 4); | ||
|
||
const uint1x2 v23 = int2x2(0, 0, 0, 0); | ||
const int1x2 v24 = min16uint2x2(1, 2, 3, 4); | ||
|
||
const uint2x2 v25 = double2x3(0, 0, 0, 0, 0, 0); | ||
const min16int2x1 v26 = min16float2x3(1, 2, 3, 4, 5, 6); | ||
|
||
const uint1x2 v27 = double3x2(0, 0, 0, 0, 0, 0); | ||
const min16int1x1 v28 = min16float3x2(1, 2, 3, 4, 5, 6); | ||
|
||
const bool2x3 v29 = min16float3x3(0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const uint3x2 v30 = min16int3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); | ||
|
||
const bool1x1 v31 = min16float3x3(0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const uint2x2 v32 = min16int3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); | ||
|
||
const bool1x1 v33 = min16float4x4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const int2x3 v34 = double4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); | ||
|
||
const bool3x3 v35 = min16float4x4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const int3x4 v36 = double4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); | ||
} |
22 changes: 22 additions & 0 deletions
22
...st/HLSLFileCheck/hlsl/types/cast/constexpr/constexpr_cast_mat_type_stack_oveflow_bug.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// RUN: %dxc -E main -T ps_6_2 %s | FileCheck %s | ||
// RUN: %dxc -E main -T ps_6_2 -enable-16bit-types %s | FileCheck %s | ||
|
||
// This is a regression test for github issue #3041. | ||
|
||
// CHECK: define void @main() | ||
|
||
|
||
static const float sFoo = 1.5; | ||
|
||
static const float3x3 sBar = half3x3 | ||
( | ||
sFoo, 0.0f, -sFoo * 0.5f, | ||
0.0f, sFoo, -sFoo * 0.5f, | ||
0.0f, 0.0f, 1.0f | ||
); | ||
|
||
half4 main() : SV_Target | ||
{ | ||
half3 result = half3(0.0, 0.0, 0.0); | ||
return(float4(result, 0)); | ||
} |
33 changes: 33 additions & 0 deletions
33
...est/HLSLFileCheck/hlsl/types/cast/constexpr/constexpr_cast_mat_types_same_comp_count.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s | ||
// RUN: %dxc -E main -T vs_6_2 -enable-16bit-types %s | FileCheck %s | ||
|
||
// This test checks that constexpr cast between matrices of same dimension but different component type compile fines. | ||
|
||
// CHECK: define void @main() | ||
|
||
|
||
void main() : OUT { | ||
const float1x1 v1 = min16float1x1(0); | ||
const int1x1 v2 = min16float1x1(-1); | ||
|
||
const uint1x2 v3 = int1x2(0, 0); | ||
const double1x2 v4 = bool1x2(1, 2); | ||
|
||
const bool2x1 v5 = float2x1(0, 0); | ||
const min16int2x1 v6 = double2x1(1, 2); | ||
|
||
const uint2x2 v7 = int2x2(0, 0, 0, 0); | ||
const int2x2 v8 = min16uint2x2(1, 2, 3, 4); | ||
|
||
const uint2x3 v9 = double2x3(0, 0, 0, 0, 0, 0); | ||
const min16int2x3 v10 = min16float2x3(1, 2, 3, 4, 5, 6); | ||
|
||
const uint3x2 v11 = double3x2(0, 0, 0, 0, 0, 0); | ||
const min16int3x2 v12 = min16float3x2(1, 2, 3, 4, 5, 6); | ||
|
||
const bool3x3 v13 = min16float3x3(0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const uint3x3 v14 = min16int3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); | ||
|
||
const bool4x4 v15 = min16float4x4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
const int4x4 v16 = double4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); | ||
} |