-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add earlier check for invalid SV_Target[n] (#6771)
According to the HLSL semantics documentation, the valid semantic indices for SV_Target[n] are 0 <= n <= 7: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics A check for this already exists in DXIL validation, but for large values of n, crashes and/or buffer overruns may occur during compilation before validation, so an earlier check is needed. Fixes #6115
- Loading branch information
1 parent
b18fe87
commit a54abe8
Showing
7 changed files
with
49 additions
and
2 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
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
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
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
10 changes: 10 additions & 0 deletions
10
tools/clang/test/SemaHLSL/hlsl/semantics/sv_target.index.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,10 @@ | ||
// RUN: %dxc -T ps_6_0 -E zero -verify %s | ||
// RUN: %dxc -T ps_6_0 -E seven -verify %s | ||
|
||
float4 zero() : SV_Target0 { /* expected-no-diagnostics */ | ||
return float4(0, 1, 2, 3); | ||
} | ||
|
||
float4 seven() : SV_Target7 { /* expected-no-diagnostics */ | ||
return float4(0, 1, 2, 3); | ||
} |
5 changes: 5 additions & 0 deletions
5
tools/clang/test/SemaHLSL/hlsl/semantics/sv_target.index.invalid.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,5 @@ | ||
// RUN: %dxc -T ps_6_0 -verify %s | ||
|
||
float4 bad() : SV_Target8 { /* expected-error{{'SV_Target8' is defined with semantic index 8, but only values 0 through 7 are supported}} */ | ||
return float4(0, 1, 2, 3); | ||
} |
9 changes: 9 additions & 0 deletions
9
tools/clang/test/SemaHLSL/hlsl/semantics/sv_target.index.struct.invalid.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,9 @@ | ||
// RUN: %dxc -T ps_6_0 -verify %s | ||
|
||
struct S { | ||
float4 t : SV_Target12345; /* expected-error{{'SV_Target12345' is defined with semantic index 12345, but only values 0 through 7 are supported}} */ | ||
}; | ||
|
||
S main() { | ||
return S(float4(0, 1, 2, 3)); | ||
} |